Questions tagged [ethers.js]

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

More information on ethers.io.

801 questions
5
votes
2 answers

How to aggregate multiple smart contract function calls on Rootstock?

I have multiple ERC20 tokens, deployed on Rootstock, and I want to track their balances and allowances in a real time from my DApp. In ethers.js, I can track their balances by alternately calling the functions balanceOf(address) and allowance(owner,…
bguiz
  • 27,371
  • 47
  • 154
  • 243
5
votes
1 answer

How to connect to custom Provider using ethers?

How do you create a new Provider using a custom node url using the ethers package? Looking to do something like this: const provider = new ethers.providers.Web3Provider('http://my-node.com')
cormacncheese
  • 1,251
  • 1
  • 13
  • 27
5
votes
7 answers

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.8)

I want to connect to ganache and I get an error that I don't know how to solve it. here is my deploy.js code which is script node.js const ethers = require("ethers") // const solc = require("solc") const fs = require("fs-extra") …
Paweł Stach
  • 83
  • 1
  • 1
  • 5
5
votes
1 answer

Why does an event emitted by a smart contract function called via `delegateCall` disappear?

I have two interacting smart contracts that I am developing/testing in Hardhat and deploying to RSK: DelegateCallee smart contract with a getData() function, emitting a Received event: contract DelegateCallee { event Received(address sender,…
Aleks Shenshin
  • 2,117
  • 5
  • 18
5
votes
2 answers

How to decode bytes calldata in a smart contract?

I have 2 interacting smart contracts which I am developing/testing in Hardhat and deploying to RSK. One of them is an ERC1363 payable token with transferAndCall(address,uint256,bytes) function, and the second one is a token receiver whose…
Aleks Shenshin
  • 2,117
  • 5
  • 18
5
votes
2 answers

How to test the Solidity fallback() function via Hardhat?

I have a Solidity smart contract Demo which I am developing in Hardhat and testing on the RSK Testnet. //SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; contract Demo { event Error(string); fallback() external { emit…
Aleks Shenshin
  • 2,117
  • 5
  • 18
5
votes
1 answer

Is it possible to top up smart contract's balance at the time of its deployment?

Say I have a Solidity smart contract MultiToken.sol which I am developing and testing using Hardhat and deploying to the RSK network. ​ //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; ​ import…
5
votes
1 answer

How to verify message in wallet connect with ethers primarily on ambire wallet?

I am trying to sign a message with wallet connect using ethers, but I am facing an issue when verifying the message with ambire wallet, it's not returning any response. const signMessage = async () => { try { console.log("started"); …
divyan
  • 59
  • 1
  • 3
5
votes
0 answers

Type error when passing web3provider as a prop with typescript

I'm trying to pass a Web3Provider as a prop to a hook with others, and I keep getting an error Here's the code of how I get the provider const provider = new ethers.providers.Web3Provider(window.ethereum) Then I have inside the return…
Fab
  • 61
  • 6
5
votes
1 answer

How to decode transaction input data using `ethers.utils.defaultAbiCoder`

I'm fetching transaction data using Etherscan API. This is the example result I'm getting: { blockNumber: '7409930', timeStamp: '1639151980', hash: '...', nonce: '4124', ... input:…
Jan Potočnik
  • 51
  • 1
  • 2
5
votes
3 answers

MetaMask - RPC Error: execution reverted {code: -32000, message: 'execution reverted'} while trying to connect to smart contract

I have deployed a smart contract on a public testnet and now I am trying to connect to it from the front end using ethers js. But when I try to fetch the value it gives the following errors in the console: I am using Angular for the front end and…
Vivek
  • 193
  • 3
  • 3
  • 9
5
votes
1 answer

Implementing Ethereum personal_sign (EIP-191) from go-ethereum gives different signature from ethers.js

I am attempting to generate a personal_sign in Golang like its implemented in ethers.js. Similar question but that ended up using the regular sign over the personal sign_implementation. Ethers // keccak256 hash of the data let dataHash =…
Franco
  • 848
  • 1
  • 12
  • 24
5
votes
1 answer

How to define an array of structs return type in ethers.js ABI

Currently I got this abi: const stakingAbi = [ 'function getStakes(address user) external view returns (Stake[] memory)', 'function stake7Days(uint128 _amount) external whenNotPaused', 'function stake14Days(uint128 _amount) external…
Thimma
  • 1,343
  • 7
  • 33
5
votes
2 answers

How do I listen to events from a smart contract using ethers.js contract.on() in a node.js application?

I'm trying to listen to events emitted from the USDT contract Transfer function using ethers.js (not web3) in a node.js application. When I run the script, the code runs with no errors and then quickly exits. I'd expect to get the event logs. I'm…
4
votes
1 answer

How to resolve intermittent "nonce has already been used" error when deploying multiple smart contracts to Hedera Testnet?

When I deploy 2 smart contracts at the same time to Hedera Testnet, I get the following error: nonce has already been used [ See: https://links.ethers.org/v5-errors-NONCE_EXPIRED ] This occurs intermittently, roughly about 20% of the time. Their…
bguiz
  • 27,371
  • 47
  • 154
  • 243
1 2
3
53 54