EVM (Ethereum Virtual Machine)
EvmTools enables agents to interact with Ethereum and EVM-compatible blockchains for transactions and smart contract operations.
Example
The following agent can interact with Ethereum blockchain:
1from kern.agent import Agent2from kern.tools.evm import EvmTools34agent = Agent(5 instructions=[6 "You are a blockchain assistant that helps with Ethereum transactions",7 "Help users send transactions and interact with smart contracts",8 "Always verify transaction details before executing",9 "Provide clear information about gas costs and transaction status",10 ],11 tools=[EvmTools()],12)1314agent.print_response("Check my account balance and send 0.01 ETH to 0x742d35Cc6634C0532925a3b8D4034DfA8e5D5C4B", stream=True)Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
private_key | Optional[str] | None | Private key for signing transactions. Uses EVM_PRIVATE_KEY. |
rpc_url | Optional[str] | None | RPC URL for blockchain connection. Uses EVM_RPC_URL. |
enable_send_transaction | bool | True | Enable transaction sending functionality. |
Toolkit Functions
| Function | Description |
|---|---|
send_transaction | Send ETH or interact with smart contracts on the blockchain. |
get_balance | Get ETH balance for an address. |
get_transaction | Get transaction details by hash. |
estimate_gas | Estimate gas cost for a transaction. |