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:| Network | Mainnet | Testnet | Chain ID |
|---|---|---|---|
| Ethereum | https://rpc.ankr.com/eth | Sepolia: https://ethereum-sepolia-rpc.publicnode.com | 1 / 11155111 |
| Polygon | https://polygon-rpc.com | Amoy: https://rpc-amoy.polygon.technology | 137 / 80002 |
| Arbitrum | https://arbitrum.llamarpc.com | Sepolia: https://sepolia-rollup.arbitrum.io/rpc | 42161 / 421614 |
| Base | https://base.llamarpc.com | Sepolia: https://sepolia.base.org | 8453 / 84532 |
| Avalanche | https://api.avax.network/ext/bc/C/rpc | Fuji: https://avalanche-fuji-c-chain.publicnode.com | 43114 / 43113 |
| BSC | https://bsc-dataseed1.defibit.io | Testnet: https://data-seed-prebsc-2-s2.bnbchain.org:8545 | 56 / 97 |
| Linea | https://rpc.linea.build | Goerli: https://rpc.goerli.linea.build | 59144 / 59140 |
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:Listening for events (Not implemented)
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:| Property/Method | Description | API Reference |
|---|---|---|
instance.provider | The JsonRpcProvider instance for interacting with the Ethereum network | JsonRpcProvider |
instance.wallet | The Wallet instance representing the connected account | Wallet |
instance.contracts | A Map of Contract instances for interacting with smart contracts | Contract |
instance.signTransaction(s) | Method(s) to sign one or multiple transactions | - |