---
title: otxn_param
description: Retrieve the parameter value for a named Invoke transaction parameter
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

### Behaviour

<Tabs>
<TabItem label="C">
* Look up the value for a named parameter specified in `read_ptr` on the originating transaction.
* Write the parameter's value to `write_ptr`
</TabItem>

<TabItem label="JavaScript">
* Look up the value for a named parameter specified on the originating transaction.
* Returns the value of the specified parameter, or an ErrorCode if the lookup fails.
</TabItem>
</Tabs>

### Definition

<Tabs>
<TabItem label="C">
```c
int64_t otxn_param (
    uint32_t write_ptr,
    uint32_t write_len,
    uint32_t read_ptr,
    uint32_t read_len
);
```
</TabItem>

<TabItem label="JavaScript">
```javascript
function otxn_param(name: ByteArray | HexString): ErrorCode | ByteArray
```
</TabItem>
</Tabs>



### Example

<Tabs>
<TabItem label="C">
```c
uint8_t pname[] = {0xCAU, 0xFEU};
uint8_t pvalue[32];
int64_t value_len = 
    otxn_param(pvalue, 32, pname, 2);
```
</TabItem>

<TabItem label="JavaScript">
```javascript
const pname = [0xCA, 0xFE]
const pvalue = otxn_param(pname)
```
</TabItem>
</Tabs>



### Parameters

<Tabs>
<TabItem label="C">
| Name       | Type      | Description                                                                              |
| ---------- | --------- | ---------------------------------------------------------------------------------------- |
| write_ptr | uint32_t | Pointer to a buffer of a suitable size to store the output. Should be at least 32 bytes. |
| write_len | uint32_t | Length of the output buffer.                                                             |
| read_ptr  | uint32_t | Pointer to a buffer containing the parameter's name                                      |
| read_len  | uint32_t | Length of the parameter's name                                                           |
</TabItem>

<TabItem label="JavaScript">
| Name | Type                   | Description                                                               |
| ---- | ---------------------- | ------------------------------------------------------------------------- |
| name | ByteArray \| HexString | The name of the parameter to look up, specified as a ByteArray or string. |
</TabItem>
</Tabs>



### Return Code

<Tabs>
<TabItem label="C">
| Type     | Description                                                                                                                                                                                                                                                                                                                                                                                    |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| int64_t | <p>The number of bytes written<br /><br />If negative, an error:<br /><code>OUT_OF_BOUNDS</code><br />- pointers/lengths specified outside of hook memory.<br /><br /><code>DOESNT_EXIST</code><br />- The specified paramater doesn't exist or is null<br /><br /><code>TOO_SMALL</code><br />- The parameter name can't be null<br /><br /><code>TOO_BIG</code><br />- The parameter name is greater than 32 bytes</p> |
</TabItem>

<TabItem label="JavaScript">
| Type                   | Description                                                                        |
| ---------------------- | ---------------------------------------------------------------------------------- |
| ErrorCode \| ByteArray | Returns the value of the specified parameter, or an ErrorCode if the lookup fails. |
</TabItem>
</Tabs>

