Questions tagged [ethers.js]

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

More information on ethers.io.

801 questions
8
votes
1 answer

Solidity: Testing reverted assertions with waffle + chai doesn't work

I'm testing a smart contract for an ERC721 token, that inherits from OpenZeppelin, using waffle and chai with NodeJS v14.18.0, but chai's reverted assertions don't seem to function as expected. Dependencies: "devDependencies": { …
Craigson
  • 131
  • 2
  • 8
8
votes
1 answer

Web3 signature verification is failing - ethers.js

I'm trying to create a signed message off-chain using ethers.js and verify that message on-chain using ecrecover. I'm signing the correct message from my metamask wallet, and passing the r, s, and v from that signature into ecrecover, but not…
a94
  • 564
  • 1
  • 7
  • 16
7
votes
1 answer

Invalid signature error from ethers when trying to verify a Smart Contract Wallet(account abstraction) signature

I am working on a dapp that needs to verify users' signatures. When testing with Metamask, everything is okay. When trying to verify a signature from Ambire wallet, I get "Error: invalid signature string" from ethers.utils.verifyMessage For example,…
whd
  • 1,819
  • 1
  • 21
  • 52
7
votes
1 answer

How do I send transactions to RSK deployed smart contract functions via Ethers.js and Hardhat

I have followed this Hardhat tutorial and trying to test a demo smart contract on RSK regtest blockchain. Here is the hardhat.config.js setup I am using: require('@nomiclabs/hardhat-waffle'); module.exports = { solidity: '0.7.3', …
7alip
  • 895
  • 6
  • 11
7
votes
5 answers

Error: invalid BigNumber value (argument="value", value={"value":"25000000000000000"}, code=INVALID_ARGUMENT, version=bignumber/5.5.0)

I have tried changing the values from 0.025 ether to 1 ether then also its showing the same error. Also, I have tried with the rational number like 1/8 still not working. LOOKED into some answers but they didn't resolve the error. I have the same…
Megabyte
  • 139
  • 1
  • 2
  • 9
7
votes
1 answer

Check balance of ERC20 token in Hardhat using Ethers.js

I'm writing unit tests using Hardhat's mainnet fork, and for a test I want to check the owner account's initial balance of an ERC20 token, in particular DAI. Here's my test so far: const { ethers } = require("hardhat"); describe("Simple Test",…
Jasperan
  • 2,154
  • 1
  • 16
  • 40
7
votes
1 answer

Wallet Connect configuration with Binance smart chain not working

I'm trying to link BSC chain with wallet connect in my react DAPP. const walletConnectProvider = await new WalletConnectProvider({ rpc: { 56: "https://bsc-dataseed.binance.org", }, }); await walletConnectProvider.enable(); …
7
votes
2 answers

Solidity - Why default getter of a public Struct variable doesn't return every variable inside Struct

I am currently learning Solidity language and I've noticed that when I'm trying to get the value of a Struct inside my JS code, Solidity returns every variable without arrays. I have to create custom getter to access all the data inside my…
Nicolas M.
  • 360
  • 6
  • 12
6
votes
2 answers

Nextjs 13.0.2 and Ethers why is my Provider undefined?

I'm trying to access the ethers provider like this in Nextjs 13.0.1: import { ethers } from "ethers"; export const signMessage = () => { const provider = new ethers.providers.Web3Provider(window.ethereum); const signer =…
patrick
  • 343
  • 1
  • 12
6
votes
2 answers

How to attach debugger to hardhat chai tests in Vscode and use Typescript breakpoints?

I know I can put console.logs in Chai tests and get them printed in console. However, I want to know how can I put a regular breakpoint (or debugger; statement) in Vscode, and hit it, and debug as usual with stepping, evaluation, viewing local…
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
6
votes
1 answer

How to calculate a smart contract deployment price on RSK?

Say I have an ERC20 smart contract which I'm developing and testing in Hardhat: //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import…
Aleks Shenshin
  • 2,117
  • 5
  • 18
6
votes
2 answers

Ethers.js gives "resolver or addr is not configured for ENS name"

I have the following code: const ethereumProvider = ethers.getDefaultProvider(ETHEREUM_RPC); const contract = new ethers.Contract( CONTRACT_ADDRESS, abi, ethereumProvider, ); The ethers package gives me the following error: Error: resolver…
Drarig29
  • 1,902
  • 1
  • 19
  • 42
6
votes
2 answers

Contract event listener is not firing when running hardhat tests with ethers js

Here is a very small repo to show the issue: https://github.com/adamdry/ethers-event-issue But I'll explain it here too. This is my contract: //SPDX-License-Identifier: UNLICENSED; pragma solidity 0.8.4; contract ContractA { event…
Force Hero
  • 2,674
  • 3
  • 19
  • 35
6
votes
0 answers

Access ContractFactory in web3-react

I'm using web3-react@^5.0.5 to interact with web3 from my react app. I can connect to metamask just fine. I set the library to ethers.js and connected to metmask. Connecting worked fine, but almost none of ethers.js's methods are there. For example,…
Jake
  • 2,090
  • 2
  • 11
  • 24
5
votes
2 answers

ethers web3Modal Property 'providers' does not exist on type 'typeof import(...)'

I am trying to add web3 wallet connect button onto my webpage but I am getting this error and I am not able to resolve it since a long time. It is a nextjs react application. const InvitesPage: NextPage = () => { let web3Modal: any; useEffect(()…
1
2
3
53 54