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 Agent
2from kern.tools.evm import EvmTools
3
4agent = 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)
13
14agent.print_response("Check my account balance and send 0.01 ETH to 0x742d35Cc6634C0532925a3b8D4034DfA8e5D5C4B", stream=True)

Toolkit Params

ParameterTypeDefaultDescription
private_keyOptional[str]NonePrivate key for signing transactions. Uses EVM_PRIVATE_KEY.
rpc_urlOptional[str]NoneRPC URL for blockchain connection. Uses EVM_RPC_URL.
enable_send_transactionboolTrueEnable transaction sending functionality.

Toolkit Functions

FunctionDescription
send_transactionSend ETH or interact with smart contracts on the blockchain.
get_balanceGet ETH balance for an address.
get_transactionGet transaction details by hash.
estimate_gasEstimate gas cost for a transaction.

Developer Resources