Questions tagged [ethers.js]

Ethers.js is a JavaScript framework to interact with EVM smart contracts.

More information on ethers.io.

801 questions
4
votes
2 answers

Get ETH Balance with Ethersjs

I'm trying to get the balance of my wallet address to render on my frontend. Here's what I have so far. const [balance, setBalance] = useState(""); const handleWalletBalance = async () => { const { ethereum } = window; …
solidityguy
  • 199
  • 1
  • 3
  • 8
4
votes
1 answer

How to cancel a payment that awaits confirmation in Metamask using web3?

I'm working on a crypto payment system using ethers Web3Provider web3.eth.sendTransaction(transactionObject) After the user calls this method, this dialog is shown: In the app the user is able to close the payment dialog leaving this pending. Is…
Edaurd B
  • 173
  • 1
  • 9
4
votes
0 answers

Encode calldata for function with uint8 argument in ethers.js

I'm trying to encode calldata using ethers.js for the following function: function myFunction(uint8,uint8,uint256,uint256,uint256) My code sample: let iface = new ethers.utils.Interface([ "function…
4
votes
2 answers

Why the timestamp of block get from ethers.js not equals to display in etherscan.io?

import {providers} from "ethers"; const provider = new providers.InfuraProvider("homestead") async function main() { provider.on("block", (blockNum)=> { console.log(blockNum+ ": " +new Date(Date.now())) }) } main() From code…
cruelcage
  • 2,044
  • 6
  • 19
  • 19
4
votes
2 answers

Etherjs "window" object not accessible in Next.js

I have a relatively basic project using solidity and react working as a single page dApp using Create React App. However I am trying to move this now to Nextjs and have hit a hurdle which I assume is something to do with the server side stuff…
Zeb
  • 547
  • 4
  • 15
4
votes
2 answers

Sign and verifiy message on ethereum using wallet connect not working

I am trying to sign and verify messages using wallet connect for my DAPP. So far I have tried using ethers and web3 to wrap WalletConnect and on my mobile device I'm using the metamask and trust wallet apps. So far none of the approaches is…
EDeveloper
  • 71
  • 1
  • 1
  • 3
3
votes
3 answers

Calculate ERC20 token buy/sell tax

I am trying to implement a method for calculating token buy/sell tax. The one that devs implement it in the transfer() function. I've done some research and there are 2 options. eth_call - simulate a swap, calculate the difference deploy the ERC20…
kakakakakakakk
  • 467
  • 10
  • 31
3
votes
1 answer

how to get an array inside of struct using ABI

I am Not able to get weeklyBusiness array inside User struct. as the contract is already deployed is there a way i can change ABI to get all components of User struct including arrays using userInfo function. struct WeeklyBusiness { uint256…
Suvi Negi
  • 31
  • 1
3
votes
0 answers

Calculating a keccak hash from a file stored on Arweave

I am attempting to calculate a hash from an image file which is stored as .png on Arweave. The method I am using is shown below, but I'm not sure I'm actually using the methods of the Node fetch function and the ethers.js slidityKeccak256 function…
GGizmos
  • 3,443
  • 4
  • 27
  • 72
3
votes
2 answers

Verify WebAuthn ECDSA signature in ethers.js

Using the SimpleWebAuthn TypeScript package, I have generated a ECDSA-SHA256 key pair and I used the key pair to sign a challenge. The SimpleWebAuthn package uses crypto.webcrypto.subtle (see this line) to verify the signature. I want to verify the…
Yao
  • 359
  • 4
  • 10
3
votes
3 answers

BigNumber multiplying decimal values in ethers

I want to do math - 100000 * 1.004 by using BigNumber values. The biggest problem here is that 1.004 is a float and BigNumber does not accept it. I am using ethers.js library for it. I tried to use parseUnits("1.004", 18). I am using 18 because…
Mickey
  • 61
  • 1
  • 5
3
votes
2 answers

Is there a way to read token address from the command line Hardhat script RSK

I have a Hardhat script that queries the RIF token balance on Rootstock. However the RIF address is hardcoded in my script: ​ const rifTokenAddress = '0x2aCc95758f8b5F583470bA265Eb685a8f45fC9D5'; ​ async function main() { const erc20 = await…
Adil6
  • 31
  • 3
3
votes
3 answers

ERC-20 holders list on Polygon

How do I get a list of a given ERC20 token holders? I use QuickNode + ethers.js or web3.js and I have SC address for the ERC20 token. Is there a short way to get a list of token holders or do I have to look through transactions? I've tried…
Stefan Drl
  • 53
  • 7
3
votes
1 answer

Invalid signature when siging EIP-712 data

I am trying call transferWithAuthorization on the USDC contract (which implements EIP-3009). To do this, I need to sign the transaction data and then execute the transaction, however I am getting the error: Fail with error 'FiatTokenV2: invalid…
ljenkins
  • 133
  • 2
  • 10
3
votes
1 answer

Why do I get Sender's Account Does Not Exist when I send ERC20 Token from a new account with tokens?

I create my wallet like this const wallet = ethers.Wallet.createRandom() I use metamask to send RIF tokens to the public address. I confirm the new balance of the account and it is accurate, the ERC20 transaction worked. When I try to send some of…
Hamady C.
  • 1,205
  • 11
  • 13