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

Filter by
Sorted by
Tagged with
15
votes
2answers
6k views

To which remote ethereum nodes does Metamask plugin send signed transactions? and are they exposed to denial of service attacks?

So Metamask allows in it UI to connect to different ethereum nw (public/ testnet) right. Do who is maintaining these peers? Can I trust these peers?. If so, can I setup similar service on my machine ...
3
votes
3answers
12k views

How can the web3 library be imported in a web application?

During the compilation of my JS code I used the statement Web3 = require('web3') for importing the web3 library. But since the require function doesn't work in a web application, I would like to know ...
19
votes
3answers
12k views

What does the Web3 “BigNumber not a base 16 number Error” mean

Is there a known problem with parsing events containing strings in Truffle/Web3? I'm using truffle with the following simple contract contract Board { string foo; event Shout(); event ...
4
votes
2answers
4k views

Private key needed or not for sending transaction in ethereum

In web3 APIs I could not see an option to specify private key for sending a transaction in doc. How this is done then ? My understanding is that we need private key of a particular account to send ...
13
votes
2answers
1k views

Can Solidity constant functions be arbitrarily complex?

Non-constant functions are limited in computational complexity by the block gas limit. I assume, but am not sure, that this does not apply to constant functions. Are constant functions in any way ...
7
votes
5answers
6k views

Trying to connect Mist/Ethereum wallet with testrpc

I need someone who can explain to me, step by step, in simple terms how can I connect the ethereum wallet with the local blockchain. I found the following link: Connect Mist to ethereum-js testrpc ...
7
votes
4answers
2k views

Optimal way of waiting for transactions to be mined in geth

I'm currently checking if a transaction has been mined using the following function (using web3.js): function waitForTx(tx_hash) { var result = null; // This is not really efficient ...
5
votes
2answers
5k views

Ethereum tokens and decimals

What is the best way to deal with decimals as I create a currency? Let's use an example. I have KARLCOIN (KARL), and I have 1,000,000 of them, and the token has 6 decimals places. This token will ...
17
votes
1answer
5k views

Passing an array as a parameter from javascrpt (web3) to a Solidity function

I have the following Solidity function: function func(bytes32[2] data) external { bytes32 x; bytes32 y; x = data[0]; y = data[1]; } I'm trying to call it from ...
6
votes
1answer
1k views

How to get all ethereum address list which have my token?

I want a list of all ethereum address which have my ERC20 token in their account. Anyone have an idea how to get list address. beause i want give divided to each account which have my ERC20 token.
3
votes
4answers
861 views

How to detect from web3 if method exists on a deployed contract?

Suppose a contract has been deployed and I don't have its source code or ABI. From web3, I would like to know if the contract has a method with a given signature. (An example application would be a ...
0
votes
1answer
2k views

Mistake when using web3.eth.filter() and filter.get()

I went to the website https://etherscan.io/txs?block=4067373 and with that information choose the following address (third in line) to test on: 0x25f000254108a104A7127B5a5697cb3C12643e62 And the ...
1
vote
1answer
918 views

How to add available accounts at infura HttpProvider

I launch web3 at nodejs server,not in explorer(no MetaMask). const END_POINT = 'http://localhost:8545'; web3 = new Web3(new Web3.providers.HttpProvider(END_POINT)); web3.eth.getAccounts() .then((...
26
votes
3answers
20k views

How can I view event logs for an ethereum contract?

After reading the this post, it seems like I should be able to access the logs of events that have been called on an Ethereum contract. The section I am interested in is Option 3 which is using event ...
13
votes
1answer
2k views

Looking for a working Whisper example

I was looking to develop an application using Whisper & NodeJS and I'm having trouble finding an example that works and is updated. I've encountered this doc web3js.readthedocs.io/en/1.0/web3-shh....
26
votes
9answers
38k views

How to get private key from account address and password?

What I have 1. I am able to create new account with personal.newAccount() method of web3 api. 2. I am working on my private blockchain. 3. geth node start with following command:- geth --datadir ~/...
10
votes
2answers
21k views

How to calculate transaction fee?

For calculating transaction fee (from web3), need to use gas price at that moment eth.getTransaction("txhash").gasPrice and multiply actually on how much gas was used eth.getTransactionReceipt(...
8
votes
1answer
13k views

Error: Invalid JSON RPC response: undefined from node web3.js app

I'm getting Error: Invalid JSON RPC response: undefined from my node.js application when it tries to execute a function. My steps: ethereum wallet 0.5.1 to deploy a contract to the testnet. start the ...
8
votes
4answers
2k views

web3.eth.getStorageAt for mapping

How can I get contract mapping storage? Considering this simple contract contract Currency{ mapping(address=>uint) public balances; function deposit(){ balances[tx.origin]++; } } ...
5
votes
1answer
3k views

What is the 0x I see around Ethereum? For example I see addresses that start with 0x

I see a number of things in Ethereum start with 0x, for example addresses. Other examples are in the Geth console, JSON-RPC, web3.js. What is the 0x and what is its purpose?
2
votes
1answer
1k views

Add user details to smart Contract

What is the best way to store users data on smart contract? Suppose we have n number of users and we want to store each username and his other details, should we have to create a smart contract ...
6
votes
1answer
5k views

Send signed transaction web3

Trying to send a transaction with web3 on ropsten. The code runs on Remix, but now I'm trying to send it via the node console. It connects fine too(web3 works), but for some reason the transaction ...
5
votes
1answer
3k views

Interaction with a deployed smart contract from the geth command line

I have a contract which I'd like to be able to sum numbers submitted by any other address: contract UnitCounter { mapping (address => uint256) public UnitsFrom; uint256 public TotalUnits; ...
4
votes
3answers
3k views

do I need to use ws provider in order to watch events?

I am using web3 version 1.0 version 26, however I can't receive any events from ganache-cli and testrpc. this.Contract.events.Created({},{ fromBlock: 0, toBlock: 'latest' }, function(error, event){...
3
votes
3answers
2k views

How to verify MetaMask account holder is the real owner of the address?

I'm making a dapp that will make calls to a Node.js server. I expect the user to have MetaMask installed and I want to verify that he is the real owner of the current address on MetaMask (i.e. ...
11
votes
3answers
6k views

Truffle invalid address

With Truffle 3.0 when I call one of my contract's function, in console I have this error: Uncaught (in promise) Error: invalid address I found this workaround, and in my code I try this with no ...
9
votes
2answers
4k views

How to connect a web site to a geth node?

Before the DApp-browser Mist was available, this web3 library seems the way to go on building a bridge from contract to a frontend (web site). But, I cannot get the very basic examples to work. ...
1
vote
1answer
2k views

Set watch for ethereum address transaction using web3js

I want to set watch for my public address. So i can get all transaction for that address. My code is: var filter = web3.eth.filter({ address: ["0x2A7146700BCe4A574eE36D5e9cd6CF7d8871aEB6"] }); ...
19
votes
6answers
29k views

Insufficient funds for gas * price + value

Sending Address has over 1 Eth in current Balance. Using the Geth console, I can send many transactions of any amount less than .033 eth.sendTransaction({to:'...
7
votes
3answers
8k views

How to check currently installed web3 version?

How to check installed web3 version with command line terminal?
6
votes
1answer
2k views

Passing ether with call to Solidity function

I have deployed a contract to testnet which appears to function. I have a function named contribute which gets the ether from the msg.value. The function is below and doesn't take any arguments. I ...
5
votes
3answers
3k views

Automatically update account balance with web3.js without polling

I've made a user interface in JavaScript with web3.js where the user can select an account to use. The accounts are displayed together with their current balance for convenience. I load the account ...
4
votes
2answers
4k views

Get Transaction Hash And Mined Receipt

I am trying to figure out how to send a transaction to a contract method, retrieve the transaction hash automatically, and then get a receipt callback after the transaction is mined. I am able to do ...
3
votes
2answers
955 views

Connection Error - Couldn't connect to ethereum node on AWS at http://xx.xxx.xx.xxx:8545

We setup ethereum node on AWS Ubuntu Server 16.04 LTS (HVM) EC2 instance and configured it in the standard way before launching the geth console using the below command: sudo geth --identity "...
3
votes
1answer
4k views

Web3 sending custom tokens by using the transfer function. Need to set the from account

Looking to code WEB3 to be able to send custom tokens out programmatically. However, I am not sure where to specify the user account that actually sends the token. This is the code I have thus far. ...
2
votes
1answer
340 views

sendTransaction from iPhone app

How do I call sendTransaction from within an iPhone app? I was thinking of running a web to Geth proxy where the iPhone app would call the Api exposed by the proxy which in turn calls my self hosted ...
2
votes
1answer
934 views

Asynchronously querying the block chain

This question is related to this one or this one. There is a tutorial here that shows some filtering examples but it doesn't get into transaction level granularity. Can we query the block chain by ...
1
vote
1answer
7k views

How to use web3 to send money from wallet A to wallet B?

var myContract = web3.eth.contract(abi); var address = contract address; var contract_data = myContract.at(address); var sender = '0xd3aaa525c087978133abb517593ea334f16abd1f'; var receiver = '...
7
votes
1answer
1k views

Event result parameters and arguments in console

I read about using events from this source http://solidity.readthedocs.io/en/latest/contracts.html#events I used a simple multiply contract: contract test1{ uint a; event event_res(string msg,...
5
votes
1answer
2k views

Getting a contract by address only (without ABI definition)

Is it possible to get a contract only by its address without the ABI definition? I'm experimenting with ethereum in a private network through the web3.js client console. The problem is that any ...
2
votes
2answers
2k views

Query multiple smart contracts' public data

I have a smart contract that holds the details of a person. Each new person gets a new smart contract that they 'own'. I have a regulator/ admin who wants to see the number of such smart contracts ...
2
votes
1answer
4k views

The MetaMask Web3 object does not support synchronous methods like personal_newAccount without a callback parameter

im using web3j with angular 5 connection working perfectly and balance showing perfectly. but when i write transfer function it throw error var tx = this._web3.eth.sendTransaction({ from: this....
2
votes
2answers
413 views

How to execute a time based transaction? Here's my sample contract

pragma solidity ^0.4.0; contract Test { uint[] timestamp; function setTime(uint _timeToset) public returns(bool) { timestamp.push(now + _timeToset); return true; } function ...
2
votes
2answers
882 views

How to receive ether in wallet address and forward to another address on successful deposit?

I want to implement a feature in which users will send ether to wallet address(0x123) and on successful deposit, it needs to automatically transfer to my cold wallet(0x983). I can able to achieve ...
0
votes
2answers
350 views

How to call this solidity function with Web3js when executing the contract?

I’m new with ethereum. I’m definitely struggling with the last 4 parameter of this function, so I’m asking the problem directly. mapping(address => uint256) nonces; /* * Proxy transfer token. ...
14
votes
6answers
24k views

How to get transactions by account using web3 js?

I'm sure this question was asked before, but I did not find any result that helped my problem. How can I get the transactions (in and out) for a given account? I use nodejs and web3? With this line ...
27
votes
2answers
8k views

web3.js execution - server vs browser

I'm a little bit far from web development, so I have one misunderstanding. As far as a know, node.js code should be run at server side and web3.js is designed to work at server side (not sure), ...
10
votes
1answer
4k views

What is the difference between web3.eth.sign, web3.eth.accounts.sign, web3.eth.personal.sign functions?

Which function should be used to sign message locally? Which function is the most secure?
21
votes
2answers
11k views

Get a peer list for my geth node

How can I use Geth (or any other client) to get a list of my peer nodes on the Ethereum network. I see there's a function to get the number of nodes using the web3 api, but I need a list of node IDs ...
16
votes
2answers
6k views

web3.eth.sendRawTransaction: cannot unmarshal hex string without 0x prefix

When I call sendRawTransaction, I got "[Error: invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go value of type hexutil.Bytes]" I think all of params have "0x" ...