> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oumla.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Contract Interactions

> SDK methods for calling contract functions and reading transaction receipts

Call read and write functions on deployed contracts and retrieve transaction receipts.

## Methods

### `readCallFunction()`

Call a read-only function on a deployed contract.

**Signature:**

```typescript theme={null}
readCallFunction(
  networkId: string,
  contractAddress: string,
  request: ReadCallFunctionRequest,
  requestOptions?: RequestOptions
): Promise<ReadCallFunctionResponse>
```

**Parameters:**

| Parameter             | Type     | Required | Description                            |
| --------------------- | -------- | -------- | -------------------------------------- |
| `networkId`           | `string` | Yes      | Network ID (UUID from `getNetworks()`) |
| `contractAddress`     | `string` | Yes      | Contract address                       |
| `request.abiFunction` | `object` | Yes      | ABI function object                    |

**Example Request:**

```typescript theme={null}
const result = await client.contractInteractions.readCallFunction('your-network-id', '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb', {
  abiFunction: {
    name: 'balanceOf',
    type: 'function',
    inputs: [
      { name: 'owner', type: 'address' }
    ],
    outputs: [
      { name: '', type: 'uint256' }
    ]
  }
});
```

**Example Response:**

```typescript theme={null}
{
  data: {
    result: {
      data: {
        result: {
          // Decoded function result
        },
        functionName: 'balanceOf',
        contractAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
        network: 'ETH',
        encodedData: '0x1234567890abcdef...'
      },
      success: true,
      status: 200
    }
  }
}
```

**Response Fields:**

| Field                              | Type      | Required | Description                     |
| ---------------------------------- | --------- | -------- | ------------------------------- |
| `data.result.data.result`          | `object`  | No       | Decoded function result         |
| `data.result.data.functionName`    | `string`  | No       | Function name that was called   |
| `data.result.data.contractAddress` | `string`  | No       | Contract address                |
| `data.result.data.network`         | `string`  | No       | Network                         |
| `data.result.data.encodedData`     | `string`  | No       | Encoded function call data      |
| `data.result.success`              | `boolean` | No       | Whether the call was successful |
| `data.result.status`               | `number`  | No       | HTTP status code                |

```typescript theme={null}
console.log('Function result:', result.data.result?.data?.result);
```

***

### `writeCallFunction()`

Call a write function on a deployed contract. Returns a workflow ID for async processing.

**Signature:**

```typescript theme={null}
writeCallFunction(
  networkId: string,
  contractAddress: string,
  request: WriteCallFunctionRequest,
  requestOptions?: RequestOptions
): Promise<WriteCallFunctionResponse>
```

**Parameters:**

| Parameter             | Type     | Required | Description                            |
| --------------------- | -------- | -------- | -------------------------------------- |
| `networkId`           | `string` | Yes      | Network ID (UUID from `getNetworks()`) |
| `contractAddress`     | `string` | Yes      | Contract address                       |
| `request.addressId`   | `string` | Yes      | Address ID for signing                 |
| `request.clientShare` | `string` | Yes      | Client share for signing               |
| `request.abiFunction` | `object` | Yes      | ABI function object                    |
| `request.amount`      | `string` | No       | Amount to send with transaction        |
| `request.feeLevel`    | `string` | No       | Transaction fee level                  |

**Example Request:**

```typescript theme={null}
const result = await client.contractInteractions.writeCallFunction('your-network-id', '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb', {
  addressId: 'address-id',
  clientShare: 'your-client-share',
  abiFunction: {
    name: 'transfer',
    type: 'function',
    inputs: [
      { name: 'to', type: 'address' },
      { name: 'amount', type: 'uint256' }
    ],
    outputs: []
  },
  amount: '0',
  feeLevel: 'standard'
});
```

**Example Response:**

```typescript theme={null}
{
  data: {
    workflowResult: {
      workflowId: 'workflow-id-here',
      operationId: 'write-call-id-here',
      status: 'started',
      message: 'Write call workflow started'
    }
  }
}
```

**Response Fields:**

| Field                             | Type                             | Required | Description                            |
| --------------------------------- | -------------------------------- | -------- | -------------------------------------- |
| `data.workflowResult.workflowId`  | `string`                         | Yes      | Workflow ID for tracking function call |
| `data.workflowResult.operationId` | `string`                         | Yes      | Operation ID (e.g. `writeCallId`)      |
| `data.workflowResult.status`      | `'started' \| 'already_running'` | Yes      | Workflow status                        |
| `data.workflowResult.message`     | `string`                         | Yes      | Human-readable status message          |

```typescript theme={null}
console.log('Workflow ID:', result.data.workflowResult.workflowId);
```

***

### `getTransactionReceipt()`

Get transaction receipt for a transaction hash.

**Signature:**

```typescript theme={null}
getTransactionReceipt(
  networkId: string,
  txId: string,
  requestOptions?: RequestOptions
): Promise<TransactionReceiptResponse>
```

**Parameters:**

| Parameter   | Type     | Required | Description                            |
| ----------- | -------- | -------- | -------------------------------------- |
| `networkId` | `string` | Yes      | Network ID (UUID from `getNetworks()`) |
| `txId`      | `string` | Yes      | Transaction hash                       |

**Example:**

```typescript theme={null}
const receipt = await client.contractInteractions.getTransactionReceipt(
  'your-network-id',
  '0x1234567890abcdef...'
);

console.log('Status:', receipt.data.receipt?.status);
console.log('Block Number:', receipt.data.receipt?.blockNumber);
console.log('Gas Used:', receipt.data.receipt?.gasUsed);
```

***

### `getDeployedContractAbi()`

Get contract ABI for a deployed contract.

**Signature:**

```typescript theme={null}
getDeployedContractAbi(
  networkId: string,
  contractAddress: string,
  requestOptions?: RequestOptions
): Promise<ContractAbiResponse>
```

**Example:**

```typescript theme={null}
const abi = await client.contractInteractions.getDeployedContractAbi(
  'your-network-id',
  '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
);

console.log('ABI:', abi.data.contractAbi?.abi);
```
