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

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

How to use web3.js@1.0.0-beta34 with TypeScript?

Here is a minimal code for testing: import * as Web3 from "web3" const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545")) const main = async () => { const blockNumber = ...
7
votes
0answers
930 views

web3 websocket connection prevents node process from exiting

I have a node js process that creates a web3 websocket connection, like so: web3 = new Web3('ws://localhost:7545') When the process completes, it does not exit, but rather hangs forever with no ...
7
votes
1answer
344 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 ...
7
votes
1answer
2k views

Error: etherbase address must be explicitly specified

When I make a RPC to geth running remotely, I cannot get the account list / balance of the account. It also says that the coinbase is not set. But as far as I know, isnt the coinbase supposed to be ...
6
votes
1answer
1k views

Adding Wallet using web3.eth.accounts.wallet.add

On web3 0.20.1, I am using Infura to deploy a contract to Rinkeby. This probably requires me to add a wallet to web3.accounts to provide the gas needed. When I ran the following nodejs code, Web3 = ...
6
votes
1answer
684 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....
5
votes
1answer
423 views

Connecting to remote Geth client from AWS hosted server via web3 needs fix

There is a general problem that is affecting most everyone who tries to initialize AWS hosted servers with a remote Geth instance. It would be great to have documentation to address a fix or at least ...
5
votes
1answer
351 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 ...
5
votes
1answer
224 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; } ...
4
votes
2answers
400 views

How to exchange ETH to DAI with web3 and node.js

I looking for solution how to convert eth to dai with web3 api. something like https://kyber.network/swap/eth_knc (I can send eth to specyfic contract adress and I receive back DAI to the same ...
4
votes
0answers
376 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 ...
4
votes
1answer
194 views

DEVp2p Wire Protocol tutorial on geth or Web3.js/Web3.py

I was looking to develop an application using ÐΞVp2p Wire Protocol and I'm having trouble finding an example or tutorial. I was able to find only ÐΞVp2p Wire Protocol's wiki. [Q] Does anybody has a ...
4
votes
0answers
498 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 (...
4
votes
2answers
2k views

Web3js - “The returned value is not a convertible string”

Can someone please help me. While trying to invoke a constant function which returns string, I am getting "Promise RejectedError: ERROR: The returned value is not a convertible string:" ...
4
votes
0answers
222 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 ...
4
votes
1answer
673 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 ...
4
votes
2answers
576 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 │   │   └── ...
4
votes
0answers
283 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; // &...
4
votes
0answers
2k 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( '...
4
votes
0answers
386 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 ...
3
votes
1answer
51 views
+50

signed message different on opera and metamask

I am using the following code to sign a message: web3.currentProvider.sendAsync( { jsonrpc: '2.0', id: 1, method: 'personal_sign', params: [ `My account is ${this.accounts[0]}`...
3
votes
2answers
31 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 ...
3
votes
1answer
34 views

GUI miners for Private Ethereum Blockchain

I have setup a multinode private Ethereum blockchain with geth. I am using geth miner (miner.start(thread) at geth console) for mining blocks but my other nodes users want to use GUI miner instead of ...
3
votes
0answers
68 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 ...
3
votes
3answers
387 views

web3.eth.Contract(abi, address) doesn't return contract instance

i'am trying to make a instance of my contract in js using web3, but when I use the function web3.eth.Contract(abi, address) the result is not the expected(I take the ABI from remix). this is the code:...
3
votes
0answers
171 views

Why can't I fetch my Metamask account address with Next.js's getInitialProps?

I'm using Next.js to implement server-side rendering in my Ethereum app, however I can't fetch my Metamask address to display it in the top-right corner of the navigation bar in my index.js file. ...
3
votes
0answers
115 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 ...
3
votes
0answers
160 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 ...
3
votes
0answers
98 views

Quorum :- metamask do not support privateFor feature of quorum

i got to know that metamask do not support privateFor because of which private transaction for quorum dapp was not behaving as expected. so, I can't use metamask for my quorum DApp to switch port and ...
3
votes
0answers
141 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 ...
3
votes
0answers
504 views

NetworkError when attempting to fetch resource. Resource URL: moz-extension://2…/contentscript.js Source Map URL: ../sourcemaps/contentscript.js.map

I get the following error message in Firefox Developer Tools Console following a successful sendTransaction: "Source map error: TypeError: NetworkError when attempting to fetch resource. ...
3
votes
1answer
187 views

Create Accounts Using Web3.js in Browser

TL;DR - Replicated Ethereum Blockchain. Running Local Node. Connecting Local Node to Web3.js in browser using RPC. Want to create addresses & send transactions Details - I have a blockchain that ...
3
votes
1answer
458 views

Recover address from signature using web3j

I have signed a data string using the following code snippet in web3js var data = "hello world"; web3.personal.sign(web3.fromUtf8(data), web3.eth.accounts[0], function(error, result) { if (!...
3
votes
0answers
248 views

Error:new bignumber() not a base 16 number

I have built a private chain with two node on two computer. The smart contract was successfully deployed on node1,and i can call the method on node1 ,but when i call the same method on node2,it occur ...
3
votes
1answer
608 views

ERC223 Token Fallback Function Usage

I'm currently writing the "Trade" smart contract which is similar to "Crowdsale" smart contract. The only function that I want to add is "sell" function. In general Crowdsale smart contract is used ...
3
votes
1answer
630 views

Ropsten infura test network + web3 js event listener

I have deployed contracts on ropsten test network. truffle.js ropsten: { provider: function() { return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/<api-token>") }, ...
3
votes
2answers
1k views

Invalid address error

I keep getting Error: Invalid address when trying to run the application. My current setup of web3 using infura node is if (typeof web3 !== 'undefined') { web3 = new Web3(web3.currentProvider); } ...
3
votes
1answer
1k views

Cannot use 'new' with an expression whose type lacks a call or construct signature

A issue in the this.web3 = new Web3(window.web3.currentProvider);the web3.js has output and I type to the code of console.log(window.web3.currentProvider)that window.web3.currentProvider is defined. ...
3
votes
0answers
2k views

How to send transaction with web3.eth.sendTransaction?

I am sending ether by using web3.eth.sendTransaction. But when I send, there is error: Failed to check for transaction receipt: web3.eth.sendTransaction({ from: base_address, to: withdrawer, ...
3
votes
0answers
170 views

Geth - Events not working/firing

I have an API (expressjs - nodejs) listening for different events from my contract. var web3 = new Web3(new Web3.providers.WebsocketProvider("ws://localhost:8546")); var tokenContract = new web3.eth....
3
votes
0answers
339 views

Passing Web3 & Contracts Between Components - React Redux & MetaMask

Curious what's the best way to access and pass a web3 contract instance provided by MetaMask between components when using react-redux. At this point, I'm tempted to do the following for both web3 ...
3
votes
0answers
74 views

SQL syntax error near `logsBloom` when call web3.eth.sendTransaction

When I am trying to call web3.eth.sendTransaction I receive this error stack: Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ...
3
votes
1answer
240 views

Infinite gas estimate for empty contract

I am trying to deploy a contract with web3, and always get an error Error: exceeds block gas limit, even for correct or empty contract code. Actually, gasEstimates always throws : Error: gas required ...
3
votes
0answers
519 views

web3.eth.getBalance(address) throws an error: Invalid JSON RPC response: “”

var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); web3.eth.getBalance(address) throws an error: Invalid JSON RPC response: "" while address is some existing valid ...
3
votes
0answers
45 views

What are the requirements for contributing a pull request to the Ethereum web3.js repository?

I would like to make a pull request to the web3.js repository (https://github.com/ethereum/web3.js). Are there any requirements, guidelines, etc. I haven't been able to find any information regarding ...
3
votes
3answers
2k 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 ...
3
votes
0answers
451 views

Remote Web3 connection to Parity node running on AWS

I have an Amazon EC2 instance set up running a Parity node. I'm trying to communicate with it via Web3 (using Nethereum.Web3 in C#). If I connect locally with http://127.0.0.1:8545, everything works ...
3
votes
1answer
835 views

SendSignedTransaction web3 v1.0 method call stack underflow

When calling sendSignedTransaction I got: VM Exception while processing transaction: stack underflow Used code is below, using TESTRPC: const serializeTx = async (contractInstance, publicKey, ...
3
votes
0answers
52 views

What RPC APIs are safe to expose?

What RPC APIs are safe to expose (make public, so accessible by anyone), and what are the unsafe ones, and why? I've read: are there "public" ethereum nodes? or any recommendations on ...
3
votes
1answer
404 views

Cannot make subscribe newBlockHeaders work

I'm doing this to get all blocks from the network: var web3 = new Web3(); web3.setProvider(new Web3.providers.IpcProvider("...", net)); web3.eth.subscribe('newBlockHeaders', function (err, result) { ...