call
npx machina-cli add skill HCS412/contractkit/call --openclawContractKit: Call
Call functions on deployed contracts.
Usage
/contractkit:call <function> [--args <arguments>] [--network <network>] [--contract <name>]
Process
1. Verify Project
Check that foundry.toml exists. If not:
Error: Not in a ContractKit project.
Navigate to a project directory or run /contractkit:new
2. Determine Network
Default: local
RPC URLs:
local:http://127.0.0.1:8545sepolia: FromSEPOLIA_RPC_URLin.env
3. Load Deployment
Check for deployments/<network>.json. If missing:
Error: No deployment found for network 'local'.
To deploy:
1. Start local chain: /contractkit:local
2. Deploy: /contractkit:deploy local
To check status: /contractkit:status
4. Select Contract
Contract selection rules:
- If
--contract <name>specified, use that - If only one contract in deployment file, use it
- If multiple contracts, default to "Token"
- If "Token" not found and multiple exist, ask user
Example deployment file:
{
"Token": "0x5FbDB2315678afecb367f032d93F642f64180aa3"
}
5. Load ABI
Find ABI from Foundry output:
out/<ContractName>.sol/<ContractName>.json
If ABI not found:
Error: ABI not found. Run 'forge build' first.
6. Determine Call Type
View/Pure functions (read-only) → cast call
State-changing functions → cast send
Known view functions:
name,symbol,decimals,totalSupplybalanceOf,allowance,ownerhasRole,getRoleAdminsupportsInterface
7. Execute Call
For view functions:
cast call <address> "<signature>" <args> --rpc-url <rpc>
For state-changing functions:
cast send <address> "<signature>" <args> --rpc-url <rpc>
8. Display Result
Decode and show human-readable output:
Token.name() → "MyToken"
Token.balanceOf(0xf39F...) → 1000000000000000000 (1.0 TOKEN)
Function Signatures
Common ERC20/AccessControl signatures:
| Function | Signature | Type | Args |
|---|---|---|---|
name | name() | view | none |
symbol | symbol() | view | none |
decimals | decimals() | view | none |
totalSupply | totalSupply() | view | none |
balanceOf | balanceOf(address) | view | 1 address |
allowance | allowance(address,address) | view | 2 addresses |
mint | mint(address,uint256) | write | address, amount |
transfer | transfer(address,uint256) | write | address, amount |
approve | approve(address,uint256) | write | address, amount |
grantRole | grantRole(bytes32,address) | write | role, address |
revokeRole | revokeRole(bytes32,address) | write | role, address |
hasRole | hasRole(bytes32,address) | view | role, address |
For unknown functions, ask user for full signature or check ABI.
Examples
Read Token Name
/contractkit:call name
Output: MyToken
Check Balance
/contractkit:call balanceOf --args "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
Output: 1000000000000000000 (1.0 tokens)
Mint Tokens
/contractkit:call mint --args "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" "1000000000000000000"
Output: Transaction sent: 0x... (success)
Check on Sepolia
/contractkit:call name --network sepolia
Specify Contract
/contractkit:call name --contract MyToken
Error Messages
No Deployment
Error: No deployment found for network 'local'.
Have you deployed yet?
/contractkit:local # Start local chain
/contractkit:deploy local # Deploy contracts
Check status: /contractkit:status
Chain Not Running
Error: Cannot connect to local chain at http://127.0.0.1:8545
Start Anvil: /contractkit:local
Function Not Found
Error: Function 'foo' not found in Token ABI.
Available functions:
- name()
- symbol()
- balanceOf(address)
- mint(address,uint256)
...
Tip: Use full signature for custom functions:
/contractkit:call "myFunction(uint256,address)" --args "123" "0x..."
Wrong Arguments
Error: Function 'balanceOf' expects 1 argument, got 0.
Usage: /contractkit:call balanceOf --args "<address>"
Execution Reverted
Error: Transaction reverted.
Reason: AccessControl: account 0x... is missing role 0x...
This usually means:
- You don't have permission (check roles)
- A require() condition failed
- The contract is paused
Missing RPC URL
Error: SEPOLIA_RPC_URL not set.
Add to your .env file:
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
Tips
- Use
/contractkit:statusto see deployed contracts and addresses - For amounts, use wei (1 ETH = 1000000000000000000 wei)
- The
--networkflag defaults tolocal - State-changing calls require a funded account on the network
Source
git clone https://github.com/HCS412/contractkit/blob/main/plugins/contractkit/skills/call/SKILL.mdView on GitHub Overview
This skill guides you through calling functions on deployed contracts. It verifies the project, selects the network, loads deployments and ABIs, and uses cast to read or modify contract state.
How This Skill Works
It validates a ContractKit project, picks the network, loads the deployments for that network, selects the target contract, and reads its ABI. It then determines if the function is view or state changing and uses cast call or cast send accordingly, finally decoding and displaying results.
When to Use It
- Read token metadata such as name, symbol, or decimals using a view function
- Check on-chain balances or allowances for an address
- Mint or transfer tokens by calling state-changing functions
- Test interactions on a specific network like sepolia
- Verify deployment and contract availability before interacting
Quick Start
- Step 1: Run in a ContractKit project and set your network
- Step 2: Load deployment and select a contract, then load its ABI
- Step 3: Run cast call or cast send with the function signature and arguments, then read the decoded result
Best Practices
- Ensure you are in a ContractKit project (foundry.toml exists)
- Load the correct network and deployment file for your target network
- Choose explicit contract with --contract if multiple contracts exist
- Build the ABI with forge before calling
- Decode results and handle errors gracefully
Example Use Cases
- Read Token name with /contractkit:call name
- Check balanceOf for an address using --args
- Mint tokens by calling mint with recipient and amount
- Inspect on Sepolia using --network sepolia
- Specify a contract with --contract MyToken to avoid ambiguity