EVM
The Ethereum Virtual Machine (EVM) is the runtime environment for smart contracts in Ethereum. It’s a fundamental part of the Ethereum network and is used by many other blockchain platforms that aim to provide Ethereum-like functionality. Our EVM SDK provides a simple interface to interact with EVM-compatible blockchains.Supported Networks
The EVM SDK supports multiple EVM-compatible networks:Core Concepts
- Accounts: Ethereum addresses that can hold balance and send transactions
- Transactions: Signed data packages that store a message to be sent from an externally owned account
- Gas: The fee required to execute operations on the Ethereum network
- Smart Contracts: Programs that run on the Ethereum blockchain
Setting up your wallet
To interact with EVM-compatible chains, you’ll need a wallet with a private key. You can use tools like MetaMask or hardware wallets to generate and manage your keys securely. For testing purposes, you can use faucets to get testnet tokens: Ethereum Sepolia: Polygon Amoy: Arbitrum Sepolia: Base Sepolia:Initialization
Import the SDK and create a new instance:Connecting your wallet
To create signed transaction payloads, you need to connect your wallet to the SDK:getAddress method:
Creating a token transfer payload
To create a signed transaction payload to transfer ETH, you can use thepreparePay method:
signedTx is a signed transaction that can be used a DEMOS transaction.
Creating multiple transfer payload
You can prepare multiple signed transaction payloads at once using thepreparePays method:
signedTxs is an array of signed transaction payloads that can be used in a DEMOS transaction.
Checking balance
You can check the balance of an address using thegetBalance method:
Signing messages
Working with smart contracts
The SDK provides methods to interact with smart contracts. Note thatabi must be passed as a JSON string, not a JavaScript array — pass it through JSON.stringify(abi) if you have it as an array.
readFromContract(contract, fnName, args) calls a view/pure function and returns the raw return value.
writeToContract(contract, fnName, args, options?) builds, signs, and broadcasts a state-changing transaction. The optional fourth argument accepts { gasLimit?: number; value?: string } — value is the ETH amount as a decimal string and is parsed via parseEther.
Listening for events
You can listen for specific events or all events from a contract:Cleaning up
To disconnect your wallet and clean up resources, you can use thedisconnect method:
Advanced usage
For more advanced use cases, you can access underlying properties and methods of the EVM instance:
You can use these properties and methods to perform custom operations: