Questions tagged [ethersjs]

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
10 views

Error when deploying a contract on Hardhat network with mainnet forking enabled

I'm running some tests on Hardhat network with the following config: const config = { networks: { hardhat: { chainId: 1337, forking: { enabled: true, url: `https://...
2
votes
0answers
19 views

Capture that a listener dismissed the MetaMask popup

I'm using ethers.js and I'm writing code to connect to MetaMask when the user clicks a "connect" button on my site. The problem I'm having is that I'm unable to determine if the user ...
0
votes
0answers
38 views

Capturing accounts on metamask with Ethers.js

On this code, the private_key is the key that the user entered. My goal here is to get the private_key from the user and log in with whichever public key it matches among the accounts that I have ...
0
votes
2answers
15 views

Ways to securely generate private key with ethersjs

I current use ethers.Wallet.createRandom() to generate private key by extracting .privateKey with ethersjs 5.3.0 in React Native 0.64 app. What is other way to securely generate private key? Somehow ...
5
votes
1answer
201 views

Proxy contract to avoid sniping bot

I am working on a trading bot with ethers.js and I would love if someone could elaborate on the following topic. Many sniping bots try to buy as fast as liquidity is added to the pool. This can be ...
0
votes
1answer
30 views

Obtain transaction hash from event (ethersjs)

My goal is to detect a contract invocation as fast as humanly possible. To do this I am processing all the pending transactions I have access to (via provider.on("pending", async (tx) => {...
2
votes
1answer
25 views

How to get historical value of a state variable?

I am unsure of the best way to do this. I have a pool contract with a state variable of the total balance of the pool. I want to show a line chart on my dApp that shows how the balance of the pool has ...
1
vote
2answers
121 views

String to Hex in Ethers.js

Only one question: How can I convert string to hex in ethers.js I need some alternative to: web3.utils.utf8ToHex() - but in ethers Any help is appreciated
1
vote
1answer
24 views

is ConnectionInfo class in ehters 5.x?

Here is the doc about provider in ethers 5.x document: new ethers.providers.JsonRpcProvider( [ urlOrConnectionInfo [ , networkish ] ] ) Connect to a JSON-RPC HTTP API using the URL or ConnectionInfo ...
0
votes
0answers
11 views

How to init type of ConnectionInfo variable?

In ethers 5.x, how to init type of ConnectionInfo variable? I am having hard time to init a variable of the type. Here the doc for ConnectionInfo: ConnectionInfo connection.url ⇒ string The URL to ...
2
votes
1answer
50 views

How to assign networkish for provider?

Here is the doc about provider in ethers 5.x document: new ethers.providers.JsonRpcProvider( [ urlOrConnectionInfo [ , networkish ] ] ) Connect to a JSON-RPC HTTP API using the URL or ConnectionInfo ...
1
vote
0answers
62 views

Error: Wallet has error: Error: could not detect network (event=“noNetwork”, code=NETWORK_ERROR, version=providers/5.0.17)

After enabling JWT token authentication on besu network, a connectionInfo with JWT token in headers is used to make connection to the network, instead of url. import { ContractFactory, ethers } from &...
0
votes
1answer
12 views

How to add JWT token in JsonRpcProvider url header when connecting to JWT enabled network?

When connecting to Besu network which enables JWT public key authentication, how to add the token to the JsonRpcProvider (ethers 5.0.8)? Here is the current code (before adding JWT token): let ...
1
vote
0answers
30 views

Can't connect to geth JSON RPC from React Native Expo

I am using the ethers library on npm to connect. My code for testing the connection is as follows let result = await ethers.utils._fetchData( { url: "https://MY_URL", ...
1
vote
0answers
44 views

Unknown account while trying to send transaction via OptimismProvider

I'm trying to make use of OptimismProvider to sign the transaction on Mumbai Matic. I'm making use of provider.send("eth_sendTransaction", [hexTxn]) and instantiating provider object by: ...
0
votes
0answers
29 views

Script for running permutations of seed phrases and finding corresponding ethereum address

My metamask extension was deleted and what I thought was the correct ordering of the seed phrase turns out not to be so. I have all 12 BIP39 phrases and am looking to run a 12! permutation to find the ...
0
votes
1answer
80 views

How do I find the gasPrice of a confirmed transaction with ethers js?

How do I find the gas price of a confirmed transaction with ethers js?
2
votes
2answers
170 views

What is in return when listening to an event?

In Hellos.sol, there is event initContract after constructor is called. Here is the solidity code: pragma solidity 0.7.0; contract Hello { address owner; uint256 value; event ...
0
votes
1answer
26 views

How to read the return object of call to function in a contract?

Here is the function isDude in a contract. If the address is recorded, then isDude returns true. Otherwise it returns false. Here is the contract function isDude: function isDude(address _dude_address)...
0
votes
0answers
14 views

EthersJS returns array double wrapped i.e [ [“0x838383…”, “0x3BC2…”, ] ]

I have a method that is supposed to return an array of deployed contract addresses, it works albeit the value that is returned client side is wrapped with an extra set of brackets and also when ...
0
votes
0answers
35 views

Error known transaction when deploying a contract with ethersjs 5

The error occurred transaction was submitted to besu network. Here is the result of web3_clientVersion: $curl -X POST --data '{"jsonrpc":2.0,"params":[], "id":1,"...
0
votes
0answers
26 views

Which signer shall be used to sign transaction message?

Here is the code to create wallet and signer with ethers.js 5.0.5: let url = "http://localhost:8545"; const provider = new ethers.providers.JsonRpcProvider(url); const signer = ...
0
votes
0answers
532 views

web3-react does not appear to be exposing Ethers.js instance

I've configured the web3-react package in my project (set up with the React Truffle box) but I don't seem to be getting an ethers.js instance in the context. According to the package page, the web3-...
0
votes
0answers
246 views

Call function in contract deployed in etherjs

Here is the code I used to call setValue and getValue in contract Hello.sol deployed with etherjs 5.0: import { ContractFactory, ethers } from "ethers"; let contract_at_address = new ...
0
votes
0answers
138 views

Truffle returns no code at address after contract update

etherjs (5.0) is used to deployed a smart contract Hello.sol. Here is the js code (truffle 5.1.52/ganache CLI 6.12.1): import { ContractFactory, ethers } from "ethers"; let privateKey = ...
0
votes
0answers
59 views

A public node URL which can take connection of ethers.js in React Native app

I just installed ethers.js in my React Native 0.63 app and would like to conduct brief checks to see if the lib is up and running. What I need is to have a Ethereum node URL as there is no Metamask or ...
2
votes
1answer
325 views

How to construct a raw Ethereum transaction from transaction data

Let's say I have the following transaction information: { "jsonrpc":"2.0" "id":0 "result":{ "blockHash":"...
0
votes
1answer
421 views

Signing a request with a signature gives the wrong from address

I am using ethers to get a signed request. I have a signature for the address 0x518171C334AD3adc1cF990A884D67963201B675F. It is, ...
0
votes
1answer
427 views

How to make this interact with metamask

I've been trying to make my contract be callable by metamask (so a popup will occur telling the user to confirm) but it does not seem to work, heres what I have come up with so far. Can anyone give me ...
0
votes
0answers
510 views

Web3 library to use with Laravel [duplicate]

Is there some library like web3.js or ethers.js but in PHP to use with Laravel? (Which code is hopefully maintained) Or is PHP just the strongest choice possible I want to work with web3?
0
votes
1answer
199 views

What is the ethersjs equivalent of `web3.eth.call` in web3js?

web3.js has the ability to call a transaction and get return data without sending a transaction: web3.eth.call(callObject [, defaultBlock] [, callback]) ethersjs apparently does not have this ...
0
votes
2answers
458 views

Ethers.js: Call constant method with await does not work [closed]

If I try to get the result of a constant function call with: let gameCountAwait = await contract.getGameEntry(0); it fails with: Uncaught SyntaxError: await is only valid in async function ...
1
vote
0answers
102 views

Meta transaction using ethers.js

How can I implement a meta transaction using ethers.js library. My transaction is to transfer 100 tokens from 0xAccountA to 0xAccountB. The transaction will be signed by 0xAccountA but the gas ...
0
votes
2answers
107 views

How to set different signer and gas payer for a single transaction

I am trying to make a transaction of DAI tokens from user wallet 0xDAIUserWallet to some random token contract say 0xRandomContractAddress. In this scenario I am using the private key of DAI User to ...
0
votes
1answer
2k views

Ethers js estimate gas offline?

Looking here in the docs it mentions I need to have the provider attached to estimate gas. But for formatting a transaction offline, I dont have access to the provider. Is there a way to estimate the ...