write_contract
Initiate state-changing smart contract functions on Ethereum-compatible blockchains. Specify contract details, ABI, function, and arguments, then sign and send transactions securely.
Instructions
Write data to a smart contract by calling a state-changing function. This modifies blockchain state and requires gas payment and transaction signing.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"contractAddress": "<contractAddress>",
"abi": "<abi>",
"functionName": "<functionName>",
"args": "<args>",
"privateKey": "<privateKey>"
},
"name": "write_contract"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| abi | Yes | The ABI (Application Binary Interface) of the smart contract function, as a JSON array | |
| args | Yes | The arguments to pass to the function, as an array (e.g., ['0x1234...', '1000000000000000000']) | |
| contractAddress | Yes | The address of the smart contract to interact with | |
| functionName | Yes | The name of the function to call on the contract (e.g., 'transfer') | |
| network | No | Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet. | |
| privateKey | Yes | Private key of the sending account in hex format (with or without 0x prefix). SECURITY: This is used only for transaction signing and is not stored. |