Questions tagged [web3js]

Javascript API and library for Ethereum To develop applications on Ethereum, you can use the web3 object provided by the web3.js library. Under the hood it communicates to a local node through RPC calls. web3.js works with any Ethereum node, which exposes an RPC layer. https://github.com/ethereum/wiki/wiki/JavaScript-API

2,095 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9 votes
1 answer
1k views

How to use Nodejs/LevelUp to read Blocks from local LevelDb database files (.ldb)?

Here's what I've been able to get going to far. I can open the blockchain database but I can't seem to create a valid blockchain object (nor call the blockchain.getBlock() function successfully). I'...
Michael Herman's user avatar
9 votes
1 answer
2k views

getting started with geth and ENS commands: Error: invalid address

I'm starting from square zero, sorry. I'm just trying to get a javascript console up and running so that I can learn more about ENS: http://docs.ens.domains/en/latest/userguide.html#resolving I've ...
Pointy Haired Boss's user avatar
7 votes
2 answers
1k views

Unit testing a Solidity Library function with a struct memory argument

I am trying to unit test a Solidity Library contract function using truffle and web3. My simplified Library contract looks like this: pragma solidity >=0.5.16; pragma experimental ABIEncoderV2; ...
dionyziz's user avatar
  • 168
7 votes
1 answer
1k views

How to Catch Connection Issues to Web3 Provider using Web3.js

My node.js script is able to successfully connect to the Web3 provider when both the private key (using truffle-privatekey-provider) and the provider host URL are correct. let privateKey = ..., ...
Nyxynyx's user avatar
  • 1,167
6 votes
0 answers
4k views

Can gas price and amount of gas be automatically set by metamask, or are they required to be set via code in web3.js (EIP-1559)?

I am using web3.eth.Contract to deploy a smart contract to the ropsten testnet. To interact with metamask I am using window.ethereum. I deploy the contract via the code below that I found on https://...
Slaven Tojić's user avatar
6 votes
0 answers
1k views

Why does Ethereum use JSON-RPC and not gRPC?

I am fairly new to networking protocols especially JSON-RPC and gRPC as they are not nearly as common in web development as REST. I was reading around and seems like gRPC generally performs better. So ...
RhinoBomb's user avatar
  • 161
6 votes
0 answers
1k views

How to get ethereumjs-abi's soliditySHA3 and web3 sign equivalents in ethersjs?

Hello I'd like to create a hash using ethersjs that encodes a number of arguments. I previously used ethereumjs-abi's soliditySHA3 function but not sure which of ethersjs crypto utilities is the ...
Alejandro's user avatar
  • 187
6 votes
0 answers
551 views

Truffle test of two transactions during the same block

I'm trying to test a solidity function that only allows it to be called once per block. E.g. (my desired functionality): Tx1 calls Fn during block #100, and when successful sets a boolean flag for ...
jonnyg's user avatar
  • 61
6 votes
2 answers
2k views

Web3 Event Filtering timeout

This is the code I use to get all events from a certain contract. Solidity: event NewEvent(address indexed contractAddress, address newBOPAddress, address payer, uint commitThreshold, bool ...
Gigi's user avatar
  • 71
6 votes
2 answers
652 views

How to access dynamic list from web3?

In my application players can create and join games. I store every game in a mapping(uint => Game), and send out a GameCreated event whenever a game is created. My issue is efficiently getting a list ...
Warkgnall's user avatar
  • 106
6 votes
0 answers
5k views

Use of web3.js batch requests

The web3.js API allows for synchronous RPC batch requests with the example given as: var batch = web3.createBatch(); batch.add(web3.eth.getBalance.request( '...
o0ragman0o's user avatar
  • 4,300
6 votes
1 answer
882 views

Problem with start() in web3-provider-engine

While trying to connect to a provider(infura) I get the above error below is the full stack trace: bundle.js:54318 Uncaught TypeError: this.provider.sendAsync is not a function at Web3Subprovider....
coderwithattitude's user avatar
5 votes
1 answer
594 views

Does anything change on getGasPrice( ) in Web3js after EIP-1559?

Using getGasPrice in web3js returns the last few blocks median gas price. After EIP-1559, the fees system is divided into Base + Tip. My question is, what is returned using getGasPrice after EIP1559? ...
sigmaxf's user avatar
  • 1,070
5 votes
0 answers
2k views

How to convert my metamask private key into 32 bytes hexa

How to convert my metamask private key into 32 bytes hexa ? i am using web3 to start trading on pancake but when i try to convert my bsc metamask phrase keys into hexa is like 150 bytes but require ...
Usama Khan's user avatar
5 votes
0 answers
648 views

How to continuesly fork mainnet on latest block

How do I keep the fork mainnet use the latest block using web3? I need to fork mainnet to latest block before I send the transaction What originally i do is just run the ganache fork command which ...
Marr's user avatar
  • 327
5 votes
0 answers
984 views

How to mimic abi.encodeWithSignature in web3?

I have the following function that I would like to test. function createPlanet(bytes memory _data) public returns (address) { emit ProxyCreated(planetImplementation); emit ...
James Dawson's user avatar
5 votes
0 answers
4k views

Contract call: data out of bounds

I'm working on a nextjs/react project in which i want to fetch the health factor of an address on AAVE. This can be done by calling getUserAcountData(address) on the lending pool contract. I can ...
Conviley's user avatar
  • 380
5 votes
1 answer
818 views

Can't debug transactions that fail during the Web3.js estimateGas() call? No Tx Hash

NOTE: I am doing my work with the Ganache v1.2.2 GUI client on a Linux Ubuntu 18.04 station. There are many revert errors that happen during the estimateGas() call that precedes the actual Web3.js ...
Robert Oschler's user avatar
5 votes
0 answers
151 views

Retrieve MetaMask version in web3.js

Is there a way to determine the version of the currently installed MetaMask extension from web3.js? I can't find it by inspecting the Web3 instance.
pors's user avatar
  • 433
5 votes
1 answer
1k views

web3.eth.getBlock returns null

I have a very similar problem as https://github.com/paritytech/parity-ethereum/issues/8788 When I use web3.eth.getBlock for the first 1 million and latest 50,000 blocks (approximately), I get the ...
Gab's user avatar
  • 51
4 votes
0 answers
506 views

GETH node maxpeers performance and benefit

I'm trying to optimize my node for transaction propagation speed. Expanding on this question: Can we improve the performance of Geth server by setting maxpeers to 0? Are there any data available ...
ceds's user avatar
  • 245
4 votes
0 answers
12k views

Get RPC URL / IP of Metamask's current provider

Suppose I have multiple copies of the same dapp running on different servers which do not directly communicate with each other, for testing purposes, and can manually interact with different dapp ...
WBT's user avatar
  • 565
4 votes
0 answers
500 views

How to access txpool pending transactions using Netherum?

I want to get list of transactions which are in pending state & queued state in txpool. I can see these transactions in pool using txpool.inspect command. I tried code given in nethereum sample ...
Vinayak M's user avatar
  • 108
4 votes
0 answers
2k views

Mining hangs on Generating DAG in progress

I am trying to initialize rpc using the below command and start miner using miner.start(1); geth --rpcapi eth,web3,personal --rpc --networkid=15 Mining starts successfully with below logs but it ...
Alien's user avatar
  • 415
4 votes
1 answer
269 views

Estimated gas is always low

web3.eth.estimateGas is always calculating low gas for the transaction. Here is a reference to a trasaction in ropsten. https://ropsten.etherscan.io/tx/...
ToniyaSundaram's user avatar
4 votes
0 answers
494 views

Is it possible to see the event log when using eth_call?

I want to perform a transaction locally (with the call method in web3 which perform a eth_call RPC call). It returns only the return value of the function called and I want to see the event log. I ...
Harold's user avatar
  • 362
4 votes
1 answer
393 views

Web3 js events not listening after 5 mins of idle time

My contract is deployed on ropsten infura test-network and that contract has events which gets fired when there is some transaction. contract file function functionName(address from, address ...
Kapil's user avatar
  • 71
4 votes
0 answers
98 views

How to do a disaster recovery in private chains?

How can I do a disaster recovery on a private chain running ethereum, say for instance Quorum ?
NaN's user avatar
  • 194
4 votes
3 answers
3k views

Correctly deploying contracts with web3 1.0 and testrpc (invalid opcode error)

I followed the following tutorial: https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2 Now this tutorial is not using the recent version of web3 but ...
Etherhacker's user avatar
4 votes
0 answers
277 views

how to get revert at the previous timestamp of evm in testrpc

I am testing my contracts so at some point i need to increase the timestamp of evm that i achieve through evm_timeIncrease but now i want to execute some functions on the basis of current timestamp ...
Satyam Agrawal's user avatar
4 votes
3 answers
1k views

Importing a contract from another contract in NodeJS app

I'm using a function in my NodeJS app to deploy contracts. The user inputs the contract he wishes to deploy and the app deploys it. The structure of the app is . ├── app │   ├── models │   │   └── ...
mcansado's user avatar
  • 841
4 votes
0 answers
413 views

Contract execution fails with Web3 but works with Remix

I am dealing with a very simple smart contract: contract MyRegistry { struct MyEvent { string date; // yyyy/mm/dd string desc; // potentially long string uint count; // &...
user197675's user avatar
4 votes
0 answers
417 views

How to create my own wallet and own blockchain explorer?

I'm running my own private/permissioned ethereum blockchain via geth on Ubuntu. How can i interact with my blockchain to visualize accounts, blocks, transactions etc...? I've tried a lot of tutorials ...
Borinho's user avatar
  • 544
3 votes
1 answer
50 views

Smart Contract/Nextjs Error: Returned values aren't valid, did it run Out of Gas?

I'm having an error while calling one of the function of the deployed contract from Next.js Error: Parameter decoding error: Returned values aren't valid, did it run Out of Gas? You might also see ...
Mohsin's user avatar
  • 31
3 votes
1 answer
2k views

How to pass bytes parameter to contract method call using Web3.js?

I'm trying to call a method in a contract and the method is like this: function myMethod(uint8 tid, bytes calldata _bytes) public view returns (string memory) { ... } I'm using Web3.js to ...
Farzad Z's user avatar
3 votes
2 answers
633 views

NodeJs & Web3 having problem with VS Code IntelliSense (autocomplete)

I'm having issue with autocomplete of Web3 module members in the VS Code. As can be noticed on the screen below web3.eth. not proposing any member of the module. web3 module has been installed over ...
mattaspen's user avatar
3 votes
0 answers
806 views

Incompatible EIP155-based V 1 and chain id 1

It's my first question here so please don't be so strict. I have such a scenario: I start learning how blockchain works, downloaded truffle, ganache cli, created an account on infura and all that ...
AGJoYy's user avatar
  • 386
3 votes
4 answers
1k views

I keep getting nonce is too low when using truffle to call functions on contracts even though this works fine on remix.How can I fix this

I keep getting the nonce is too low when running functions with sub transactions on the kovan test net is there a way I can stop this from happening?these sub transactions are making transactions with ...
Matthew Pinnock's user avatar
3 votes
0 answers
836 views

tx fee (5274661132.35 ether) exceeds the configured cap (1.00 ether) Web3 JS

New to web3 JS. using Binance Smart Chain (mainnet) :( I am getting this error: tx fee (5274661132.35 ether) exceeds the configured cap (1.00 ether) Below are my parameters (done on php for some ...
Haren Sarma's user avatar
3 votes
0 answers
194 views

What's the type (always 0x0) field of a transaction about?

Using web3 you can get all transaction of a block web3.eth.getBlock: const web3 = new Web3(provider); const currentBlockNumber = await web3.eth.getBlockNumber() // true means that transactions should ...
ysfaran's user avatar
  • 131
3 votes
0 answers
422 views

How can I do contract call transaction from Metamask qr code scan?

I have a payable function in the smart contract that takes some ether from the sender and does some tasks. I want to generate QR code for this contract call transaction so that user can scan and ...
Abishek Bashyal's user avatar
3 votes
0 answers
1k views

What reason? "Unhandled Rejection (Error): replacement fee too low "

I am going to swap two BSC tokens using etherjs. I sent approval for a transaction and then I sent a swap transaction. I am using a Pancakeswap v2 router. I had this error. Unhandled Rejection (Error):...
Alex Weber's user avatar
3 votes
1 answer
3k views

How to send correct SwapExactEthForTokens params types on ethers/web3.js?

I need to know how to send correct paramaters / paramater types as in what does the parameter type has to be is it a hex number , a string ? help would be massively appreciated. Notes: 1)i cant set ...
Aaron Klich's user avatar
3 votes
1 answer
1k views

web3 subscribe to pendingTransactions for a given contract?

Is it possible to only subscribe to a specific contract for pendingtransactions using web3.eth.subscribe? The docs dont show any parameters besides a callback function, so the result shows all pending ...
Chris S's user avatar
  • 161
3 votes
0 answers
1k views

Gas limit too low when using transaction data field

I am using web3.js to send a transaction. This is the code that I have currently: async function sendTx(tran, ethAddress, privateKey, value=0) { var tr = { chainId: await web3.eth....
Mark's user avatar
  • 133
3 votes
1 answer
2k views

How to get a list of all token holders using ethers.js + metamask

Is there any way, using ethers.js and metamask, to build an array of all current token holders? I would need this to my project which I'm currently working at. I know I can download the entire ...
Radek_pl's user avatar
  • 761
3 votes
0 answers
723 views

geth javascript console: web3.eth.subscribe ==> "Object has no member 'subscribe'"

I must be missing something -- I am trying to use the web3.eth.subscribe() function in my geth node's javascript console and there is no subscribe function. Welcome to the Geth JavaScript console! ...
Randal Ramig's user avatar
3 votes
0 answers
2k views

Swap tokens to Ether on Uniswap V2 TRANSFER_FROM_FAILED

I am trying to swap DAI to ETH on kovan testnet my wallet and contract both have DAI tokens. Whenever I swap the token through web3 the transaction fails Fail with error 'TransferHelper: ...
Marr's user avatar
  • 327
3 votes
0 answers
733 views

How can I handle the UniswapV2: LOCKED revert reason when calling swapETHForExactTokens on the Uniswap router2 contract

I have forked the eth mainnet onto my local machine using ganache cli and am trying to call the UNISWAP router2's SwapETHForExactTokens to swap eth for MEME tokens. I call the function from truffle ...
user63854's user avatar
3 votes
0 answers
788 views

How to listen for contract creation, or all block events?

I'm building a web app with web3 where users can deploy a certain contract and assign some people to it. Inside the constructor of that contract I also output a certain event. I want these assigned ...
Dzeri96's user avatar
  • 131

1
2 3 4 5
42