4 votes

Faced a problem whiling getting Ethereum transactions which are in mempool

You can get the pending transactions using Chainstack's WSS Node. In your code, you first need to declare a provider // Connecting to the Chainstack's WSS Node const provider = new ethers.providers....
2 votes
Accepted

Unexpected object returned from basic solidity contract (hardhat, ethers)

When you call a non view/pure function, ethers creates and signs a transaction. Ethers then returns the transaction data and not the value returned by your solidity function (the value is actually ...
2 votes
Accepted

My transaction is 2 blocks earlier than the competitor, but mine is failed and his successful. Why?

The transaction reverts with the following error 0x6f7eac26 From the 4bytes.directory that value corresponds to InvalidTime(). It is likely the offer wasn't within the time allowed.
  • 30.1k
2 votes
Accepted

How to change (or prompt to change) a user's current metamask network programmatically?

This is the code that you need to prompt a switch from the current selected network to Mumbai, using the window.ethereum global API injected directly by MetaMask. // Prompt the user to switch to the ...
  • 566
2 votes
Accepted

Is it possible to set a mapping using ethers.js

When you defined the claimTransactions mapping, solidity automatically created a getter method for it, which you accessed by doing claimTransactions(string). However, solidity does not automatically ...
  • 183
1 vote
Accepted

How do I change the address deploying smart contracts with ethers and hardhat local network?

First, specify the private key of the account you want to use and then connect to the contract to deploy it with such wallet. const main = async () => { const signer = new ethers.Wallet(...
  • 183
1 vote

How to decode and update input data of a specific transaction?

no it's not possible. a transaction is an immutable record of something that has happened. It doesn't make sense to be able to change it as it would mean there could be no certainty on the blockchain. ...
  • 903
1 vote

Is possible to call a non-payable function of smart contract and send Ether to contract at same time?

You can create a new smart contract and pass the smart contract address that you want to send ether as an owner contract inside the newly deployed contract. You can call self.destruct on your new ...
  • 1,134
1 vote

I am unable to deploy a smart contract(Simple Storage) to hardhat programmatically

Add the following code snippet at the top of your hardhat.config.js file require("@nomiclabs/hardhat-waffle"); solution from here: https://stackoverflow.com/questions/70628980/typeerror-...
  • 606
1 vote

I am unable to deploy a smart contract(Simple Storage) to hardhat programmatically

On the last line, I see two "await" which is not correct I think. I would create deploy script like this: const hre = require("hardhat"); async function main() { const ...
1 vote

I am unable to deploy a smart contract(Simple Storage) to hardhat programmatically

It's complaining that ethers is not defined, check your package.json to see if you correct installed hardhat-ethers plugin. https://github.com/NomicFoundation/hardhat/tree/master/packages/hardhat-...
1 vote

Signing Messages Ethers.js

The private key is hardcoded so it does not need metamask's approval even if you connect your wallet.
1 vote

Invalid transaction key: price - Swap Transaction fails using ethers.js on Ropsten

Going off of 0x_jess's answer as it led me to my version of a solution. So the issue definitely is that web3.js is more permissive with extraneous fields where as ethers is not. In fact if you have ...
1 vote

How to get contract's ether balance at hardhat / waffle

You can obtain the ETH balance of your Contract directly using the following code snippet: import {ethers} from "hardhat" const contractBalance = await ethers.provider.getBalance("...
1 vote

generation of my private key

If the random 256-bit number is really random and it was generated in a secure way, the chances of someone else guessing it is so low that we could say it's impossible in our life span. Something to ...
  • 2,982
1 vote

how to send ether in hardhat instead of msg.value in remix

In order to send funds to the function being tested you shoul use something like this: contractInstance.testFunction(<any function args>, { value: ethers.utils.parseUnits("1", &...
1 vote

How to connect and call a function with a different account using hardhat-deploy?

You can try adding this line of code after your contract is deployed: const contract = await ethers.getContract("ContractName") now when you use contract.connect() it should work
1 vote
Accepted

How to connect ethereum node through proxy agent using ethers.js?

The answer will dissapoint you. Cause there is still no method or option to add custom http agent through the ether.js. There had been a PR and the developer said he might add it in ethersV5 but ...
  • 680
1 vote
Accepted

How to make a mixed-type struct from function args?

you don't have to encode it. you can build the input like this: let myStruct = { _address: accounts[2].address, _num: web3.utils.toWei("1") } Then just call your function with ...
  • 3,590
1 vote
Accepted

MetaMask - RPC Error: execution reverted, Simple NFT Miniting Dapp

You want to check if the contract address you are deploying to the testnet is correct. If it is, check if the method you're calling is correct. Finally, check if the parameters in the function call ...
1 vote
Accepted

Ethers JS BigNumber Errors

If you are using ethers.js, there is a constants module you can use directly: here const maxNumber = ethers.constants.MaxUint256
1 vote

Hardhat network resetting repeatedly

that's a pretty normal state of affairs. the hardhat network only lasts as long as your script is running and you start afresh each run. That's generally not a bad thing for unit tests and suchlike. ...
  • 903
1 vote

Listen for all the events of a smart contract with ethers.js polygon

You can use couple of methods in ether.js to achieve the result. I wrote a sample code to listen to the events from a particular contract by listening to the block mining event. const { ethers } = ...
  • 680
1 vote
Accepted

Listen for all the events of a smart contract with ethers.js polygon

Hi developer advocate at Chainstack here! Web3.js has a subscriprion method to easily to that! const Web3 = require("web3"); const node_url = "CHAINSTACK_WSS_URL"; const web3 = ...
  • 566
1 vote
Accepted

Is there a way to extract functions from an ABI and show it in the front end?

I created a simple and quick implementation with plain JS and HTML so you can see how something like that can be done. Check (replace <yourInfuraRinkebyKey> with your own infura api key): <!...
  • 2,982
1 vote

Is there a way to extract functions from an ABI and show it in the front end?

The ABI is basically a list of objects. You can iterate over this list to get the individual objects and process them. You can easily parse the function name and the input types from them. Then use ...
  • 1,179
1 vote

How to trace a Internal Ether Send

When looking at opcodes you go to the stack to see the input. evm.codes is a good resource. So in the example you posted we see the CALL opcode. CALL has 7 inputs which get popped off the stack in ...
1 vote

Call contract artifacts with same names from different path in hardhat

It's possible by specifying the full path: const GmxReaderFactory = await ethers.getContractFactory("src/gmx/Reader.sol:Reader"); const PerpReaderFactory = await ethers.getContractFactory(&...
  • 1,027
1 vote

My transaction had a higher gas price but failed. Why?

Your transaction failed because although you were in the same block and the max gas you picked was higher, his Max Priority was 167.4 gwei while yours was 163 gwei. This means he tipped the miner 3.4 ...
  • 183
1 vote

How to access solidity function variables inside a transaction

What is the Breed type? A struct? A contract? When I decode "0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266&...
  • 2,982

Only top scored, non community-wiki answers of a minimum length are eligible