Questions tagged [ethers.js]

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

More information on ethers.io.

801 questions
3
votes
2 answers

How get estimated gas before sending the transaction?

How do you get the "estimated gas" from a "swapExactETHForTokens" function? As shown in metamask (before one can accept the purchase) Binance Smart Chain (BSC) From the pancakeswap contract…
luisbriyan
  • 95
  • 9
3
votes
2 answers

Why Does My Ethereum ".on" Event Listener Stop Firing?

I have a node.js server where I am listening for an event that is emitted from a Solidity smart contract deployed on the Mumbai Polygon testnet. First, I'm using the "web3-providers-ws" node package to create a provider, using keepalive and…
Jim
  • 3,821
  • 1
  • 28
  • 60
3
votes
1 answer

tx.wait with Ethers.js never resolves

I'm trying to send transactions to the polygon network using ethers.js. After submitting the transaction, i await tx.wait(), but it fails to resolve 50% of the time. I saw other people were having similar issues but was due to their gas price being…
Dan Ramos
  • 1,092
  • 2
  • 19
  • 35
3
votes
4 answers

How to generate arbitrary wallet seeded with eth in hardhat tests using ethers.js?

I'm currently trying to run a test in hardhat/waffle that requires hundreds of unique wallets to call a contract, using new ethers.Wallet.createRandom(). However, none of these wallets are supplied with eth, so I can't call/send transactions with…
3
votes
1 answer

Ethers.js, send money to a smart contract (receive function)

I have a smart contract with a receive function : receive() external payable { Wallets[msg.sender] += msg.value; } I have a front end and I want to send Ethers to this smart contract using the receive() function. async function transfer()…
Ben BK
  • 154
  • 2
  • 11
3
votes
1 answer

window.ethereum.request get_balance method, how do I get the tokens amount of specific token?

I was wondering, what can be done so it would get a balance of specific token I want instead of ethereum? const getAccountBalance = (account) => { window.ethereum.request({method: 'eth_getBalance', params: [account, 'latest']}) …
Terkinas
  • 71
  • 1
  • 7
3
votes
1 answer

× Unhandled Rejection (Error): invalid fragment object (argument="value", value=

I am new to Smart Contracts. I am unable to read a smart contract from Binance test network. I keep getting an Unhandled Rejection every time I attempt to read my smart contract using ethers.js. Error Unhandled Rejection (Error): invalid fragment…
3
votes
1 answer

useDapp's useContractCall throws "Invalid contract call" in React

in React component I want to read function "paused" in contract deployed on Rinkeby testnet. Using useDapp (https://usedapp.io/) hook "useContractCall", i call contract function in custom hook: import { ethers } from "ethers"; import {…
3
votes
2 answers

SyntaxError: Invalid character '\ud835'

SyntaxError: Invalid character '\ud835' When running a web application (built with Typescript + Webpack) inside Safari I am facing the error above (not faced in other browsers). From searching all node_modules, ethers.js contains: const EtherSymbol…
Nick Taras
  • 696
  • 8
  • 15
3
votes
2 answers

How to restart a local hardhat node to initial state?

I am not really sure how to restart the state of the node to the initial state. Each time I try to redeploy a contract - I'm getting the same contract, the constructor params don't change. How to clean my local hardhat node?
Shocky2
  • 504
  • 6
  • 24
3
votes
1 answer

How to Make a Custom Chain Connect Button With Ethers.js

I want to make a connect to custom network like that at the bottom of arbiscan.io How would I do this using ethers.js framework? Clicking the button should add arbitrum network to user's Metamask.
Curio
  • 33
  • 1
  • 6
3
votes
1 answer

Equivalent for abi.encodePacked

I am using ethers-rs to write a defi app. I need to calculate the CREATE2 address in rust. I couldn't find the equivalent of abi.encodePacked(token0, token1) in rust. The code used in Uniswap's library…
Ganesh Rathinavel
  • 1,243
  • 4
  • 17
  • 38
3
votes
1 answer

ethers.js: provider.getGasPrice()

In ethers.js you can use provider.getGasPrice() to get a best-guess estimate of the gas you should pay. Is there anything simple I can call or transform onto this value in order to get what an equivalent of a "Fast" transaction would be instead of…
aroooo
  • 4,726
  • 8
  • 47
  • 81
2
votes
1 answer

Cannot read properties of undefined (reading 'parseUnits') - Hardhat js

When trying to use ethers.utils.parseUnits("1", "ether") in a test function an error is thrown TypeError: Cannot read properties of undefined (reading 'parseUnits'). const { deployments, ethers, getNamedAccounts } = require("hardhat") const {…
Moeyjac
  • 31
  • 6
2
votes
0 answers

ENS name not configured

I use the ENS address for my code const {ethers} = require('ethers') const provider = new ethers.providers.JsonRpcProvider("") const addressReceiver = 'ENS.eth' const privateKeys = ["AAAAAAA"] const bot = async =>{ provider.on('block', async…
2troy
  • 21
  • 1