Skip to main content
Share Your Experience: Take the 2024 Developer Survey

New answers tagged

0 votes

TypeError: Cannot read properties of undefined (reading 'getSigner')

It should be accessed using the ethers library of hardhat runtime environment (hre) like: const hre = require("hardhat"); async function main() { const signer = await hre.ethers....
SYED ASAD KAZMI's user avatar
0 votes

Hardhat, problem with uninstalled dependencies

As the error is self-explanatory, there are some required packages to work with hardhat ignition. Run npm install --save-dev "@nomicfoundation/hardhat-ignition@^0.15.4" "@...
Zartaj Afser's user avatar
  • 4,221
0 votes

invalid mnemonic checksum in ethers v6

The problem is that this version of ethers.js doesn't handle trailing '\n' as spaces or blanks and instead handled those as data.
sw.'s user avatar
  • 171
0 votes

How do I wait for confirmation in metamask/ethers before proceeding

You can use an websocket to verify: const websocket = new ethers.WebSocketProvider("YOUR_WSS_URL") websocket.on("block", () => { const receipt = ethers.getTransactionReceipt(...
Rodrigo Burgos's user avatar
0 votes

Error: Timeout of 2400000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves

Eventually, it works I don't why but it works. It's only necessary changing the last test. As well as, I don't know how I solve most of the errors and why there's two catch and why the second is ...
Tucan's user avatar
  • 3
1 vote

Ethers v6 TypeError: overflow

Fixed by using the method formatEther. const sanitizeAmount = (value: string): number => { return Number(ethers.formatEther(value)); };
stuckoverflow's user avatar
1 vote

How can I listen emitted events from BSC network

You can try Bitquery Events API to listen to emitted events on BSC Network. You can try the websocket here in Bitquery API Playground - https://ide.bitquery.io/Listen-to-emitted-events-on-BSC-...
Akshat Meena's user avatar
0 votes

web3.js or ethers.js, what should I learn in 2023?

Ethers in my humble opion. Easer to learn, ease to be read by a human, intuitive methods in it's classes and also has mirror in rust.
Rodrigo Burgos's user avatar
0 votes

JsonRpcProvider not Found in ethers.js

Make sure your local Ethereum node (like Geth or Ganache) is running and listening on port 7545 as you are specifying the URL of your local Ethereum node in your program as "http://127.0.0.1:...
Harigovind M G 's user avatar
0 votes

JsonRpcProvider not Found in ethers.js

Since you’re using ethers.js v6 (6.12.1), you’ve to access it like: const provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545"); P.S., The way you’re currently doing is applicable ...
SYED ASAD KAZMI's user avatar
0 votes

Infura Ethers.js jsonrpcprovider failed to detect network and cannot start up

Hi,bro,i adapt your reply,but I got a new Error,could u tell me how to solve this
secret sun's user avatar
0 votes

How to parse SIWE on chain?

SIWE is EIP-191 message. EIP-191 is not meant for on-chain parsing, because I am pretty sure the actual message does not get delivered on-chain, only message hash, but I could be wrong here.
Mikko Ohtamaa's user avatar
0 votes

Hardhat Ethers get Contract Deployed on a Specific Chain

While running your script, you can pass the network flag at the end of the command, like: npx hardhat run scripts/yourScriptFileName.js —-network desiredNetworkName You can pass the network name like ...
SYED ASAD KAZMI's user avatar
0 votes

How get network ID with ethers.js?

Ethers v6 update: As stated by some answers above you can use const chainId = await provider.getNetwork()console.log(chainId) , But this has changed as of ethers v6. In v5, it returned a number but, ...
Web3Phoenix's user avatar
0 votes

How to add a NFT to metamask wallet with a RPC method

A bit late, but watch asset now supports both ERC721 (NFTs) and ERC1155. Here's the link: https://docs.metamask.io/wallet/reference/wallet_watchasset/ In params, just specify the type and tokenId: { ...
Aleksa Milosevic's user avatar
0 votes

GetBalance faster method and tokens/nft balance

While using ethers.js or web3.js library and calling the getBalance() function, the speed depends on various factors such as network conditions, response time of WSS RPC url of the node, etc. I would ...
SYED ASAD KAZMI's user avatar
0 votes

TypeError: Cannot read properties of undefined (reading 'FormatTypes')

I believe this is the FreeCodeCamp tutorial. Well as of ethers v6 the utils class has been removed. So to convert and return the contract interface in JSON format, you use the formatJson() method of ...
Web3Phoenix's user avatar
0 votes

Getting transaction history via Ethers.js

Personally, I hit a very similar obstacle to obtain transaction data associated with an address. Here is a very great explanation on the topic of state tries and its cost effectiveness: Read ...
Pavel Fedotov's user avatar
0 votes

Set RPS with ethers.js

To limit the requests per second (RPS) to 25, you can implement a throttling mechanism in your code. Here's the revised code: const ethers = require("ethers"); const InputDataDecoder = ...
SYED ASAD KAZMI's user avatar
0 votes

How to get ABI of deployed contract using ethersjs in hardhat?

You can use the built-in method readArtifact const hre = require('hardhat') or import * as hre from 'hardhat'; const myContractArtifact = await hre.artifacts.readArtifact('MyContract'); const {...
Nick's user avatar
  • 1
0 votes

Delegatecall failing 'could not coalesce error'

You don't have to pass calldata in the argument while encoding the function signature of setmessage. Just remove calldata, it would work fine: (bool success, bytes memory data) = _original....
SYED ASAD KAZMI's user avatar
0 votes

Error: contract runner does not support sending transactions (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=6.6.3)

Dont forget to connect when you calling the contract Not const testFactory = await uniswapV2Factory.feeTo() But const testFactory = await uniswapV2Factory.connect(owner).feeTo()
blockson's user avatar
2 votes

how can we control the logic behind ethersJs fallbackProvider's choices

Dev Advocate at Chainstack here. I made a tutorial about using the FallbackProvider. You can find it here: Ethers.js: Enhancing blockchain data reliability with FallbackProvider The TL;DR is that the ...
Dave Dev Advocate Chainstack's user avatar
0 votes
Accepted

provider.getBalance() always returns "0"

As, @Awais Ahmad has mentioned in his answer that getBalance() function retrieves the Ether balance (i.e., BNB balance in case on Binance Network) of an address, not the balance of any BEP-20 token ...
SYED ASAD KAZMI's user avatar
0 votes

provider.getBalance() always returns "0"

Hello @Christopherus, It seems like you're trying to retrieve the balance of an address holding the BUSD token on the Binance Smart Chain (BSC) using the getBalance() function, but you're encountering ...
Awais Ahmad's user avatar
0 votes

Is it possible to validate the Metamask personal_sign in the back end?

This is an example in javascript and nodejs to solve this. // Client javascript const message = "My Message"; const address = '0x2e1fe3c3bf4c576d34c4048e5e7a8055b92a2e21'; const message_hex =...
Enzo's user avatar
  • 177
0 votes

Is it possible to validate the Metamask personal_sign in the back end?

I've implemented this. What you can do is, in an API send user address to the backend and get a signature message from backend. Something like "Sign this message: <any random string>" ...
Vinay Kharayat's user avatar
2 votes
Accepted

Getting execution reverted: ERC20: transfer amount exceeds allowance code: UNPREDICTABLE_GAS_LIMIT method

You're facing this error because you haven't approved the Swap contract to spend the amount of tokens (particularly token0 i.e., USDC in your case) that you're swapping. You can check that by ...
SYED ASAD KAZMI's user avatar
0 votes

Any way to learn about transaction events/logs before the transaction/block is mined?

Im not completely sure if this is the right answer but transaction.wait() would wait until the transaction was mined then send you the reciept. Whatever you are trying to do, you need to do it without ...
TiltedGamer's user avatar
0 votes

How to keep wallet connection persistent when refreshing with Ethersjs

I noticed that when I use the useEffect hook inside the connectWallet(), the connectWallet function will be called on initial page load because of the empty dependency array [] without the user ...
Web3Phoenix's user avatar
0 votes

Getting 'too many arguments' error when calling a contract function through a forwarder contract using Openzeppelin's defender in Ethereum

You're passing too many arguments to your smart contract function through the Defender relayer. The error indicates the function expects only one argument. Solutions: Check Contract: Verify the add ...
Awais Ahmad's user avatar
0 votes

How to listen to contract events using ethers.js?

In addition to using Ethers.js, you can use Bitquery streams. This makes programming easier, and data parsing is already done on Bitquery's end. Here is an example of a PairCreated Event on the ...
Gaurav Agrawal's user avatar
0 votes

transaction reverted when calling swapExactETHForToken on uniswapRouter02

i looked at the transaction failed in baseScan , and notice it was failing cus it was running out of gas https://basescan.org/tx/0xa3d18b809fb3221de12de77d74027597e2de7822965b681ad50bb6d2be8ab6e6 so ...
yahdielo's user avatar
0 votes

Not getting every transaction and unable to parse data

You can try Bitquery's streams to check BSC mempool data. Here is an example of a pancake address. https://ide.bitquery.io/Pancake-Mempool-calls-events-and-transfers However, to check Pancake's ...
Gaurav Agrawal's user avatar
0 votes

Deploy contract on Hyperledger Besu zero fees network

i think the reason you get an error if you use await contractDeployed.waitForDeployment(); is because the contract isn't actually being deployed you're getting BAD_DATA 'cause no contract actually ...
smatthewenglish's user avatar

Top 50 recent answers are included