Ethereum -> Algorand

Example bridging from Ethereum to Algorand

Code Flow

Steps

  1. getAllowanceEth()

  2. approveEth()

  3. transferFromEth()

  4. getEmitterAddressEth()

  5. parseSequenceFromLogEth()

  6. getSignedVAA()

  7. redeemOnAlgorand()

1. getAllowanceEth()

const allowance: ethers.BigNumber = await getAllowanceEth("0xf72a04B891bA46819D83c75687d31f22f6d646c1","0xbF0482884043B7ea1eB55516770C217C77CC7A48",signer);

2. approveEth()

await approveEth(
      "0xf72a04B891bA46819D83c75687d31f22f6d646c1",
      "0xbF0482884043B7ea1eB55516770C217C77CC7A48",
      signer, // Wallet from ethers js
      AMOUNT_TO_TRANSFER
    );

3. transferFromEth()

const receipt: ethers.ContractReceipt = await transferFromEth(
      "0xf72a04B891bA46819D83c75687d31f22f6d646c1",
      signer, // Wallet from ethers js
      ethAsset,
      BigInt(1000000), // AMOUNT_TO_TRANSFER * (10 ^ ASSET_DECIMALS)
      CHAIN_ID_ALGORAND,
      algosdk.decodeAddress(wallet.addr).publicKey
  );

4. getEmitterAddressEth()

const emitterAddr = getEmitterAddressEth("0xf72a04B891bA46819D83c75687d31f22f6d646c1");

5. parseSequenceFromLogEth()

const sequence: string = parseSequenceFromLogEth(receipt, "0xE4DF23D087ef706a536527a41bef769a43656C91");

6. getSignedVAA()

const signedVAA = await getSignedVAA(GUARDIAN_GRPC, emitterAddr, 'CHAIN_ID_ETHEREUM', sequence, 1000, 20)

7. redeemOnAlgorand()

const redeemTxs = await redeemOnAlgorand(
      client, // Algodv2 from algosdk
      BigInt(114976173),
      BigInt(114976156),
      vaaBytes, // parsed signed vaa
      SENDER_ADDRESS
    );

Last updated