🔄Transfer within Cycle

Transfer tokens within Cycle can be easily accomplished by using ether.js and web3.js. A coding example can be seen below:

import { Contract, Wallet, BigNumberish, providers } from 'ethers'
const rpc = 'https://rpc-testnet.cyclenetwork.io'
const abi = [
  'function transfer(address to, uint256 amount) external returns (bool)'
]

async erc20Transfer(
    privateKey: string,
    tokenAddress: string,
    toAddress: string,
    amount: BigNumberish
) {
    const provider = new providers.JsonRpcProvider(rpc)
    const signer = new Wallet(privateKey, provider)
    const contract = new Contract(tokenAddress, abi, signer)
    const tx = await contract.transfer(toAddress, amount)
    const recepit = await tx.wait()
}

We can also transfer tokens by MetaMask, which is connected to Cycle directly.

Last updated