Send ETH Using Smart Account
1. Create a Smart Wallet 🔨​
Please add a .env
file in your project with this format.
PRIVATE_KEY = // your EOA private Key
RPC_URL = // your RPC URL
The PRIVATE_KEY
will be added corresponding to a EOA Signer that will be added as a owner of the Smart Account. You can get get private keys of the EOA Signer from Wallets like Metamask, Coinbase, TrustWallet etc.
INFO
In the Ethereum Virtual Machine (EVM), smart contracts cannot initiate transactions by themselves. Instead, an external signer is required to induce state changes and initiate transactions within the EVM.
We highly suggest you use a dedicate RPC Service for your transactions. You can get RPCs from Infura, QuickNode, etc.
We use Pimlico Bundlers kindly sign in to Pimlico Dashboard and get your Bundler URL.
2. To Send ETH Using Smart Account​
Now create a sendETH.js
and paste the code below.
axirwallet/sendETH.js
import { AxirCore } from "axr-erc4337-sdk";
const recipient = "0x123...";
const amount = "0.001";
const usePaymaster = "false";
const paymasterType = undefined;
const smartWalletAccount = new AxirCore(
process.env.PRIVATE_KEY,
process.env.RPC_URL,
process.env.BUNDLER_URL,
0 // salt you can enter any value
);
const ethTxHash = await smartWalletAccount.sendEth(
recipient,
ethers.parseEther(amount),
undefined,
usePaymaster,
paymasterType
);