Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

0
votes
2answers
14 views

Integration of smart contact with frontend using web3js

I had been long searching methods fro integration my smart contract with my frontend. Then I came across web3.js but couldn't find any specific method is to how this system is working.
0
votes
0answers
11 views

Sign a transaction locally and send it

I'm using Infura as my web3 provider, and have MetaMask installed to connect to the blockchain. I'm trying to send a transaction, but have learned that Infura is read-only, and doesn't support the ...
0
votes
1answer
16 views

How to add actual Ether to custom token

I built a token by creating a smart contract for it, and have successfully connected to it, which is on a Ethereum test-net. Using web3.js I have been able to send token from one account to another ...
2
votes
0answers
16 views

Using web3.js, how can I get a TX hash before sending?

I'm using web3.eth.accounts.signTransaction() to obtain a rawTransaction, but I also need the transaction hash. calling web3.eth.sendSignedTransaction() will give me the hash, but I need to get it ...
0
votes
0answers
15 views

Web3.js in Docker: invalid JSON-RPC response: undefined

Recently I've made a container out of my app, which used to work fine in a normal environment with an infura node. This is the code that's causing problems inside of the Docker container. I'm new to ...
0
votes
1answer
17 views

Contract deployment using web3.eth.contract(abi) with constructor arguments

I'm trying to deploy the following smart contract: pragma solidity ^0.5.00; contract TestContract { address public owner; string public word; constructor(string memory _word) public{ ...
0
votes
0answers
7 views

How to use web3.bzz with PoA network?

I'm trying to use web3.bzz with a poa network but I always get this error : invalid content type, only application/json is supported this the code: const file = fs.readFileSync("file.json"); web3....
0
votes
0answers
12 views

What is the role of the Geth ipc socket in a web3.js connection?

I started Geth as a root and try to run node.js with the rights of the group www-data. When node connects to Geth all is fine but transactions throw ... (node:27824) UnhandledPromiseRejectionWarning: ...
0
votes
0answers
11 views

How to generate Ethereum accounts using Web3 Python on Ropsten?

Just wanted to know how to use web3.py to generate Ethereum accounts. I tried using ropsten.infura.io/v3/<KEY> as an HTTPProvider, but it does not allows to create me account
1
vote
1answer
30 views

How to call contract functions using web3?

I have deployed my contract in private blockchain, now I am calling functions using Nodejs and web3. Here, I want to transfer tokens for which I need to unlock my account from which I am transferring ...
0
votes
1answer
15 views

Is geth account new and web3.eth.accounts.create the same?

For creating a new account, are these 2 commands the same or different? geth account new and web3.eth.accounts.create.
0
votes
1answer
14 views

How can I access a contract's fallback function via 'myContract.methods'?

Web3.js documentation says here that the methods of a smart contract are available through: The name: myContract.methods.myMethod The name with parameters: myContract.methods['myMethod(uint256)'] The ...
1
vote
1answer
24 views

Getting all past events in web3JS

I have seen similar questions here, but the answers didn't help so far. I have a JS function in a React component that should parse all the past events of the contract. The function is invoked in ...
2
votes
2answers
28 views

Which version of solidity works web3js [on hold]

In what version of solidity do I have to write my smart contracts if I want to interact with Web3.js
0
votes
2answers
18 views

ERC721 Error: invalid number value arg=“_tokenId”, coderType=“uint256”, value=

MyERC721: pragma solidity ^0.5.0; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol"; import "openzeppelin-solidity/...
0
votes
1answer
15 views

Unable to sign a message on geth Console

I have two accounts on my geth node . The geth node is syncing with the Ropsten testnet . I executed the following commands personal.unlockAccount(eth.accounts[1],'Test'); The result was true After ...
0
votes
1answer
24 views

React: Please pass numbers as strings or BigNumber objects to avoid precision errors

Here is my onSubmit function: onSubmitModifyAllocation = async event => { event.preventDefault(); const accounts = await web3.eth.getAccounts(); await fund.methods.modifyAllocation(this....
0
votes
0answers
15 views

CORS Error for using infura

I need to call the balance function from my smart contract using my application and i don't want to use metamask and other web3 providers like infua as I am not going to send any transactions and don'...
0
votes
2answers
17 views

uint showing in hexadecimal in console

Simple issue but couldn't find solution. When I run a console to interact with a function that returns uint in a smart contract, it shows in hexadecimal notation. Like this: <BN: a> (meaning ...
0
votes
1answer
18 views

How to Serialize/Deserialize array of bytes?

I'm writing a smart contract and inevitably need to have arrays of bytes as input and output of functions. In remix arrays work just fine but with web3j and web3js there are several issues with arrays ...
1
vote
0answers
24 views

Developer related changes to prepare for Ethereum hard fork - Constantinople

I am hosting my own ethereum node using geth and I have some simple dApps which make use of the web3.js library. I went through various documentations related to the hard fork, more specifically this ...
0
votes
0answers
13 views

How to search all blocks in ethereum blockchain of a particular public key?

How to search all blocks in ethereum blockchain of a particular public key? And explore all data inside them.
1
vote
2answers
39 views

Difference between web3.eth.getCoinbase() and web3.eth.getAccounts()[0]

What is the difference between web3.eth.getCoinbase() and web3.eth.getAccounts()[0]. In both cases, I always get the value, which is the currently selected account in Metamask. Note: The question ...
1
vote
1answer
24 views

Script with web3.eth.getAccounts() never ends

I have a little script just with the following function: const Web3 = require('web3'); var web3Provider = new Web3(new Web3.providers.WebsocketProvider('ws://127.0.0.1:3001')); const web3 = new Web3(...
0
votes
1answer
30 views

How to apply EthFilter to specific address?

In web3.js, we can apply event filter something like below: this.event = this.Contract.events.MyEvent({ filter: { address: "0xAccountAddress" }, }) In Web3J, it is translated to EthFilter ...
0
votes
1answer
34 views

Contract.methods.transfer is a not a function error using web3

Running something simple as this: Contract = new web3.eth.Contract(this.contractABI, this.contractAddress) Contract.methods.transfer(toAccount.address, transfferAmount).encodeABI() Gives me ...
1
vote
1answer
17 views

Scope in events in web3 1.0 [closed]

Inside the callback of an event, how do I get the scope outside the function? Specifically, in the following scenario, I want the web3 object: (using truffle-contracts and web3 1.0 here) ... const ...
0
votes
2answers
25 views

web3 send signed transaction to smart contract

I have some basic questions about web3. Is it common to send transactions to the smart contract address when calling methods in the smart contract or should I send them to another wallet? When ...
0
votes
1answer
19 views

Web3 event listener not reacting to emitter

I'm writing a program in JS/Node that, amongst other things, subscribes to a smart contract event waiting for it to happen. There's a lot going on on the code, so I've got it separated. The main ...
0
votes
1answer
24 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
1answer
25 views

Error: Please pass numbers as strings or BigNumber objects to avoid precision errors

let result = await instance.joinQuiz({ from: accounts[1], value: web3.utils.toWei(10, "wei") });
0
votes
1answer
16 views

Doubt with ethereum-input-data-decoder when decoding a variable uint256

the input data of the variable uint256 is "22092018" but when using ethereum-input-data-decoder I return "BN: 15118f2". Instead of getting "BN: 15118f2" with the decoder, have the original value of ...
0
votes
0answers
18 views

How to find out if a transaction was successful in javascript?

I want to do a transaction from my website to a private blockchain and inform the user after the transaction is done. This is my code so far: const web3 = new Web3(new Web3.providers.HttpProvider("...
1
vote
2answers
20 views

Encode constructor arguments used when deploying a contract

How can I encode the constructor arguments when deploying a contract? Here is my deployment function: async function deploy(abi, bin, args) { let contract = new this.web3.eth.Contract(JSON.parse(...
0
votes
0answers
14 views

how to export that web3.admin api in external java Script code web3.admin api doesn't work in external JavaScript code

I'm trying to interact with a private blockchain from JavaScript code. For that I've provided an RPC address to each node and extended multiple apis using -rpcapi. Now if I'm using geth attach http://...
0
votes
0answers
22 views

how to web3's admin and miner api in node.js code [on hold]

How we can export web3.js's amdin and miner block in node.js code by to interact with the ethereum private blockchain in console
2
votes
1answer
34 views

Can't access test network's accounts

So I've updated my framework and with it the web3,js lib. When I run the console and attempt to get an account from my test network by web3.eth.accounts, it won't display a list of the accounts like ...
2
votes
1answer
20 views

Is it possible that Ganache can handle a private key without an “0x” prefix, but Parity cannot?

I am trying to sign and send a transaction as follows: let signedTx = await web3.eth.accounts.signTransaction(options, PRIVATE_KEY); let txReceipt = await web3.eth.sendSignedTransaction(signedTx....
0
votes
2answers
19 views

i am trying to send ether to a list of addresses from backend

Below are few lines from the contract in which I am basically trying to send some ether to an array of addresses. Now, when can run this code in remix solidity by replacing "value" to "msg.value". But ...
0
votes
0answers
28 views

What is use of absolute Path on Json file of a Smart Contract?

What is the use of absolutePath on JSON artifact of a Smart Contract? Does this mean we need the .sol file on the same server where web3.js apis are running? { "absolutePath": "/home/hashcode01/...
0
votes
2answers
27 views

Get creator from contract address

How can I get the creator's address of a contract? I'm using truffle, so usually I do let instance = await VM.instance() and then get the contract's address via instance.address Then, how can I ...
1
vote
1answer
28 views

Using web3 estimateGas API (with infura) always returns the last block's gas limit

I am entirely unsure what the root cause is, but every time I use web3.eth.estimateGas with my call's parameters, it results in the last blocks gas limit as the result (~8 million). I have even tested ...
0
votes
2answers
18 views

Web3 js APIs Installation Requirements

If I am using Infura Node interact with smart contracts. And I want to build/setup web3 apis on a ubuntu machine on AWS. Do i need to install truffle on that machine or just node.js and web3 is enough?...
1
vote
1answer
23 views

How can I retrieve the constructor arguments used during contract deployment

I know how to extract the constructor arguments out of the transaction object returned from a contract-deployment operation. It is explain in web3.js official documentation here. But this is not an ...
0
votes
1answer
36 views

How does Ethereum Smart Contract work on Mobile Client

I want to deploy a smart contract on server and interact with it using mobile client. I'm not familiar with how does that work but after some research, I found something like below: If we compare ...
0
votes
1answer
28 views

Trying to send ether to multiple addresses

Trying to send ether to multiple addresses. For the first address the transaction succeeded but for the rest of the addresses it is showing "transaction underpriced". Below is the code attached. I ...
0
votes
1answer
29 views

How to get private key with web3 v0.2.x?

web3 version 1.x has the decrypt method, which decrypts a keystore v3 JSON. By using it the following way, I can get the private key easily: web3.eth.accounts.decrypt(keystoreJsonV3, password); But ...
0
votes
1answer
15 views

CORS Issue when using RPC with 2 docker containers

I currently have a setup with two docker containers. The first container, peerA, has a private ethereum network running a single node. The second container, web-app, has a web application that uses ...
1
vote
0answers
16 views

geth console - web3.isConnected function and not a function?

I am trying to find out if my node is connected. So I attach geth via geth attach in another terminal. But if I run web3.isConnected it returns function(). But when I run it as a function web3....
1
vote
2answers
40 views

Pass specific address in Web3J send method

How to pass specific address in send method in Web3J? For example, using web3 javascript library, we can pass from address like below. contract.someMethod().send({ from: this.props.accounts[0] }) ...