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
0
votes
2answers
444 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. ...
28
votes
2answers
9k 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), ...
15
votes
5answers
10k 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 ...
13
votes
2answers
7k views

What is msg.data?

Is msg.data equal to {from: addr1, data:something}? How to handle the data 'something'? when execution this code: web3.eth.sendTransaction({from: ..., to: addressOfE, data: something}); how to ...
22
votes
2answers
13k 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 ...
17
votes
2answers
7k 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" ...
14
votes
4answers
19k views

unable to connect Ethereum node even RPC port: 8545 is open

I have created my private Ethereum blockchain network. From different servers I am able to connected and added into the network as peer without any problem. The way I run my server: geth --...
13
votes
1answer
7k views

How can I verify a signature with the web3 javascript API?

Using the javascript web3 API I can create a signature like this: > web3.eth.sign(eth.coinbase, "0xdeadbeef") "...
13
votes
2answers
6k views

Convert with JS a Solidity bytes32 to a Solidity string

I have functions which are forced to return a bytes32 object, but then in my webapp I need to reconvert them to a classic string. How can I do that?
12
votes
3answers
2k views

is there an easy way to get the full state of a contract?

I'm developing a quite complex contract with many state variables of all kinds. (mappings, arrays, uint, strings, bytes, etc). For testing, it would be very useful to get a JSON (or similar) with the ...
8
votes
4answers
5k views

How to list ALL Ethereum addresses with a positive balance

Using web3 I can query the balance of any fixed account with web3.eth.getBalance. Assuming I have the entire blockchain downloaded, how can I recover the list of all addresses that have a positive ...
7
votes
2answers
1k views

Why does sendSignedTransaction return a tx hash BUT does not post to the Rinkeby network (React, Metamask, web3, infura)

I'm developing a very simple React application wherein a user clicks a button and some ether gets sent from one account to another. Currently, the onClick sendEther function crafts a proper signed ...
27
votes
7answers
27k views

web3.eth.contract is not a function when making contract

Whenever I try and make a contract, I get: web3.eth.contract is not a function I'm using this code: const path = require('path'); const fs = require('fs'); const solc = require('solc'); ...
15
votes
2answers
15k views

'authentication needed: password or unlock' Error when trying to call smart contract method via web3

I am trying to call the smart contract method (deployed on remote ethereum account) from my nodejs DAPP, and getting the following error- Error: authentication needed: password or unlock at ...
8
votes
1answer
2k views

Private chain: Extracting the “data” from an account?

I have initiated and mined a transaction between two accounts. I also included a data field in this transaction. This is just random hex data. Here is the command: eth.sendTransaction({from:...
8
votes
2answers
14k views

Getting ABI data for ERC20 tokens programatically with Web3 [duplicate]

I am just starting to dive into Web3. I am trying to display the various ERC20 token values for a given Ethereum Address. The pieces I need to do this are: Token Contract Address Token Contract ABI ...
11
votes
5answers
5k views

Web3.js : eth.sign() vs eth.accounts.sign() — producing different signatures?

I'm getting to grips with web3.js and have noticed an unusual issue with signing data. When I sign a string with the web3.eth.sign() method, I am getting a different signature than if I use web3.eth....
9
votes
1answer
2k views

Is it possible to call debug_traceTransaction from nodejs?

Following answer (https://ethereum.stackexchange.com/a/9437/4575) [ 1 ] guide us to call debug_trace through using geth: As documented in debug.traceTransaction(...), you can only access this API ...
6
votes
5answers
3k views

How to deploy contract to the Ropsten test-net using web3.js

I am newbie in solidity. I don't understand what steps I must do for deploy contract in the Ropsten test-net. This is my contract: pragma solidity ^0.4.15; import './ERC20.sol'; import './SafeMath....
4
votes
1answer
3k views

How to properly set nonce in a web3 contract invocation?

I have this code, which works: MyToken.airdrop(wallets,amounts,{ gas: 1267051, gasPrice: 2000000000, },function(err,tx){ console.log('err is %s',err) console.log('tx is %s',tx) callback(err,...
2
votes
2answers
562 views

How can I program my DApp to tell my user that their action/transaction has been confirmed?

Take an example of a voting DApp. A user clicks on a vote button, then behind the scenes the transaction containing the vote gets mined on the blockchain. The DApp then wants to alert('You have ...
21
votes
4answers
12k views

Does Web3.js have the functionality to create new accounts and unlock an account for a period of time for a series of transactions?

I want to create new accounts through my Dapp web interface and unlock a specific account so that transactions can be processed. I didn't see it in the web3.js documentation so wonder if that's on the ...
9
votes
5answers
17k views

why did it returned null after call miner.start()

> miner.start() > null before it , I had created a account like this . user1 = eth.accounts[0] "0xb62f0bae52d153365661c4e23ab1d594484e9bef"
8
votes
3answers
380 views

Method overloading conflicting with transaction object

In my contract there is a buy method with 1 argument being overloaded by a 2nd one with 2 arguments: function buy( uint id ) function buy( uint id, uint quantity ) Now I want to call the 1st method ...
8
votes
2answers
12k views

How to build a front end for dApp

I am studying about DApps and Ethereum. I did get the Solidity part but I am confused about the front-end apps. Is it possible that I use web framework like PHP Laravel/Rails for Frontend/Db ...
5
votes
1answer
711 views

How can i safely unlock an account and send transactions from a web application server using web3js?

I need a web application backend to be able to make transactions to a smart contract. In order to do this i need to send a transaction on behalf of an account that is authorized by our smart contract. ...
5
votes
1answer
2k views

Making web3.js work from node server code

I'm running a geth node on the testnet and trying to run web3.js method from my node server code. var coinbase = web3.eth.coinbase; console.log(coinbase); However, I'm getting a provider not set or ...
4
votes
2answers
4k views

web3.accounts.create() is not a function

I want to create a new account via code (Node.js), so I ran the following code, which was copy-pasted from the docs: web3.eth.accounts.create(); How ever accounts' value is an empty array, and ...
4
votes
1answer
917 views

How to get byte code from deployed contract in

I want to get the byte code of a deployed contract. How can I get it? Is there a special function in web3.js? I haven't found any.
3
votes
2answers
5k views

With web3 how would I get transaction AND function result?

I'm using testrpc, truffle, and web3 in Node. I've written my contract and pushed it to testrpc with truffle. Here's the gist of the Node code I have so far: let fs = require('fs'); let Web3 = ...
2
votes
2answers
6k views

How to login with web3 without MetaMask?

Is it possible to sign a user in web3 without MetaMask? I am trying to execute a smart contract I created and I'm using Infura to connect to the Kovan test network, but web3.eth.accounts[0] is ...
0
votes
1answer
2k views

Check for error in transaction with web3js

If you look at this transaction in etherscan.io you can see that it notes that the transaction has an error Warning! Error encountered during contract execution [Bad instruction]. Same status can be ...
0
votes
3answers
1k views

Can I mine on my private blockchain using geth with rpc?

I am using the web3 api and want to try out mining using rpc. The usual miner.start() (which is used on terminal) does not work even after including the miner api when starting geth and I get the ...
7
votes
2answers
9k views

Calling public array of structs using web3

Good day. I've got an array of structs such as: User[] public users; struct User{ uint idNum; string name; address userAddress; } And I'm trying to get the array of users with web3.js ...
7
votes
2answers
11k views

How to listen to events using Web3 v1.0?

I have a problem when listening for events from my contract. Code js : var Web3 = require('web3'); var abi = '...'; var contractAddress = '0x62e7Dd1Af52d5A08D401b1e156cC4CB1d2f89d57'; var eventName =...
6
votes
3answers
3k views

web3 methods not implemented

I'm running a geth node on the testnet and trying to run web3.js method from my node server code. Here's my code var Web3 = require("web3"); var web3 = new Web3(new Web3.providers.HttpProvider('http:...
5
votes
1answer
2k views

Get transaction id after contract function call

I'm using truffle. How can I get transaction id before it is mined? For example: contract.purchase(price).then(function(tx) { console.log("Success"); }).catch(function(e){ console.log(e); }...
4
votes
3answers
2k views

How do I determine whether the transaction is used for the contract creation?

I want to monitor Ethereum and memorise every contract published on the blockchain (basically the same thing that Etherscan does). How it is possible to do this using NodeJS & web3? How can I ...
3
votes
1answer
2k views

How to sign a send method in web3 1.0?

I have the following function and don't want to manually sign the transaction every time it's called, how would I go about setting up a way of signing this transaction with an object. I've seen ...
3
votes
1answer
929 views

How to query token transfers like etherscan.io?

Look at this. We are able to see tx, from, to, value etc... How is etherscan achieving this? I badly need this kind of functionality in my app. How can I list token transfers for a ERC20 contract? ...
3
votes
1answer
741 views

How to get byte32 similar data and return same index as ethereum wallet in web3.js?

Solidity byte32 return different value in web3, remix browser compiler and ethereum wallet In the contract, I have just added byte32 values and return it but in the web3 api, remix browser compiler ...
2
votes
1answer
776 views

Detecting a Reverted Transaction with Web3

I am using Web3 to submit transactions and it seems as though whenever a transaction is successfully mined but reverted I don't get that error on my frontend. Is there anyway to detect when the ...
2
votes
2answers
3k views

How to send transaction to Infura node using Web3?

I want to send ETH from one account to another using Web3 interface and Infura node. I have tried like below, and I got error 405(). Error: Invalid JSON RPC response: "" I test it in Rinkeby test ...
2
votes
3answers
3k views

for using web3.js it is necessary to install geth into your system

for using web3.js it is necessary to install geth into your system or it automatically connect with geth or ethereum blockchain? var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:...
1
vote
2answers
466 views

How do I implement simple JS code to deploy a compiled smart contract to ganache-cli? [closed]

Everything I've tried results in strange errors, and it's been difficult to get this working. I've been struggling with this for a while, especially having problems determining which versions of web3 ...
1
vote
2answers
825 views

Image attached to Ethereum contract (off-chain)

What I am trying to do is make some smart contracts that I am going to sell to my clients giving them ownership of those contracts. A web service using web3 will be available to retrieve some ...
1
vote
2answers
5k views

Error: Returned error: insufficient funds for gas * price + value

Im using this code to send payment from Address A to address B.. But im getting this error always. (node:18492) UnhandledPromiseRejectionWarning: Error: Returned error: insufficient funds for gas * ...
1
vote
1answer
6k views

Using web3.eth.filter

The following link describes some of how the function web3.eth.filter(...) works: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethfilter What I would like to do is get a list of the ...
0
votes
2answers
3k views

Creating new address with web3

I want my website users to have a new ethereum address after registration into my website. How is it possible with web3 to generate new ethereum address for each user of my website? Does it require ...
0
votes
1answer
51 views

How to create an interaction between a smart contract and a HTML file with Node-js?

My Truffle project is this contract that just shows Yerevan is love: pragma solidity ^0.5.12; contract TEST{ string public note="Yerevan is love"; function rep() public view returns(string memory){ ...

1 2
3
4 5
9