Transfer
The Sodium Wallet is compatible with various methods for sending transactions
Simple Transfer
// send 1eth to 0x812D3C67d283F3b9d1F1E347DF37F0C7fbD6a0B0
const transaction = {
to: "0x812D3C67d283F3b9d1F1E347DF37F0C7fbD6a0B0",
value: "1000000000000000000"
}
const signer = wallet.getSigner()
const txnResponse = await signer.sendTransaction(transaction)
console.log(txnResponse)
// wait for the transaction to be mined
await txnResponse.wait()Transfer ERC20
// ERC20 contract address to send from
const erc20ContractAddress = "";
// Destination address for the transfer
const recipientAddress = "";
// Transfer amount
const amount = "";
const erc20Interface = new ethers.utils.Interface([
'function transfer(address _to, uint256 _value)'
])
// Encode an ERC-20 token transfer to recipient of the specified amount
const data = erc20Interface.encodeFunctionData(
'transfer', [recipientAddress, amount]
)
const transaction = {
to: erc20ContractAddress,
data
}
const signer = wallet.getSigner()
const txnResponse = await signer.sendTransaction(transaction)
console.log(txnResponse)
// wait for the transaction to be mined
await txnResponse.wait()Batch Transactions
Last updated