Questions tagged [ethers.js]

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

More information on ethers.io.

801 questions
27
votes
3 answers

No safeTransferFrom function in ethers.js contract instance?

I created a contract instance in hardhat console like so: const contract_fac = await ethers.getContractFactory("ContractName"); const contract = await contract_fac.attach("CONTRACTADDR..."); Contract object has all public/external functions except…
Lightstorm
  • 379
  • 4
  • 5
25
votes
4 answers

Set gas limit on contract method in ethers.js

Problem I am trying to use a method of a contract on the test network (ropsten), but it fails due to this error: reason: 'cannot estimate gas; transaction may fail or may require manual gas limit', code: 'UNPREDICTABLE_GAS_LIMIT' Code I created an…
Gh05d
  • 7,923
  • 7
  • 33
  • 64
23
votes
1 answer

How would I send an eth value to specific smart contract function that is payable in ethers.js?

I'm trying to call a payable function on a smart contract that only accepts one argument. How would I send an eth value to this function in ethers.js along with the function call? The docs don't seem to give much examples on the best way to do…
18
votes
1 answer

How can I use different addresses to call functions in Hardhat tests and scripts?

When running tests and scripts, all functions are called by the first address provided by Hardhat. I'd like to know if there's a way to change the calling address within the same test or script. Thanks in advance!
Nico
  • 181
  • 1
  • 4
12
votes
4 answers

Ethers.js "Error: unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION)"

I'm trying to fetch the price of ETH from KyberSwap, using Ethers.js, but I'm receiving the following error: Error: unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION, version=providers/5.5.3) I'm connected to an Infura web…
Jasperan
  • 2,154
  • 1
  • 16
  • 40
12
votes
3 answers

`Property 'ethereum' does not exist on type 'Window & typeof globalThis'` error in React

I am getting the Property 'ethereum' does not exist on type 'Window & typeof globalThis' error in React. This is the line generating the issue: import { ethers } from 'ethers' const provider = new…
Boris
  • 11,373
  • 2
  • 33
  • 35
11
votes
6 answers

Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed. Reason: Fail - Unable to verify - with arguments

I am trying to verify my contract with arguments and I am getting this error: Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed. Reason: Fail - Unable to verify I am also importing Open Zeppelin contracts…
solidityguy
  • 199
  • 1
  • 3
  • 8
10
votes
2 answers

How to receive a value returned by a Solidity smart contract transacting function?

I am writing an NFT smart contract which I am going to test via Hardhat and deploy on RSK. //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; contract MyNFT…
Ahsan
  • 339
  • 3
  • 11
10
votes
1 answer

Get events from a transaction receipt in hardhat

I have an ethers contract that I've made a transaction with: const randomSVG = new ethers.Contract(RandomSVG.address, RandomSVGContract.interface, signer) let tx = await randomSVG.create() I have an event with this transaction: function create()…
Patrick Collins
  • 5,621
  • 3
  • 26
  • 64
9
votes
4 answers

How to send ETH to a contract function with ethers.js?

I am trying to send ETH to a contract function from a web app via metamask and ethers.js. So far I have tried: const provider = new ethers.providers.Web3Provider(window.ethereum); const signer = provider.getSigner(); const splitterManager = new…
Bruce Jayasinghe
  • 173
  • 1
  • 1
  • 7
9
votes
6 answers

Invalid address or ENS name

I can't understand what the problem is. When I am run the app I am getting this error: Unhandled Runtime Error Error: invalid address or ENS name (argument="name", value=5.050201689117535e+47, code=INVALID_ARGUMENT, version=contracts/5.5.0) My code…
Ishtiaq Mahmood
  • 154
  • 1
  • 2
  • 8
9
votes
9 answers

Error connecting to localhost after npm hardhat run

I am new to deploying smart contracts with hardhat and am following a tutorial at https://dev.to/dabit3/the-complete-guide-to-full-stack-ethereum-development-3j13. However, after running npx hardhat run scripts/deploy.js --network localhost, I get…
sultan m_c_t
  • 99
  • 1
  • 1
  • 3
9
votes
3 answers

How to connect ethers.js library with Rinkeby programmatically?

According to official docs of ethers.js, this should be the way how to connect to a specific network like Rinkeby-testnet with custom data: const provider = ethers.getDefaultProvider(network, { etherscan: ETHERSCAN_API_KEY, infura:…
delete
  • 18,144
  • 15
  • 48
  • 79
9
votes
2 answers

How to get Ethers.js response data

Solidity: function ping() public view returns ( uint ) { return 999999999; } function ping2() public returns ( uint ) { return 999999999; } Javascript Ethers.js: (await contract.ping()).toString(); //-> 999999999 ( correct ) (await…
Om Solari
  • 207
  • 1
  • 4
  • 13
8
votes
2 answers

Documentation for ethers.getContractAt()

Can somebody please point me to the documentation (official or otherwise ) that explains the function ethers.getContractAt(): the original context of this is as follows: vrfCoordinator = await ethers.getContractAt('VRFCoordinatorMock',…
maskara
  • 329
  • 1
  • 2
  • 12
1
2 3
53 54