AI Network
  • What is AI Network
  • AIN Blockchain
    • Architecture
      • Design Principles
      • Event-driven Architectures
      • Blockchain Database
        • States
          • State Types
          • Operations
          • Predefined Structures
        • Rules and Owners
          • Rule Configs
          • Owner Configs
        • Functions
          • Built-in Functions
      • Instant Execution, and Eventual Consistency
      • Network ID and Chain ID
      • Transactions
        • Structure
        • Nonce
        • Read Concern
        • Propagation
      • Block Structure
      • Account and Keys
      • Consensus
      • Scalability
      • Apps
    • Developer Guide
      • Quick Start
      • AI Network Products
        • AI Network Worker
        • AI Network Insight
        • Testnet Server Node
        • Ainize Trigger
          • Project user
          • Project deployer
          • Why do we have to use Ainize Trigger?
      • Token Bridge
      • Trouble Shooting
    • Developer Reference
      • Blockchain API
        • JSON RPC API
        • Node Client API
      • Blockchain SDK
        • ain-js
        • ain-py
      • Validators
    • Staking
  • AIN DAO
    • What is AIN DAO
      • Runo (Run Your Node)
      • GPU Sponsorship Program
    • Onboarding & Participation
    • Governance
    • Tokenomics
      • AI Network Tokenomics
      • AINFT Tokenomics
  • AI Agents
    • AINFT
    • AINFT Factory
    • AINFT Projects
      • 🍳MiniEggs
      • 🦈Baby Shark
      • 🛸Soul Fiction
      • 🎻NFT Classics Society
    • Developer Reference
      • Ainft-Js
      • AINFT tutorial
        • Create AINFT object and Mint
        • Transfer AINFT
        • Set metadata of AINFT
        • Search and Retrieve AINFT
  • AIN Wallet
    • What is AIN Wallet?
    • AIN Wallet API
  • PROPOSAL DOCUMENTS
    • AIN Improvement Memos (AIMs)
    • AIN Improvement Proposals (AIPs)
Powered by GitBook
On this page
  • Check-in
  • 1. Send your AIN ERC20 tokens to the AI Network ERC20 Token Pool address.
  • 2. Send a check-in request transaction to the AI Network blockchain.
  • 3. Check that your AI Network account's balance has increased on Insight.
  • Check-out
  • 1. Send a check-out request transaction to the AI Network blockchain.
  • 2. Check that your transaction was successfully added to the blockchain on Insight.
  • 3. Check that your Ethereum wallet has received AIN ERC20 tokens.

Was this helpful?

  1. AIN Blockchain
  2. Developer Guide

Token Bridge

AI Network operates a token bridge between AIN native coins and AIN ERC20 tokens on Ethereum. Disclaimer: Check-in and check-out requests may take a few days to be processed.

PreviousWhy do we have to use Ainize Trigger?NextTrouble Shooting

Last updated 3 years ago

Was this helpful?

Note: This guide assumes that you have an Ethereum wallet with some AIN ERC20 tokens in it. You can buy AIN ERC20 tokens on Uniswap, Balancer, or GOPAX.

AIN ERC20 Token Addresses

  • Mainnet:

  • Testnet (ropsten):

AIN Native Token Pool Addresses

  • Mainnet

    • Ethereum:

    • AI Network:

  • Testnet

    • Ethereum:

    • AI Network:

Check-in

Here, a check-in refers to a transfer of your AIN ERC20 tokens on Ethereum to AI Network as AIN native coins.

1. Send your AIN ERC20 tokens to the AI Network ERC20 Token Pool address.

1-1. Using a MetaMask, Add AIN ERC20 Token to your list of tokens.

1-2. Send AIN ERC20 to AI Network ERC20 Token Pool.

AI Network ERC20 Token Pool address

There is no minimum/maximum amount you need to check-in.

1-3. Make sure the transaction is successfully executed.

You can view your transaction on Etherscan by clicking the transaction on MetaMask and then "View on block explorer".

2. Send a check-in request transaction to the AI Network blockchain.

check-in-mainnet.js
/* This code snippet is for Mainnet! */
const stringify = require('fast-json-stable-stringify');
const Accounts = require('web3-eth-accounts');
const Ain = require('@ainblockchain/ain-js').default;
const ain = new Ain('https://mainnet-api.ainetwork.ai', 1); // chainId = 1 (mainnet)
const ethAccounts = new Accounts();
const ainErc20TokenAddress = '0x3A810ff7211b40c4fA76205a14efe161615d0385';
​
// Create 1 new account
const accounts = ain.wallet.create(1);
// WARNING: Make sure to record this private key somewhere safe! We cannot retrieve it for you!
console.log(JSON.stringify(ain.wallet.accounts, null, 2));
const myAddress = accounts[0];
ain.wallet.setDefaultAccount(myAddress);
// Or, import an account you already have
// const myAddress = ain.wallet.addAndSetDefaultAccount(YOUR_PRIVATE_KEY);

// Create a sender proof with your Ethereum key (sender)
const timestamp = Date.now();
const ref = `/checkin/requests/ETH/1/${ainErc20TokenAddress}/${myAddress}/${timestamp}`;
// Should be exactly the same as the AIN ERC20 token you sent in Step 1-2.
const amount = 20000;
// Sender is the Ethereum address that you used to send AIN ERC20 token in Step 1-2.
const sender = 'YOUR-ETHEREUM-ADDRESS';
const senderPrivateKey = 'YOUR-ETHEREUM-PRIVATE-KEY';
const senderProofBody = {
  ref,
  amount,
  sender,
  timestamp,
  nonce: -1,
};
const senderProof = ethAccounts.sign(ethAccounts.hashMessage(stringify(senderProofBody)), senderPrivateKey).signature;

// Send a check-in request
ain.db.ref(ref)
  .setValue({
    value: {
      amount,
      sender: myAddress,
      sender_proof: senderProof,
    },
    nonce: -1,
    gas_price: 500,
    timestamp: timestamp // Should be the same as the checkinId in ref
  })
  .then((res) => {
    console.log(JSON.stringify(res, null, 2));
  });
check-in-testnet.js
/* This code snippet is for Testnet! */
const stringify = require('fast-json-stable-stringify');
const Accounts = require('web3-eth-accounts');
const Ain = require('@ainblockchain/ain-js').default;
const ain = new Ain('https://testnet-api.ainetwork.ai', 0); // chainId = 0 (testnet)
const ethAccounts = new Accounts();
const ainErc20TokenAddress = '0xB16c0C80a81f73204d454426fC413CAe455525A7';
​
// Create 1 new account
const accounts = ain.wallet.create(1);
// WARNING: Make sure to record this private key somewhere safe! We cannot retrieve it for you!
console.log(JSON.stringify(ain.wallet.accounts, null, 2));
const myAddress = accounts[0];
ain.wallet.setDefaultAccount(myAddress);
// Or, import an account you already have
// const myAddress = ain.wallet.addAndSetDefaultAccount(YOUR_PRIVATE_KEY);

// Create a sender proof with your Ethereum key (sender)
const timestamp = Date.now();
const ref = `/checkin/requests/ETH/3/${ainErc20TokenAddress}/${myAddress}/${timestamp}`;
// Should be exactly the same as the AIN ERC20 token you sent in Step 1-2.
const amount = 20000;
// Sender is the Ethereum address that you used to send AIN ERC20 token in Step 1-2.
const sender = 'YOUR-ETHEREUM-ADDRESS';
const senderPrivateKey = 'YOUR-ETHEREUM-PRIVATE-KEY';
const senderProofBody = {
  ref,
  amount,
  sender,
  timestamp,
  nonce: -1,
};
const senderProof = ethAccounts.sign(ethAccounts.hashMessage(stringify(senderProofBody)), senderPrivateKey).signature;

// Send a check-in request
ain.db.ref(ref)
  .setValue({
    value: {
      amount,
      sender,
      sender_proof: senderProof,
    },
    nonce: -1,
    gas_price: 500,
    timestamp: timestamp // Should be the same as the checkinId in ref
  })
  .then((res) => {
    console.log(JSON.stringify(res, null, 2));
  });

3. Check that your AI Network account's balance has increased on Insight.

You can check your AI Network account's balance at the AI Network blockchain explorer.

  • Mainnet: https://insight.ainetwork.ai/accounts/${YOUR-AIN-ADDRESS}

  • Testnet: https://testnet-insight.ainetwork.ai/accounts/${YOUR-AIN-ADDRESS}

Check-out

Similarly, a check-out refers to a transfer of your AIN native coins on AI Network to Ethereum as AIN ERC20 tokens.

1. Send a check-out request transaction to the AI Network blockchain.

For check-out's, there is a minimum and a maximum allowed per request as well as a maximum per day for the entire network. Currently the limits are:

  • Minimum check-out amount per request: 10,000 AIN

  • Maximum check-out amount per request: 100,000 AIN

  • Maximum check-out amount per day for the network: 1,000,000 AIN

/* This code snippet is for Mainnet! */
const Ain = require('@ainblockchain/ain-js').default;
const ain = new Ain('https://testnet-api.ainetwork.ai', 1); // chainId = 1 (mainnet)
const ainErc20TokenAddress = '0x3A810ff7211b40c4fA76205a14efe161615d0385';
​
// Import an account you created in the check-in process
const myAddress = ain.wallet.addAndSetDefaultAccount(YOUR_PRIVATE_KEY);

// Send a check-in request
const timestamp = Date.now();
const ref = `/checkout/requests/ETH/1/${ainErc20TokenAddress}/${myAddress}/${timestamp}`;
const amount = 10000;
// This is the Ethereum address that will receive the AIN ERC20 tokens
const recipient = 'YOUR-ETHEREUM-ADDRESS';
ain.db.ref(ref)
  .setValue({
    value: {
      amount,
      recipient,
      fee_rate: 0.001
    },
    nonce: -1,
    gas_price: 500,
    timestamp: timestamp // Should be the same as the checkoutId in ref
  })
  .then((res) => {
    console.log(JSON.stringify(res, null, 2));
  });
/* This code snippet is for Testnet! */
const Ain = require('@ainblockchain/ain-js').default;
const ain = new Ain('https://testnet-api.ainetwork.ai', 0); // chainId = 0 (testnet)
const ainErc20TokenAddress = '0xB16c0C80a81f73204d454426fC413CAe455525A7';
​
// Import an account you created in the check-in process
const myAddress = ain.wallet.addAndSetDefaultAccount(YOUR_PRIVATE_KEY);
​
// Send a check-in request
const timestamp = Date.now();
const ref = `/checkout/requests/ETH/3/${ainErc20TokenAddress}/${myAddress}/${timestamp}`;
const amount = 10000;
// This is the Ethereum address that will receive the AIN ERC20 tokens
const recipient = 'YOUR-ETHEREUM-ADDRESS';
ain.db.ref(ref)
  .setValue({
    value: {
      amount,
      recipient,
      fee_rate: 0.001
    },
    nonce: -1,
    gas_price: 500,
    timestamp: timestamp, // Should be the same as the checkoutId in ref
  })
  .then((res) => {
    console.log(JSON.stringify(res, null, 2));
  });

2. Check that your transaction was successfully added to the blockchain on Insight.

You can view your transaction at:

  • Mainnet: https://insight.ainetwork.ai/transactions/${txHash}

  • Testnet: https://testnet-insight.ainetwork.ai/transactions/${txHash}

3. Check that your Ethereum wallet has received AIN ERC20 tokens.

You can confirm your increased AIN ERC20 token balance on either MetaMask or Etherscan.

  • Mainnet: https://etherscan.io/address/${ethereumAddress}

  • Testnet: https://ropsten.etherscan.io/address/${ethereumAddress}

Mainnet:

Testnet:

Make sure you are on the right network (Ethereum Mainnet vs Ropsten Test Network) before sending your assets.

⚠️
0x3A810ff7211b40c4fA76205a14efe161615d0385
0xB16c0C80a81f73204d454426fC413CAe455525A7
0x00CC50B6DC70cC854B1231272FDe0b0CFE561d72
0x00CC0491CdA2dA91385C9c424852Ae096B7AbD89
0x00AA9daA2aC950fF445B435Af7F6c39C5c65D677
0x00AA7d797FB091AF6dD57ec71Abac8D2066BE298
0x00CC50B6DC70cC854B1231272FDe0b0CFE561d72
0x00AA9daA2aC950fF445B435Af7F6c39C5c65D677
1. Click import tokens
2. Enter the AIN ERC20 address
3. Click Import Tokens
1.Click send
2. Enter the AI Network ERC20 Token Pool address
3. Confirm
Click View on block explorer to see your transaction on Etherscan.