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

# Smart Contract Write

Execute a state-changing function on any smart contract. Provide the contract ABI and function name; the transaction is signed and broadcast from your connected wallet. Use for: staking, governance votes, custom contract interactions.

![Smart Contract Write logo](https://ai-icon.b3.fun/logo/ethereum)
Catalog action EVM Onchain wallet Gas send

Execute a state-changing function on any smart contract. Provide the contract ABI and function name; the transaction is signed and broadcast from your connected wallet. Use for: staking, governance votes, custom contract interactions.

**Review wallet and value movement**

This action can require a wallet connector, gas, token movement, or an external side effect. Test with simulation or a controlled amount before using it in a live workflow.

## At a Glance

| Field | Value |
| --- | --- |
| Action ID | `evm-write` |
| Category | EVM Onchain |
| Connector | `wallet` |
| Requires gas | Yes |
| Funds movement | `send` |
| Tags | `blockchain`, `evm`, `write`, `contract`, `transaction`, `execute`, `custom`, `abi`, `defi` |

## Payload Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `contractProjectId` | `string` | No | Select a deployed contract project or choose 'Custom' to enter address and ABI manually. |
| `chainId` | `number` | Yes | Chain ID \(1=Ethereum, 137=Polygon, 56=BSC, 8453=Base, etc.\) |
| `contractAddress` | `string` | No | The contract address to interact with |
| `abi` | `string` | No | The ABI of the contract function\(s\) as a JSON string array. Can be full contract ABI or just the function signature needed. |
| `functionName` | `string` | Yes | The name of the function to call |
| `args` | `object` | No | Arguments for the function call as a JSON string array \(e.g., '\["0x123...", "1000"\]'\) or a native array. Optional if function has no arguments. |
| `value` | `string` | No | Amount of native token \(ETH, MATIC, etc.\) to send with the transaction in Wei. Optional, defaults to '0'. |
| `gasLimit` | `string` | No | Optional gas limit for the transaction. If not provided, will be estimated. |
| `maxFeePerGas` | `string` | No | Optional max fee per gas in Wei \(EIP-1559\). If not provided, will be estimated. |
| `maxPriorityFeePerGas` | `string` | No | Optional max priority fee per gas in Wei \(EIP-1559\). If not provided, will be estimated. |
| `waitForConfirmation` | `boolean` | No | Whether to wait for transaction confirmation. Defaults to true. |
| `confirmations` | `number` | No | Number of confirmations to wait for. Defaults to 1. |

## Result Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | `string` | Yes | - |
| `transactionHash` | `string` | Yes | The transaction hash |
| `blockNumber` | `number` | No | The block number where transaction was mined |
| `gasUsed` | `string` | No | Gas used by the transaction |
| `from` | `string` | No | The sender address \(Turnkey wallet\) |
| `effectiveGasPrice` | `string` | No | The effective gas price used |

## Examples

**Workflow node**

```json
{
  "type": "evm-write",
  "payload": {
    "functionName": "example-functionName",
    "chainId": 8453
  },
  "children": [],
  "connector": {
    "type": "wallet",
    "id": "conn_wallet"
  }
}
```
  **Test with API**

```bash
curl -X POST "https://api.b3os.org/v1/actions/evm-write/test" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "inputs": {
    "functionName": "example-functionName",
    "chainId": 8453
  }
}'
```

**Use expressions for dynamic values**

Payload fields can use workflow expressions such as `{{$trigger.body.amount}}`, `{{$nodes.fetch.result.price}}`, and `{{$props.asset}}` when the value should come from a trigger, prior node, or reusable workflow prop.