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,315 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
0answers
993 views

Passing a bytes32 as a parameter from web3, returns invalid opcode

When I deploy the solidity contract and make the tests with mocha, the result of a function that receives a bytes32 parameter works fine. But, when I make the same with web3 in order to make the ...
0
votes
1answer
519 views

Why is the units of gasUsed in the transaction receipt 10^11 Wei?

I'm checking the balance of an account after a payable transaction in a Truffle test. Below is my code: // amount is the value supplied to the txn assert.equal(Number(String(currentBalance)), ...
0
votes
1answer
317 views

Factory Contract Function is not creating New Contract using testrpc and web3

I am new to DApp development. I have deployed a TokenFactory contract and that Factory contract has a function "Create New Token" that generates a new token contract. The function "Create New Token" ...
0
votes
0answers
42 views

Couldn't interact with a “complex” Smart Contract in a private network through Web3.js, however, could interact with Remix

I've developed a UI in Visual Studio. The UI is a simple HTML with some CSS and also, Javascript code. To interact with my Ethereum Private Network, I've included the web3.min.js. Firts of all, I've ...
0
votes
0answers
1k views

.new isn't a function when deploying contract (web3)

I'm trying to deploy contracts using Ganache but I'm getting the following error. I have my ABI and contract address defined, all other functions with respect to interacting with the contract work, ...
0
votes
0answers
18 views

Contracts, Total Sold, Total sold in US

I need to find out how to: Connect web3 to the smart contract that contains the TOKEN token via a ethereum node URL running parity, and use getter function on this contract to obtain the 'total sold' ...
0
votes
1answer
708 views

Fetching all the accounts from Genache

I'm using Ganache to generate dummy accounts but every time I try to access the list of accounts using web3.eth.accounts or the web3.eth.getAccounts method, I only get access to the first account in ...
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
336 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
169 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
374 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
254 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
477 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
157 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
437 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
72 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
565 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
222 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
373 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
475 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
245 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
298 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
620 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
319 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
531 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
586 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
236 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
295 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
165 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
438 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
533 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
235 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
691 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
0answers
456 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
836 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 ...