New answers tagged

0 votes

Sending hundreds of transactions every minute, TXs seem to get randomly stuck in mempool even after setting high gas

First of all, I'm wondering what you are building because it sounds potentially toxic but putting that aside....there is an annoying thing on web3 where if one transaction from an address gets stuck ...
user127148's user avatar
0 votes

Ethers js deploy contract with balance, payable constructor

Here is a snippet if you are using ethers.js v6 const initialBalance = ethers.parseEther("0.1"); const myContract = await ethers.deployContract("MyContract",{value: initialBalance})...
Upsilon's user avatar
0 votes

Create a new Erc20 contract through Ether.js

@Mehran Ra's code doesn't seem to work in my case. Specifically you the provider line didn't work for me. Adjusted the code would look like this: const { ethers } = require('ethers'); const ...
ThinkBonobo's user avatar
0 votes

typeError: Cannot read properties of undefined (reading 'format')

TypeError: Cannot read properties of undefined (reading 'format') the variables are either undefined or not formatted proparly for the function to interpret the arguments. I think the problem either ...
Yann's user avatar
  • 21
1 vote

React (opts:) not working, am i missing dependency?

That version of Web3Modal doesn't work any more and has been deprecated. Try v3 check docs here: https://docs.walletconnect.com/web3modal/react/about?platform=ethers
Glitch's user avatar
  • 11
0 votes

ethers.js version 6: TypeError: wallet.getTransactionCount is not a function

In addition to Ali's answer, wallet in this case is a Signer. From the docs, getNonce: Gets the next nonce required for this Signer to send a transaction.
Code on the Rocks's user avatar
0 votes

CALL_EXCEPTION in estimateGas with local ganache

I was using a newer version of solc and was seeing the same error. To fix: yarn remove solc yarn add [email protected] Recompile contract and deploy
Code on the Rocks's user avatar
0 votes

in cloud window.ehtereumundefined,in local window.ehtereum is object

The RPC provider window.ethereum is injected by the browser using wallet extension or its own implementation. When running as a service outside a browser the object window doesn't exists. To access ...
Ismael's user avatar
  • 31k
1 vote

What is the best way to fetch and store data from ethereum blockchain for migration of contracts?

With 0xweb tool you could dump the contracts storage first. It collects all the contract state variables from the source, so the contract must be validated on a block explorer, or if you develop ...
tenbits's user avatar
  • 1,979
0 votes

Calling Gnosis safe's propose transaction (safeService.proposeTransaction) gives Unprocessable Entity error

Try to set value as as a string. Like this: const data1 = { to: tocks, data: "...
Calypso's user avatar
  • 167
0 votes

Ethers is not decoding the indexed parameters

If you're seeing an error Interface is not constructor, it might be worthwhile to check for any typos or mistakes in the const iface = new ethers.Interface(abi); line of the solution (maybe 9th line). ...
Shinichiro Yamamoto's user avatar
0 votes

ERC-20 token approval fails if amount is close to maximum balance

You seem to assuming the gas cost is always the same, but it isn't. Besides the cost of the transaction execution (which can vary for reasons like changing from/to zero and refunds, but not in your ...
Chan-Ho Suh's user avatar
1 vote

If blockhash changes, did block become uncle?

Uncles were only in Ethereum's early years when it was using Proof of Work. In Ethereum's Proof of Stake, when a block is replaced by another block, the common case would be called an orphan block. ...
eth's user avatar
  • 85k
0 votes

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

Your hardhat.config.js: accounts: [`0x${PRIVATE_KEY}`], plural 'accounts', not singular 'account'
CITD com my's user avatar
0 votes

How to fetch events emitted in a deployment transaction using ethers JS?

Following code will do your work const { ethers } = require("ethers"); const ABI = <Contract ABI> const rpcProvider = new ethers.JsonRpcProvider( <rpc url> ); async function ...
Iresh Madhusankha - DevCresix's user avatar
0 votes

Estimate gas price with ethers.js

Firstly, I'd like to say that the third top answer and second top answer are correct but vague. The top answer also implicitly relies on the use of a Contract and a DefaultProvider which is not ideal ...
xxl's user avatar
  • 1
1 vote

Cannot read properties of null (reading 'constructor') Etherjs error

Just change in the second line to const contract = new ethers.Contract so you'll call class constructor. And no need in await on second line as constructor in synchronous
crystalbit's user avatar
1 vote

Now that eth_decrypt and eth_getEncryptionPublicKey are deprecated, is there a good way to encrypt and decrypt data via a user's private key?

I'm not sure if it's the same way you me but I was using metamask for something like this before, but it's not suggested anymore. Also metamask deprecated its related method. The main reason is that ...
Salih Cemil Cetin's user avatar
0 votes

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Returned error: invalid opcode

You can only test in Goerli or Sepolia. In remix, importing the openzeppelin library requires your compiled version ^0.8.20; while most bsc or other Ethereum compatible chains are not yet compatible ...
EthanOK's user avatar
  • 391
0 votes
Accepted

Uniswap - swap between Sepolia and my own erc-20 token

get provider in ethers v6: const provider = new ethers.JsonRpcProvider(""); get provider in ethers v5: const provider = new ethers.providers.JsonRpcProvider("");
EthanOK's user avatar
  • 391
0 votes

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Returned error: invalid opcode

There may be other issues, but the first thing that pops out to me is an array out-of-bounds issue. If you try to access (read or write) to an index in an array that is larger than the arrays length, ...
natewelch_'s user avatar
  • 11.9k
0 votes

Verify signature result return 0x

The return signature result from signMessage method being 0x typically means that the signing operation failed or was cancelled by the user. If the user cancelled the operation, you might want to ...
Ari Setiawan's user avatar
0 votes

Why I can't get meta data of USDC in ethereum?

The contract address you provided 0xa2327a938febf5fec13bacfb16ae10ecbc4cbdcf is not the official USDC contract (at least until my knowledge cutoff in September 2021), which could be a reason for the ...
Ari Setiawan's user avatar
0 votes

Why I can't get meta data of USDC in ethereum?

Yes calling the implementation contract won't give you the values, because it is there to extend the functionality of the proxy contract, in the context of the proxy contract's storage. All the ...
Peter's user avatar
  • 166
0 votes
Accepted

How to encode param of type address

This is what worked for me. I don't really have some reference from some documentation or anything, but I got to this solution based on some recent working examples of code for similar use cases. ...
stuckoverflow's user avatar
1 vote

How to encode param of type address

These are scripts I tried. (I think it's not ideal to continue the exchange here multiple times, so I'll present this source code and conclude my remarks. I apologize if it doesn't get resolved.) In ...
Shinichiro Yamamoto's user avatar
0 votes

How to encode param of type address

How about remove (address) from 1st parameter ? const selector = contract.interface.encodeFunctionData( "removeRes", // <--- change here. [contractAddress], );
Shinichiro Yamamoto's user avatar
0 votes

How to handle wrong chain error [Infura, Wagmi, React, Typescript]

provider = new ethers.InfuraProvider('sepolia', infuraApiKey); ... //in your React/NextJs: const { chain, chains } = useNetwork();//from Wagmi if (chain.name.toLowerCase() !== expected_blockchain....
Russo's user avatar
  • 1,764
0 votes

How do I obtain a signer object from a named account address in a Hardhat project?

To obtain a signer object from a named account address in a Hardhat project with the hardhat-deploy plugin, you can use the ethers.getSigner method, which is designed to work with the addresses of the ...
MShakeG's user avatar
  • 1,418
0 votes
Accepted

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

I have solved this with Ethers.js 6.8.0 and Infura: network = "sepolia" infuraApiKey = '1234...' provider = new ethers.InfuraProvider(network, infuraApiKey); InfuraProvider() does not ...
Russo's user avatar
  • 1,764
0 votes

Can anyone help me to solve this error (TypeError: contractInstance.isComplete is not a function)?

This is a type error which means that the contractABI you're using doesn't have that function. Apparently, you're using an older ABI. try recompiling the contract and replace the ABI
Farrukh Raza's user avatar
1 vote
Accepted

What is the best way to fetch and store data from ethereum blockchain for migration of contracts?

My approach : What I did for now is, fetch the desired events using ethers js queryFilter, then store those in the form of an array in a JSON file by converting them into Objects. Now I can read the ...
Zartaj Afser's user avatar
  • 2,180
2 votes

Unable to fetch events using Ethers js

My bad. The deployed contract was an old contract, containing only two parameters in the event, but the instance I was creating had three parameters, producing a wrong filter for the event.
Zartaj Afser's user avatar
  • 2,180
1 vote

Unable to fetch events using Ethers js

The contract hasn't emitted that event yet. The only functions called so far is the createChannel. Try calling updateChannelMeta which emits the UpdateChannel event.
Farrukh Raza's user avatar

Top 50 recent answers are included