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,293
questions with no upvoted or accepted answers
8
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 = ...
8
votes
1answer
501 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 ...
6
votes
2answers
785 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 ...
6
votes
1answer
739 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
319 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 ...
5
votes
1answer
881 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 ...
5
votes
2answers
432 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
0answers
3k 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(
'...
5
votes
1answer
238 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
0answers
238 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 ...
4
votes
0answers
377 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 = ...,
...
4
votes
0answers
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 ...
4
votes
1answer
893 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 (!...
4
votes
0answers
510 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
235 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
1answer
3k 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. ...
4
votes
0answers
580 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
0answers
79 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 ?
4
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 ...
4
votes
0answers
227 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
2answers
669 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 ...
4
votes
2answers
784 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
323 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
393 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
0answers
109 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;
...
3
votes
2answers
70 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
61 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 ...
3
votes
0answers
1k 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 ...
3
votes
0answers
100 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
0answers
339 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
243 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
1answer
174 views
Web3JS incorrect return value
When I return a string array with web3 I don't get the original array as expected, but rather I get an array of the same size, with the index off by one.
So instead of ["One","Two","Three"] I get ["",...
3
votes
0answers
140 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
927 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
266 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
451 views
Retrieve event args from getPastLogs
When we use web3.eth.getPastLogs it returns topic and data properties together with rest data. Does it possible to retrieve event args parsing just data and topic as filter? Without to make additional ...
3
votes
0answers
94 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.
3
votes
2answers
400 views
How can we compile multiple smart contracts by compile.js file?
My compile.js file is below
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const ballotPath = path.resolve(__dirname, 'contracts', 'blocktitans_ballot.sol');
...
3
votes
0answers
269 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
850 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
2answers
801 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
2answers
23k views
TypeError: Cannot read property 'then' of undefined
I am having an error with Web3. After going through all possibilities I decided to post a question hoping for someone with a solution.
The error I keep getting is:
TypeError: Cannot read property '...
3
votes
0answers
928 views
contract.method.getData getData is undefined
When I use contract.method.getData(params) it throws an error
getData is undefined. I searched on github and saw someone used request
instead, and I used contract.method.request and it has successed! ...
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
197 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
85 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
2answers
264 views
Issue with autonomous contract calling erc20 token's transferFrom for approved amount
Trying to transfer fund using ERC20 token handle and calling 'transferFrom'. Assume that the specific amount is preapproved by owner account for 'MyContract' contract address.
contract StandardToken {...
3
votes
0answers
569 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
46 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 ...