Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code after initializing ethers interface isn't executing #4676

Open
Dnguye92 opened this issue Apr 1, 2024 · 0 comments
Open

Code after initializing ethers interface isn't executing #4676

Dnguye92 opened this issue Apr 1, 2024 · 0 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@Dnguye92
Copy link

Dnguye92 commented Apr 1, 2024

Ethers Version

6.11.1

Search Terms

No response

Describe the Problem

I'm using this doc (https://docs.alchemy.com/docs/how-to-get-erc-20-token-balance-at-a-given-block#step-5-get-usdt-balance-at-a-particular-block) to pull block specific balances with Alchemy and Ethers v6.x. The doc is referencing what looks to be Ethers v5.x but I was able to find the v6.x equivalent. The problem I'm facing is that none of the code after creating an ethers interface is being executed. I've confirmed that all of my Alchemy related code is working as expected and that the issue lies with ethers or my use of ethers. I'm also not seeing any errors reported in the console.

Code Snippet

const getBalance = async (walletAddress) => {
  ...
  console.log("CREATING INTERFACE");
  // Create function call data -- eth_call
  let iface = new ethers.Interface([
    "function balanceOf(address) view returns (uint)"
  ]);
  // code below this comment never gets executed
  console.log("IFACE", iface);

  let data = iface.encodeFunctionData("balanceOf", [walletAddress]);
  console.log("DATA", data);

  // Get balance at a particular block -- usage of eth_call
  let balancedData = await alchemy.core.call({
    to: USDC_CONTRACT_ADDRESS,
    data: data,
  }, blockTag);

  console.log("BALANCE", balancedData)
  balancedData = (parseInt(balancedData) / 10 ** FIXED_DECIMAL_PLACE).toFixed(2);
  console.log("Balance:", balancedData, "USDT");
}

Contract ABI

["function balanceOf(address) view returns (uint)"]

Errors

N/A

Environment

Ethereum (mainnet/ropsten/rinkeby/goerli), node.js (v12 or newer)

Environment (Other)

No response

@Dnguye92 Dnguye92 added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Apr 1, 2024
@Dnguye92 Dnguye92 changed the title Add Bug Title Here Code after initializing ethers interface isn't executing Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants