Questions tagged [ethers.js]

A lightweight JavaScript library which can be used as an alternative to Web3.js to build your JavaScript front-end and interact with the Ethereum blockchain.

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

Missed events when using ethersjs contract.on in a nodejs backend

I am using a default ethersjs provider with Infura and etherscan API keys to listen for a contract events with contract.on(event, listener) in a nodejs backend. It misses some of the events (let's say ...
0
votes
1answer
12 views

EIP-2771: Is it possible to pay a function with from's eth, not the forwarder contract's eth

I use OpenZeppelin ERC-2771 lib. I managed to forward an EIP-712 signed transaction to a contract. The function I call is payable. So far I only managed to have my Forwarder contract paying the ...
0
votes
1answer
4 views

WETH Deposit returning an error

I'm trying to get a WETH by calling the WETH contract on Kovan (using ethers.js) but something goes wrong. Here's my code: const swapETHForWETH = async(eth: string) => { const wethAddr = "...
0
votes
0answers
4 views

Contract.on(filter, (result) => { console.log(result)}) doesn't return anything

campaignFactory.on(getDeployedCampaign, (result) => { console.log("result is: ", result); }); This block is not returning anything const { expect } = require("chai"); const { ...
0
votes
0answers
6 views

verifyMessage throw `TypeError: Cannot read property 'r' of undefined`

I'm implementing web3 authentication using sign message and verify message. On my client side i have following code: const timestamp = Math.floor(Date.now() / 1000) const message = `Current time ${...
1
vote
0answers
20 views

Private key from 13/25 seed phrase

It's quite clear for me how to generate a 12-24 seed phrase: straightforward with ethers.js import { entropyToMnemonic } from "@ethersproject/hdnode" // 16 bytes / 128 bits => 12 ...
0
votes
0answers
7 views

TypeError: ethers.getContractFactory is not a function

Im trying to run the partybid contract https://github.com/PartyDAO/partybid from windows powershell but am running into this issue where getContractFactory is not a function Under helpers.js: const fs ...
0
votes
0answers
12 views

Mint failing on rinkeby with ethers and react. Help troubleshooting?

I've deployed a contract on Rinkeby with Truffle, and connected to it with Ethers.js and React. When I call the minting function defined in the smart contract, passing an address and token metadata ...
1
vote
0answers
19 views

Cannot interact with deployed contract - negative hex string

I am working on several contracts and I can deploy and test fine on hardhat-network. However whenever I switch to Ganache or Rinkeby I get the following behaviour: The contract deploys fine Whenever ...
0
votes
0answers
6 views

How would you get total transactions submitted by an address to a specific smart contract?

If I want to see how many transactions your address has sent to Opensea's contracts over the last year - how would you do this? Would you just query etherscan? Or is there a better way?
0
votes
1answer
36 views

Interacting with Contract instance works on hardhat local rpc but throws error on mumbai testnet

So I'm currently working on an nft marketplace and I have this function that gets all the collections(which are proxy contracts) in the marketplace and gets basic info from the contract, like the name,...
0
votes
1answer
11 views

EthersJS JSON to sha256: Error string too long

what I'm trying to accomplish is creating a hash of a JSON object. This will then be used as a bytes32 parameter when minting a token. I thought the best way to go about this is to first stringify a ...
0
votes
0answers
12 views

Ethers - Reading Staked Balance from Staking Contract

I'm trying to read the value of a given token that is staked or locked. I can get this to work for DuckStarter's staking contract in NodeJS using the EthersJS package like so: // THIS WORKS async ...
1
vote
2answers
26 views

Web3 + React: After successful transacion, try to get changed state but returns old value?

I'm trying to do something pretty simple using React, but I can't understand what's going on. const A = await myContract.getA() // A = 0 myContract .setA(1) // should set A = 1 => ...
0
votes
1answer
17 views

swapExactTokensForTokens not working!

We are trying to "swapExactTokensforTokens" for swapping any token, and it runs well, but we get this error at the blockchain: TRANSFER_FROM_FAILED https://polygonscan.com/tx/...
0
votes
0answers
13 views

Trying to use an Alchemy Websockets address to subscribe to an event but it errors out when it tries to update

Here is the script: const Big = require('big.js'); const blk = require('./blockchain'); const UniswapV2Pair = require('./abi/IUniswapV2Pair.json'); const cc = require('./common_code'); const ...
0
votes
0answers
17 views

Signing with BSC Provider causes unknown ENS error

I am not sure why this is throwing an error. From all the examples I've looked it up, it seems correct, but no amount of chaning how i send the provider makes the error go away. mintReward: function(...
0
votes
2answers
34 views

Ethersjs - get ERC20 contract decimals

I have the following: import { ethers } from "ethers"; import { ws } from "../providers/node"; import abi from "../abi"; export default async (address: string) => { ...
0
votes
0answers
26 views

Calling Contract meet UNPREDICTABLE_GAS_LIMIT error

the detail scenario is i try to call pancake erc20 pair swap method using ethers the code like below: const gasLimit = await pancakePair.estimateGas.swap( !shouldStartEth ? DAI_TRADE : ...
0
votes
1answer
40 views

Gnosis safe-core-sdk : EthersAdapter is giving empty object

I'm trying to use safe-core-sdk on our Dapp but the EthersAdapter instance creation is always giving empty object even the signer is getting from the provider is working fine Lib used : ether.js ^5....
1
vote
1answer
29 views

How to gather historical events emitted by any contract

I am trying to gather all events of a specific type on the entire chain, regardless of what contract emitted them. When trying to find solutions online, I came across code like the following (source): ...
1
vote
1answer
11 views

Transaction not created by ethers.js

I have written the following code to try to mint an NFT based on some git repos I saw. The code runs successfully and outputs a transaction hash, but the hash never resolves to anything on Rinkeby ...
2
votes
0answers
11 views

Is there a way to set gas fees to 0 for unit tests in ethers js?

All the contract deploying and setup cost some gas fees. Is there a way to disable or set gas fees to 0, so we can calculate and test only the meaningful business logic change on the balance, without ...
0
votes
1answer
36 views

How to call a contract function from ReactJS, that takes a struct as an argument?

I am struggling to figure out how to actually call a function (using React) in a contract that takes a struct as an argument (which also has another struct in it) ? The contract function looks like ...
0
votes
0answers
31 views

Ethers: constructor with function signature as parameter

I'm trying to instantiate a contract and pass a function signature as parameter in the constructor: callbackContract.callbackFunction.selector What's the right syntax to do that with Ethers ? contract ...
1
vote
0answers
27 views

Proper Local Hardhat Deploy and Transaction: function call to a non-contract account

I am trying to test out this contract function by function to interpret how each call works and while I am able to deploy the contract, I receive this error message, Error: Transaction reverted: ...
0
votes
2answers
53 views

Cannot approve or sell token swapExactTokensForTokens: transaction fails (not a honeypot)

I am trying to sell a token (DOBO). Buying DOBO is no problem and it goes through. But I cannot sell it. I get a failed transaction, but no error message on node.js (see https://bscscan.com/tx/...
0
votes
0answers
19 views

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist while trying to connect metamask

There seems to be a problem while connecting metamask to the web application. At the first initialization of the application it throws this error but when, I refresh the page metamask pops up ...
0
votes
1answer
94 views

How to approve() a ERC721 token to an unknown address which buys the token at some later point?

I am building an NFT marketplace where the user actions are as follows. Address A uploads an image to create an NFT. This action calls smart contract functions createToken() to create ERC721 token ...
0
votes
1answer
36 views

passing constructor arguments to smartcontract with options

i have a smartcontract that expects constructor arguments. i would like to deploy the contract with arguments and also pass the options gasPrice and gasLimit. this is my function for deploying: const ...
1
vote
1answer
45 views

How to call an external contract function using custom Struct from typescript

I have this basic contrat: //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.4; import "hardhat/console.sol"; contract Greeter { struct Greeting { uint8 id; ...
0
votes
1answer
18 views

How to deploy smart contracts from other accounts using javascript?

How can we deploy contracts using web3.js or ethers.js just like thirdweb does? I create a contract on web3.js then used the deploy function with send but then alchemy gave an error that it can't ...
0
votes
1answer
89 views

Undefined output when using getPair and getReserves in web3 / node.js

Happy new year to you all! I am trying to get the wBNB/BUSD pair address from Pancakeswap (using getPair) and then check for their liquidity (using getReserves). I have pretty much copied the code ...
0
votes
0answers
6 views

How do you get the Erc20 token balance of a random address using hardhat without the ABI json? [duplicate]

I need the dai balance of a whale which I am impersonating with hardhat.
0
votes
1answer
18 views

What is `ContractTransaction`?

I have a function in my smart contract: function provideLiquidity(address inputToken, uint256 amount) external override onlyValidAddress(inputToken) whenNotPaused ...
0
votes
1answer
41 views

How to test sending eth to function using ethers.js?

I'm net to eth dev and trying to test sending eth while assigning a value to betOnTeam function: function betOnTeam(uint8 _team) public payable { // assign usre to _team and add betting value to ...
0
votes
0answers
20 views

Major differences between ethers-js and ethers-rs

I haven't used ethers-rs before, are there any extra features there compared to ethers-js. Learning rust is not an issue here, I'm pretty comfortable with both javascript and rust.
0
votes
0answers
4 views

Can anyone tell me the way to access the uncle blocks and newly created blocks with ether.js

I'm trying to figure out the method that would help me to list uncle and newly created blocks on the blockchain network. I created a script for uncle block by going through the ethers.js docs, where I'...
0
votes
1answer
126 views

ethers js .callStatic() method doesn't support Uniswap Router

I have created a test project for the purpose of this question for testing a simple swap using Uniswap Router. My aim is to simply test the transaction before it is actually sent, so I'm trying to use ...
0
votes
0answers
25 views

Why does web3js return gas price instantly, and ethersjs takes 1-2 seconds, same rpc

takes less than .3 seconds: await w3provider.eth.getGasPrice() takes 1-2 seconds: g = await ethersjsprovider.getGasPrice() using node repl, to test each of them 20 times, same alchemy json rpc url, ...
1
vote
1answer
29 views

Programmatically get smart contract ABI and Bytecode

I have ERC20 contracts with imports and solc is not able to compile contracts with imports. I have tried truffle compile and it works fine and generates ABI. I want to fetch smart contract file ABI by ...
0
votes
1answer
28 views

Ethers.js event firing question

I've got a simple contract that fires an event when a method is called. On my ethers.js client in an html page I've got the following code executed when the page is loaded: voterContract.on(&...
0
votes
0answers
17 views

ReactJS & Chainlink connection for a generated random number

During my investigation, I would like a piece of advice, please. I am trying to get a random number generated by the VRF of the oracle chainlink from the front coded in ReactJS. I would like to get ...
0
votes
1answer
53 views

ethers web3provider can't connect to metamask the second time

I am developing a React NFT marketplace on Polygon where a user can create, buy and relist an NFT. The issue is I am unable to connect to Metamask/web3provider for the second time after successfully ...
1
vote
1answer
50 views

Do we need to use both Metamask and Alchemy as providers?

I was using metamask (window.ethereum) as my Web3 provider but for production was going to switch to Alchemy and realized that the provider.listAccounts() method stopped working with Alchemy provider. ...
1
vote
0answers
33 views

Running multiple nodes in different physical locations

The goal I'm currently running a sniping bot that interacts with a private node. The goal is to detect new ERC20 token launches and place orders. After a while of testing this setup I noticed that ...
1
vote
1answer
97 views

How to ask the metamask user to switch its network?

Some web3 enabled websites ask you to switch your network on metamask. How can I do so? Some other websites also allow you to add a network you don't have (for example https://chainlist.org/). I would ...
1
vote
0answers
19 views

How to get uint256 from smart contract without signer

I have a simple smart contract method that returns the current token Id minted. function getCurrentId() public view returns (uint256) { return _tokenIds.current(); } it works just good ...
1
vote
1answer
128 views

Using typed @web3-react/core, Web3ReactProvider, useWeb3React in a well-encapsulated way

I was looking into good usage patterns of @web3-react/core, specifically was looking at Uniswap's V3 code among other places... Examples here: https://github.com/Uniswap/interface/blob/main/src/index....
1
vote
1answer
20 views

How to prevent cross-chain signed message replay?

I'm building a system for Ethereum authentication through the browser, which also checks whether the user owns a specific token. For this, I'm sending from the back-end a nonce for the user to sign ...

1
2 3 4 5
10