write_contract
Modify blockchain state by calling state-changing smart contract functions. Specify contract address, ABI, function name, and arguments. Requires gas payment and transaction signing with a private key.
Instructions
Write data to a smart contract by calling a state-changing function. This modifies blockchain state and requires gas payment and transaction signing.
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. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"abi": {
"description": "The ABI (Application Binary Interface) of the smart contract function, as a JSON array",
"type": "array"
},
"args": {
"description": "The arguments to pass to the function, as an array (e.g., ['0x1234...', '1000000000000000000'])",
"type": "array"
},
"contractAddress": {
"description": "The address of the smart contract to interact with",
"type": "string"
},
"functionName": {
"description": "The name of the function to call on the contract (e.g., 'transfer')",
"type": "string"
},
"network": {
"description": "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet.",
"type": "string"
},
"privateKey": {
"description": "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.",
"type": "string"
}
},
"required": [
"contractAddress",
"abi",
"functionName",
"args",
"privateKey"
],
"type": "object"
}