👉How to roll in tokens
ERC20 tokens
async function getZkEvmClient(
privateKey: string,
userAddress: string,
network: string = 'testnet',
version: string = 'starfish'
) {
const zkEvmClient = new ZkEvmClient()
return zkEvmClient.init({
log: true,
network,
version,
child: {
name: 'cycle',
provider: new HDWalletProvider(privateKey, RPC_CYCLE),
defaultConfig: {
from: userAddress,
},
},
parent: {
name: 'sepolia',
provider: new HDWalletProvider(privateKey, RPC_SEPOLIA),
defaultConfig: {
from: userAddress,
},
},
})
}
async function rollin(
tokenId: number,
amount: BigNumberish,
receiverAddress: string
) {
const client = await getZkEvmClient()
const erc20Token = client.customERC20(tokenId, true)
const result = await erc20Token.deposit(amount, receiverAddress)
const txHash = await result.getTransactionHash()
const receipt = await result.getReceipt()
}Last updated