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,261 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
1answer
389 views

web3 contract TypeError: 'apply' is not a function

I'm Trying to call the apply function on the contract ABI but I'm getting: TypeError: 'apply' is not a function at :1:1 > myContract { abi: [{ constant: false, inputs: [{...}], ...
0
votes
2answers
3k views

Contract method: Error: Provider not set or invalid

I'm building a Dapp using MetaMask. However, I'm getting an error when I try to call a method on my contract. Here's the simplified code: var web3 = new Web3(web3.currentProvider); var contract = ...
0
votes
0answers
37 views

Contract call not returning?

For some reason all my functions are able to return my calls except this one particular function. I call it using Truffle. async function asdf() { let contractInstance = await MyContract.at('0x...') ...
0
votes
1answer
179 views

adding the contract value but still not changed

I am using web3 1.0 and testrpc, The following is my contract. pragma solidity ^0.4.18; contract LocalEthereum { event Created(bytes32 _tradeHash); uint32 value = 0; function addValue() ...
0
votes
0answers
334 views

ERR_CONNECTION_REFUSED when connecting to remote node

I'm getting a ERR_CONNECTION_REFUSED error when connecting to my remote geth node with web3 = new Web3(new Web3.providers.HttpProvider("http://"+RPCIP+":"+RPCPort)); and web3.min.js which is ...
0
votes
0answers
82 views

unable to use deployed contract

I want to use a deployed contract that has been deployed through Mist using byte code. This is how I try to get the contract using a testnet: import contract from 'truffle-contract'; import Web3 ...
0
votes
1answer
163 views

Metmask injection local client standalone

It is too confusing for me. I tried everything. If I run the code in node.js with browserfy.. everything works fine. No I want to run it on my webserver. As MetaMask states it will not inject the ...
0
votes
0answers
105 views

Cannot invoke contract function from Web3js, but work when invoke via Parity

Following function work as expected and record all Events as expected when invoke via Parity client (Parity v1.9.0-20171208 unstable) function addMember(address newMember) payable public{ ...
0
votes
1answer
370 views

Error when trying to create new Solidity contract using Geth

Very new to Geth and Ethereum, and I'm just trying to create my first contract and deploy it to my private blockchain using Geth. Geth version 1.7.3 Below is my Solidity contract code: pragma ...
0
votes
1answer
1k views

Web3 sendSignedTransaction Transaction cost

I'm new to Ethereum world. I've just manage to create an example that calculates transaction fee and sends a signed transaction without a contract using Web3js library. My issue is that my test ...
0
votes
0answers
253 views

web3.personal.unlockAccount creates too many nodejs defunct processes

I am getting a lot of [nodejs] [defunct] process when run this code. Is there a way to check if an account is already unlocked or lock the account to properly close the nodejs process it starts so ...
0
votes
1answer
473 views

Default account is not reflected in Web3 instance created from injected current provider

According to the MetaMask docs the recommended way to access the web3 is by creating a new instance of the Web3 class by passing the window.web3.currentProvider, which is injected by the MetaMask ...
0
votes
1answer
155 views

Deploying with Truffle

I deployed a contract through remix and then I run the following code MyContract.deployed() .then(instance => { c = instance; return c.getCreator(); }) .then(result => { ...
0
votes
1answer
434 views

Error: Invalid address

I keep encountering an error saying invalid address. Why is this? const Web3 = require('web3'); const contract = require('truffle-contract'); const MyContract = require('../build/contracts/...
0
votes
1answer
71 views

When closing node (geth ropsten) I cannot save created accounts

I am pretty new to this. I downloaded the ropsten blockchain using a geth command line. Then, using Truffle, I created an account, but when I closed my node (ctrl - c on the geth command line) and ...
0
votes
1answer
560 views

Solidity - Ballot Example

I have this following Ballot contract: pragma solidity ^0.4.11; /// @title Voting with delegation. contract Ballot { // This declares a new complex type which will // be used for variables later. // ...
0
votes
2answers
220 views

Web wallet best practices

I'm putting together an ether/erc20 token wallet in a chrome extension but would like to follow best practices with regards to private key security. I'm using localstorage to handle login and its ...
0
votes
1answer
365 views

“Error: VM Exception while executing eth_call: invalid opcode” when accessing array

I'm trying to incorporate storage in a smart contract where participants of the contract will have their address stored in a address[] look up table participationAddressLUT. The contract initializes ...
0
votes
1answer
467 views

Accessing Web3 in trufflebox's react-auth-box

Hi I am using trufflebox boilerplate react-auth-box. Created a new component called Foo where I am trying to access the web3 object that has been mapped from Store to this.props. However the console....
0
votes
1answer
88 views

Can not see Solidity events

I can see events in a private net, but when I connect to "real" net, I can not see them. Meaning .watch(function(err, result) is never called. My theory is I am using lightning, and it probably means ...
0
votes
1answer
242 views

Trouble running node to test Web3

I'm trying to test basic web3 with node. I have testrpc running and I have the following in a javascript file: var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider("http://...
0
votes
0answers
294 views

Format of return value from a function

I have this function from a Solidity contract. SomeStruct public rr; function getRatingResult() public constant returns(bytes32) { // rr is an instance of a struct variable that has a field ...
0
votes
1answer
595 views

Smart contract external function with dynamic array of bytes32[] as argument works only from Remix

Here is my full contract's code. The reason I ask here is the function startNewBallot(). As you can see, it accepts bytes32[] dynamical array pragma solidity ^0.4.8; contract ibaVoter { struct ...
0
votes
1answer
318 views

Javascript to display multiple records from a struct

I am trying to build some Javascript using Web3js to list out nested structs. Specifically, I have designed a customer struct through a mapping. I have nested in the customer struct two additional ...
0
votes
0answers
108 views

Using modifier on view function works locally, but fails on Ropsten

Hey I'm trying to make it inconvenient to view stored data in a contract, but it seems that the function is returning null values when I add a modifier. The modifier makes sure someone is approved ...
0
votes
1answer
526 views

web3.eth.sendTransaction sending to random address

I've been trying since near 2 weeks to make my users able to deposit and send ethereum on site. I use geth mostly, and more recently web3.js. I face a very weird issue. All seems well, transaction ...
0
votes
0answers
181 views

`Error: Invalid params: invalid format.` when deploying Contract to testrpc

Tried to deploy a contract to testrpc network, but it is giving an error Error: Invalid params: invalid format.. Contract bytecode and ABI json is taken from frozeman's example. deployContract.js ...
0
votes
2answers
573 views

How to execute web3 batch js file

New to solidity programming and I discovered this today at this site: var contract = new web3.eth.Contract(abi, address); var batch = new web3.BatchRequest(); batch.add(web3.eth.getBalance.request('...
0
votes
1answer
81 views

Meteor's EthBlocks.latest.number not updating

Created a very simple Meteor app to display the current block number using ethereum:block. Problem: Even though the current block number is displayed when the page loads, it does not update both on ...
0
votes
1answer
443 views

Creating a transaction from a webform - invalid number of args

I have a HTML web page where I am feeding user entries into a smart contract that is designed to "store" the entries in transactions. I have most of the application working, but I'm having trouble ...
0
votes
1answer
233 views

Error while calling function in smart contract using nodejs?

I have deployed a contract in private blockchain using mist wallet. When I try to call the function in the smart contract using web3 api it through the below error /home/karthikeyan/Desktop/n2/...
0
votes
1answer
859 views

Meteor web3 sendTransaction - error cannot create property 'from

Hello ethereum experts, I got the following error in the Chrome's Javascript Console: ethereum_web3.js?hash=ee8d37819d18de934b202361e374522a33bbd060:3783 Uncaught TypeError: Cannot create property '...
0
votes
1answer
289 views

Local account to local node

If I create my wallet / accounts client-side with web3.eth.accounts how can I "publish" them on my local node? For example, I want to send some ether with an eth faucet to the first created account. ...
0
votes
1answer
163 views

Unable to change contract data with nodejs (web3)

I created a contract, and deployed it into my private blockchain, as you can see I use mapping and dynamically allocated array. When I am trying to add a domain by 'addDomain' method with remix web ...
0
votes
0answers
431 views

web3 angular not working in IE 11

Have a problem with web3. In the project on angular use this library. In all browsers everything is good but in ie 11 it gives an error and does not load. Error in this line const {keccak256, ...
0
votes
1answer
3k views

invalid address error on running code - solidity

Here is my code : var Web3 = require('web3'); var fs = require("fs"); var Artifactor = require("truffle-artifactor"); var provider = new Web3.providers.HttpProvider("http://localhost:8545"); var ...
0
votes
1answer
527 views

Implement Web3 and IPFS on server side (backend)

How do I implement Web3 and IPFS on the server side (backend)? I am able to implement on client-side (using web3.js and ipfs.js in HTML script tags) for localhost. However, it fails when I run the ...
0
votes
2answers
233 views

filter: logs.blockNumber = undefined

I have the following code: var filter = web3.eth.filter({ fromBlock:4076955, toBlock:"latest", address:"0x0123456789012345678901234567890123456789" }); filter.get(function(error,logs){ ...
0
votes
0answers
674 views

How to fix Web3 syntax error (“Unexpected token {”)?

On line 33717 of Web3's app.js file (in the /build folder of a truffle project) there's the following line: })[0] || {}; However, somehow this turns into the following when app.js runs when my app ...
0
votes
0answers
71 views

How to get contract adress when contract is deployed uisng other contract?

I have a smart contract with a function named, let's say, deployNewContract(..) this function takes some arguments and deployed a new contract based on the parameters. I am able to call the function ...
0
votes
1answer
606 views

pending transaction blocked on a local private node

Geth v1.6.1-stable on linux i have initialized my data localy with : geth --datadir "data" init "genesis.json" then i run geth to launch local node with very low gasPrice geth --datadir "data" --...
0
votes
0answers
453 views

We3JS get the data from a contract contained in a block

I am trying to get the data returned by a smart contract on my private blockchain using web3js. I have found this function "web.eth.getBlock" which seems to do just that but everytime I call it I get ...
0
votes
1answer
500 views

Simple event watching with testrpc - unexpected output

Working with this example, I've been attempting to utilise event watching from the web js api. Window 1 (a testrpc instance with filled account): testrpc -a 1 Window 2 geth attach rpc:http://...
0
votes
0answers
1k views

web3.eth.sendTransaction sends different messages on failure

I am using web3.js to interact with my contract. Now, I am using eth.sendTransaction, I am trying to send funds more than sender account posses. But, I am getting different error messages for the ...
0
votes
0answers
835 views

'Web3' is undefined in html javascript

I have geth installed and running and I am connected to a private network. As given in https://github.com/ethereum/web3.js, I have created a test html with jquery-3.1.1.min.js and web3.min.js and then ...
0
votes
1answer
31 views

How to signTransaction of a smart contract methods?

I have a smart contract contains this method: function addOneUser (User memory _user) public { bytes32 hash = keccak256(abi.encode(_user.name)); users[hash] = _user; } I want ...
0
votes
1answer
440 views

BigNumber Error: new BigNumber() not a base 16 number:

I'm new to Ethereum and javascript so hope someone can help me with this as none of the other answers on BigNumber help me understand why this won't work for me. I've tried converting the number to a ...
0
votes
2answers
485 views

Modify number of confirmations

By default there are 24 confirmations but I am running a testnet with just 3 miners and I would like to change this number bucause it makes not sense to have 24. I have been checking ...
0
votes
2answers
1k views

how to install web3 (1.0.0)?

I have 0.20.0 installing but not the default 1.0.0. I have Ubuntu 18.04 installed. Is any special config needed for Ubuntu 18.04 when installing web3 (1.0.0)? trevor@bridge2:~$ sudo npm install ...
0
votes
1answer
41 views

How do I access the properties of a contract xyz from an enclosing contract abc?

With respect to the following code: pragma solidity ^0.4.23; contract xyz { uint x = 0; function setX(uint pX) public { x = pX; } function getX() public view returns(uint){ ...