Cycle Network Docs
  • 🙌Welcome
    • 📖Genesis of Cycle Network
    • 🌀What is Cycle Network
    • 😃Benefits of Cycle Bridgeless
      • 🧑‍🤝‍🧑For End User
      • 👨‍đŸ”ŦFor Developer
  • âš™ī¸Quick Start
    • đŸŦConnect to Cycle
      • Connect to Cycle Mainnet
        • â›ĩCycle Sailboat
      • Connect to Cycle Testnet
        • đŸĒŧCycle JellyFish
        • đŸĻ‘Cycle CuttleFish (Archived)
        • ⭐Cycle StarFish (Archived)
        • đŸ’ĩTestnet Tokens
      • Operator Guideline
    • 🔄Transfer within Cycle
    • 👉How to roll in tokens
    • 👈How to roll out tokens
    • ✋Claim assets on destination chain
  • đŸ› ī¸Technical Introduction
    • Overview
    • Technical Background
      • ZK-Rollup
      • Sequencer
      • Zero-knowledge hardware acceleration
      • Fully Homomorphic Encryption
    • Module Explanation
      • Omni State Channel Indexer (OSCI)
      • Decentralized Aggregate Sequencer
      • Zero-knowledge hardware acceleration
      • Fully Homomorphic Encryption
  • đŸ•šī¸Cycle-CORE-SDK
    • Introduction
    • Getting Started
    • Onchain Transaction
    • Query Service
  • 💡Case Study
    • 🐷Piggy Bank
    • 🎮TapUp
    • â¤ī¸â€đŸ”ĨBridgeless All Chain Trading
    • 🤑Bridgeless All Chain AI Application
  • đŸĸResources
    • Website
    • Medium
    • White Paper
    • GitHub
  • 😇Community and support
    • 📞Contact Us
    • đŸĩTwitter
    • 🤖Telegram
    • 💰Campaign
Powered by GitBook
On this page
  1. Quick Start

How to roll in tokens

ERC20 tokens

The most outstanding advantage of Cycle is that it allows assets from multiple chains to be deposited into Cycle, which is named Rollin in our scenario. The most common scene is rolling erc20 tokens to Cycle, which is supported by SDK. Here we show an example of how to rollin ERC20 token from Sepolia to Cycle.

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()
}

Currently, we only have a test ERC20 token named 'CYCLE' used to present Cycle's capacity of all-chain assets management whose tokenId is 1. Soon we will have more origin tokens issued on Cycle and wrap tokens whose original tokens are already issued on Security Layer/Extend Layers.

Soon, we will provide a query-API listing all the tokens' information including token address and token id.

When a new kind of ERC20 token is rolling-in from the origin layer to Cycle for the first time, the rollin smart contract will automatically deploy a wrapped ERC20 token contract that corresponds to the origin token deployed on the origin layer.

PreviousTransfer within CycleNextHow to roll out tokens

Last updated 10 months ago

âš™ī¸
👉