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,219 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
1 answer
1k 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 ...
user avatar
6 votes
0 answers
843 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 = ..., ...
user avatar
  • 1,077
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( '...
user avatar
  • 4,180
6 votes
1 answer
841 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....
user avatar
5 votes
1 answer
283 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? ...
user avatar
  • 888
5 votes
0 answers
3k 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://...
user avatar
5 votes
2 answers
4k views

sign transaction in web3 with metamask

I'm trying to make a signed transaction in browser with web3 injected from metamask and send the transaction to my backend-server and then submit it to blockchain. However, it's hard to find how I can ...
user avatar
  • 53
5 votes
0 answers
616 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 ...
user avatar
  • 151
5 votes
0 answers
937 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; ...
user avatar
  • 149
5 votes
0 answers
506 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 ...
user avatar
  • 51
5 votes
1 answer
712 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 ...
user avatar
5 votes
1 answer
952 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 ...
user avatar
  • 51
5 votes
1 answer
1k views

Call write function, which doesn't change contract value

I'm new in smart contracts and faced with one problem. After deploying contract to my test local blockchain network, i try to set new value via setter, after that I call get method of contract and it ...
user avatar
  • 61
5 votes
2 answers
615 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 ...
user avatar
5 votes
1 answer
259 views

web3.eth.compile.solidity(source) throws me Invalid JSON RPC response

I am relatively new to Blockchains and when I execute the following command I am getting an error. contract mortal { address owner; function mortal() { owner = msg.sender; } ...
user avatar
4 votes
0 answers
455 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 ...
user avatar
  • 297
4 votes
0 answers
680 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 ...
user avatar
4 votes
0 answers
3k 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 ...
user avatar
  • 360
4 votes
0 answers
792 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 ...
user avatar
  • 167
4 votes
0 answers
11k 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 ...
user avatar
  • 545
4 votes
0 answers
415 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 ...
user avatar
  • 108
4 votes
0 answers
132 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.
user avatar
  • 423
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 ...
user avatar
  • 395
4 votes
0 answers
247 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/...
user avatar
4 votes
0 answers
325 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 ...
user avatar
  • 362
4 votes
0 answers
302 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 ...
user avatar
  • 71
4 votes
1 answer
854 views

How can I retrieve transaction hashes using web3 batch requests?

When I send a transaction using Truffle's contract wrappers - or using plain web3 sendTransaction() - I get a tx hash back that I can use to confirm the tx has completed. While using batch requests (...
user avatar
4 votes
0 answers
91 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 ?
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 ...
user avatar
4 votes
0 answers
254 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 ...
user avatar
4 votes
2 answers
1k 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 ...
user avatar
  • 51
4 votes
2 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 │   │   └── ...
user avatar
  • 831
4 votes
0 answers
385 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; // &...
user avatar
4 votes
0 answers
414 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 ...
user avatar
  • 544
3 votes
0 answers
1k 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 ...
user avatar
3 votes
4 answers
871 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 ...
user avatar
3 votes
0 answers
162 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 ...
user avatar
3 votes
0 answers
819 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):...
user avatar
3 votes
0 answers
825 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....
user avatar
  • 133
3 votes
0 answers
1k views

How to create a wallet with web3.js

From what I understand, a wallet is a smart contract and in order to create a wallet, you need to deploy the contract to the blockchain as stated here, which is different from creating accounts. When ...
user avatar
  • 617
3 votes
0 answers
696 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 ...
user avatar
  • 651
3 votes
2 answers
6k views

How to generate solidity encode function signature from Javascript?

What I am trying to achieve is like , i should be able to call a set of solidity functions dynamically based on some criteria. i'm using call() method to achieve the same. (bool success, bytes memory ...
user avatar
3 votes
0 answers
548 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! ...
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: ...
user avatar
  • 297
3 votes
1 answer
1k views

how can i translate the ethers.js "getSigner" utility to web3?

I have a web3 object but I'm working off an example that uses ethersProvider.getSigner(). Is there an equivalent (or mostly equivalent) in the web3 library? For reference, the ethersProvider is ...
user avatar
  • 363
3 votes
2 answers
133 views

Auction contract problem regarding highest bid display

I have an Auction contract which has a function like this: function bid() payable{ //calculate and store highest bid value } But because each transaction takes time to mine, so when a user bids ...
user avatar
  • 31
3 votes
1 answer
86 views

What is the best way to push transactions with hight rate (>1000 per second)?

In order to test the throughput of a private Ethereum, I need to send multiple transactions as fast as possible. Can web3js ensures fast delivery of transactions? or there is an other more efficient ...
user avatar
3 votes
0 answers
135 views

Invalid JSON RPC response on IOS build with Infura

I am developing a mobile DAPP using ionic frame work, everything was fine when I testing on the browser. However I try to build my app on IOS, and run it on my Iphone7, the web3 doesn't work(did't ...
user avatar
  • 31
3 votes
1 answer
89 views

Most efficient way to get all non-zero storage locations for a smart contract?

I'm looking at a mainnet smart contract and want to figure out all storage positions/slots where the storage has a non-zero value. Is there a way to do this other than replaying and tracing all ...
user avatar
  • 885
3 votes
0 answers
479 views

using events in private blockchain raises leveldb not found error

i'm getting { [Error: Node error: {"code":-32000,"message":"leveldb: not found"}] when trying to use events on a private eth blockhain. What might be the problem? (I've installed Leveldb with brew) ...
user avatar

1
2 3 4 5
45