Messina SDK
  • Introduction
    • Introduction
  • SETTING UP
    • Installation
  • Contracts
    • Contracts
  • METHODS
    • Algorand
      • transferFromAlgorand()
      • getEmitterAddressAlgorand()
      • parseSequenceFromLogAlgorand()
      • redeemOnAlgorand()
    • EVM
      • getAllowanceEth()
      • approveEth()
      • transferFromEth()
      • getEmitterAddressEth()
      • parseSequenceFromLogEth()
      • redeemOnEth()
      • redeemOnEthWithType()
    • Guardian
      • getSignedVAA()
    • Utils
      • nativeToHexString()
  • Bridging
    • Algorand -> Ethereum
    • Ethereum -> Algorand
  • Contact
    • Email
    • Discord
    • Telegram
    • Twitter
Powered by GitBook
On this page
  • Method Parameters
  • Returns
  • Usage
  1. METHODS
  2. EVM

parseSequenceFromLogEth()

Parses EVM transaction to get the sequence number

Method Parameters

receipt: ContractReceipt

ethers js ContractReceipt

bridgeAddress: string

Ethereum core contract address

Returns

Returns sequence number as string

Usage

import { ethers } from "ethers";
import algosdk, { Account, Algodv2 } from "algosdk";
import { approveEth, transferFromEth, CHAIN_ID_ALGORAND, getEmitterAddressEth, parseSequenceFromLogEth } from "@algo-foundry/messina-sdk";

const client: algosdk.Algodv2 = new Algodv2(<ALGO_TOKEN>, <ALGO_ADDRESS>, <ALGOD_PORT>);
const wallet: Account = algosdk.mnemonicToSecretKey(<ALGO_MNEMONIC>)

const provider = new ethers.providers.WebSocketProvider(<ETH_NODE_URL>) as any;   
const signer = new ethers.Wallet(<ETH_PRIVATE_KEY>, provider);

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

if(allowance.lt(AMOUNT_TO_TRANSFER)){
  await approveEth(
    "0xf72a04B891bA46819D83c75687d31f22f6d646c1",
    "0xbF0482884043B7ea1eB55516770C217C77CC7A48",
    signer,
    AMOUNT_TO_TRANSFER
  );
}

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

const emitterAddr = getEmitterAddressEth("0xf72a04B891bA46819D83c75687d31f22f6d646c1");
const sequence: string = parseSequenceFromLogEth(receipt, "0xE4DF23D087ef706a536527a41bef769a43656C91");
PreviousgetEmitterAddressEth()NextredeemOnEth()

Last updated 6 months ago