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
2
votes
3answers
265 views

Event firing before data is actually set

Let's say this is my smartcontract: event NewUser( address userAddress, uint amount ); function addUser() public payable{ require(msg.value <= maxValue && msg.value > ...
2
votes
0answers
693 views

What can I do about an “Invalid sender” contract deployment error?

When deploying a smart contract, I get this message: "Error: invalid sender undefined." See details below. Why is this happening? What do I need to do differently? I wrote the smart contract below ...
2
votes
3answers
2k views

Are there ropsten ERC20 testnet tokens?

I am trying to write an application using web3.js and I want to integrate some ERC20 functionality. But rather than muddy up the mainnet, I'd like to try things on the Testnet first. I see that https:/...
1
vote
0answers
247 views

Error: CONNECTION ERROR: Couldn't connect to node (RPC & web3.js)

I am trying to access my Geth node through RPC from my UI (using web3.js) My Geth command is: geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcaddr 'localhost' --rpcport 8501 --...
1
vote
1answer
484 views

Transaction receipt contains all log entries, but only the last two are decoded by web3

I have a flow which yields 4 events. When I obtain the transaction hash via web3.js, I can see that all 4 events are included in the receipt logs, but only the last 2 events are in the decoded logs (...
1
vote
2answers
446 views

Following web3.js docs raises TypeError: .once is not a function

I deployed a contract which has a function recordData(bizname, id) function. I have a expressjs api layer. I want to make sure that when the function is called from this api layer using web3 the ...
1
vote
5answers
1k views

How to invoke functions of Smart Contract from Android phone?

I deployed a smart contract with solidity along with a GUI by Javascript and HTML. This project works well on my computer. Now I want to invoke functions of Smart Contract from Android phone. Is ...
1
vote
1answer
335 views

How to bundle own web3 version and using Metamask

I am a bit of a javascript noob and have some questions about using web3js and Metamask. My objective (for now) is to display the ether balance as displayed on my Metamask (where I am logged in). ...
1
vote
1answer
568 views

getting error web3.toWei is not a function when testing

i have installed web3 latest version 1.0.0-beta.36. i am using helper libraries which i used from openzeppelin when i am running the test cases using truffle test it shows error as TypeError: web3....
1
vote
1answer
1k views

How to connect web3js to mainnet or testnet?

It might be a very basic question. But here's what I want to achieve: I want to make a web app which interacts with a contract on testnet/mainnet. I can see in the documentation that you have to ...
1
vote
1answer
1k views

Web3.js enabled mobile browsers and wallets

What mobile browsers or wallets there exist with proper web3.js support?
1
vote
2answers
1k views

How to catch JSON RPC exception in front end web3

I have a transaction in contract which "requires" only owner can call. In front end when I call this with accounts other than owner of the contract I want to display an error. Code below doesn't work....
1
vote
2answers
855 views

How to call my contract's function using sendRawTransaction?

I am trying to call my contract's method using sendRawTransaction. I have a function in my contract updateReading(address consumerAddress, uint32 consumerMeterId, uint64 ...
0
votes
2answers
1k views

Unable to connect to metamask using web3

I have tried everything but just can't get the web3.currentProvider to work. I have metamask installed and working and somehow want to connect the website on the test network. Has there been some ...
0
votes
1answer
444 views

“Updated :” How to see “output” of “web3.personal.sign” in “browser”? (“Method personal_sign not supported”)

Note: I updated the html / JavaScript code according to the answer and I used THIS META MASK sample code for web3 provider. However, I receive the same error. I eventually did not understand that do I ...
0
votes
3answers
366 views

Dapp not conecting (through web3) when called from browser which dont have node running on it

trying to connect dapp through browser,when doing the same through the browser on machine which has running geth node is getting connect through public ip (eg :http175.xxx.xxx.xx:xxxxlogin) but the ...
0
votes
1answer
265 views

Fetching single account from web3.eth

I'm trying to fetch the first account using web3.eth.accounts[0] using Truffle, but couldn't seem to make it work. I'm using version 0.5.0. I read that the command is deprecated and have to use web3....
0
votes
0answers
80 views

Are there any libraries/tools for encoding input for data field of web3.eth.call method? [duplicate]

You can call contract functions using web3.eth.call method. Information on which function to call and what arguments to pass to this function is encoded according to the rules that can be found here. ...
13
votes
5answers
9k views

web3.js with promisified API

I'd like to take away the pain from web3 development callback hell and use Promise pattern and async/await keywords on both client side and on Node.js. Do there exist any web3.js builds or forks that ...
6
votes
4answers
9k views

How to transfer ERC20 tokens using web3js

I've read some docs, run parity in docker container, and being able to connect and get token balance of an account const Web3 = require('web3'), const web3 = new Web3(new Web3.providers.HttpProvider('...
21
votes
2answers
2k views

What are best practices for serving a DApp over HTTPS, connecting to an Ethereum node using JSON RPC / web3.js, which by default uses HTTP?

Summary: we're serving an Ethereum DApp from a webserver through HTTPS. The DApp connects to an Ethereum node through JSON RPC using web3.js, which uses HTTP (not HTTPS). How to deal with this in a ...
16
votes
2answers
9k views

Connecting to hosted web3 provider from NodeJS backend

I'm using these instructions from etherchain. Here's a similar question(seems like duplicate, but it's not). The solution provided there doesn't work for me, because I don't have a local ethereum ...
11
votes
1answer
5k views

Error: personal_unlockAccount method not implemented

Using web3 under nodejs I suddenly want to unlock my account before calling a DAO contract function: var Web3 = require('./node_modules/web3/lib/web3'); // dont override global variable if (typeof ...
11
votes
2answers
6k views

trying to use web3-utils but not working

Trying to use web3-utils. I installed the package via NPM , however, I am getting the error that sha3 is undefined.. TypeError: Cannot read property 'sha3' of undefined at C:\block2\deliver.js:...
7
votes
2answers
3k views

How to manipulate data in a Solidity smart contract?

I have a smart contract with some members which should get modified on certain events. For simplicity, let's imagine we have a greeter contract. If I call greeter.greet() in the JavaScript console, ...
15
votes
3answers
7k views

Using web3 to sign a transaction without connecting to geth

Is it possible to use the web3.js library in a client's browser to let them generate an address and sign a transaction without them connecting to an ethereum node?
9
votes
1answer
1k views

How to check if a transaction is still in the blockchain?

Say we want to confirm that a value transaction tx has reached certain finality, which we define as waiting for 12 block confirmations. We do this to drop the probability of tx getting lost due a fork ...
8
votes
2answers
2k views

Call an arbitrary JSON-RPC method with web3

I want to use web3 to call evm_snapshot (only available on testrpc). This is not in web3's list of methods, but I don't want to have to make an actual http call.
7
votes
3answers
8k views

What is the correct way to access public variable from contract in Truffle: then or standard callback?

There are some similar posts to this but none seem to be able to solve my problem. I have a contract deployed with Truffle running with testrpc. I want to access the value of a public uint variable ...
7
votes
2answers
2k views

Unhandled rejection Error: Couldn't decode uint256 from ABI

I am working on using a sample Contract using NodeJS, Web3, and Solc but I encountered some error that the given address in the Contract that I've created couldn't decode. Am I doing something wrong? ...
7
votes
2answers
6k views

How can I connect to public chain using web3?

I have used web3 to interact with my private chain by using : web3.setProvider(new web3.providers.HttpProvider("http://localhost:8012")); But How can I connect to Public Network using web3? I am ...
7
votes
1answer
3k views

Executing custom JavaScript Snippets through Non-Interactive console (geth --exec)

I have a JavaScript snippet to get the latest transaction to/from an account. After starting the geth instance, I did this in the interactive JS console: jsFunction is a function in filename.js &...
5
votes
2answers
2k views

how to parse the Ethereum Blockchain and save the output to a file? geth console isn't node, right?

I'm trying to parse the Blockchain and extract to a txt file part of the transactions and Addresses to a specific contract (theDAO) for later analysis. I'd like to save the output to a file (.txt) in ...
5
votes
2answers
5k views

Send transaction using MetaMask injected web 3

Metamasks injected web3 gives an error when using web3.eth.sendTransaction() web3.eth.sendTransaction({from:web3.eth.accounts[0], to:'', data: // hash to interact with contraact, gas:85000}); What ...
4
votes
2answers
2k views

Unlocking accounts for a back office app

I'm writing a "back office" app and need a way to unlock an account in an automated fashion. Yes, I know security of nodejs is questionable, but there are ways of solving this. blocking web3 from ...
4
votes
6answers
2k views

How many concurrent requests can an Ethereum node handle?

This is a fairly simple question which (I suspect) has a more complex answer. I would like to find out that answer now rather than the hard way down the line. How many concurrent requests can an ...
3
votes
1answer
7k views

geth transactions stuck in pending, resend fails

I sent 115 transactions with geth, and they are stuck in pending for over an hour. Etherscan doesn't recognize them. I try to resend, and get a confusing error. Some details from geth console: > ...
3
votes
0answers
1k views

web3 filter option not working

var filter = web3.eth.filter({fromBlock: 350000, toBlock: 'latest',address:"0x075da4ebae466b80d451b0627296d5d38b3e99c1"}); var myResults1 = filter.watch(function (error, log) { console.log(error);...
2
votes
1answer
991 views

Node script to sweep accounts

I have a rather large list of accounts (HD wallets) I want to sweep into one. They've all been imported into geth, and all have the same password. I wrote a script to do this in node but get this ...
1
vote
1answer
7k views

How to make transactions using private key in web3? [duplicate]

I have account private key, contract address and abi and I need to call contract function with this account. Is it possible?
1
vote
2answers
3k views

encode data input of the raw transaction to update an contract function? [duplicate]

I need to update a contract by calling one of their function but I cant use web3.js so I need to send a raw transaction. example of function to be call on the contract: test(address buyer, uint256 ...
1
vote
1answer
2k views

How to map a web3 to a react.js state

How would you map a changing variable from web3 to react.js component? Example: class App extends Component { constructor(props){ super(props); this.state = { blockNumber: web3.eth....
17
votes
4answers
10k views

'Error: base fee exceeds gas limit' When creating new contract instance (Using Truffle, Web3Js and testrpc)

I have the following code in app.js file of my truffle project. import { default as Web3} from 'web3'; import { default as contract } from 'truffle-contract' import conferrence_artifacts from '../../...
16
votes
4answers
18k views

Invalid JSON RPC response: undefined, when running web3.eth.accounts (Node)

I'm very new Ethereum and trying to follow this tutorial: https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2 But when I run: web3.eth.accounts I ...
13
votes
9answers
15k views

Invalid Address Error when interacting with a smart contract with metamask

I want to call the methods with metamask of this simple contract: contract AssetPrices { mapping (uint => uint) public prices; uint public data; function EnterPrice(uint _time, uint _price){...
10
votes
2answers
1k views

Programmatically saving the contract address of a submitted contract

I understand how the below web3js code block works, adapted from here: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethcontract But how does one save the contract address ...
10
votes
2answers
607 views

Is there a tool that creates a basic HTML interface from an ABI?

I am looking for a tool that builds a basic interface for a contract so that I can use this generated HTML as a starting point to build the front end. I am aware that Mist, https://chriseth.github.io/...
9
votes
1answer
1k views

Is it safe to publicly host a parity node?

In the normal use case, Parity runs on localhost. However, I'm building a demo web site that uses Web3JS to connect to a public parity node running on port 8545. I am publicly serving a Node/VueJS ...
9
votes
3answers
9k views

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

Deployed a contract using Remix IDE to Rinkeby testnet. Etherscan contract address and code is here. contract SimpleCounter { int counter; constructor() public { counter = 0; } ...
9
votes
3answers
3k views

Deploy contract on EthereumJS TestRPC

Following https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2 I've tried to create an instance of a contract using: VotingContract = web3.eth....