Stack Exchange Network

Stack Exchange network consists of 175 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
0answers
59 views

To transfer tokens using google cloud function

I am transferring token to the User's wallet when they create account. For that I am using google cloud functions. Here, on the account creation event, tokens will get transferred to the address. My ...
0
votes
1answer
26 views

How to use soliditySha3 in web3py

I have tested soliditySha3 function with web3js. var msg = web3Infura.utils.soliditySha3("transferPreSigned", mainContractAddress, recepientAddress, tokenAmountWei, transferFee, randomNounce); I ...
0
votes
1answer
12 views

How do you add miner address so that it can mint tokens?

I have ERC721 that I'm making. function mint(address to, uint256 tokenId) public onlyMinter returns (bool) { _mint(to, tokenId); return true; } How can I add an address so that it is able ...
1
vote
1answer
15 views

How to improve web3 when importing and stop doing the same task over and over again?

When using web3js, you will automatically have to make file to create an instance of that contract which you will use in your main project to interact with. For example, smartContract.js import ...
0
votes
0answers
34 views

i am trying to send a signed transaction for my solidity code but i am encounting some error can anyone suggest me the fix?

pragma solidity^0.5.0; import "./TokenSale.sol"; contract Dice{ TokenSale public tokenSale; address tokensaleaddress; struct player_details{ address pAddress; string ...
0
votes
0answers
48 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
26 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
47 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
77 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
95 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
22 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
25 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
25 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
186 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
46 views

The geth account new and web3.eth.accounts.create

The geth account new and web3.eth.accounts.create. That both function/command are same are different.To create new account.
0
votes
1answer
26 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
75 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 ...
3
votes
2answers
38 views

Which version of solidity works web3js [closed]

In what version of solidity do I have to write my smart contracts if I want to interact with Web3.js
0
votes
2answers
178 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
24 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
107 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
29 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
28 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
63 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
1answer
61 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
16 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.
2
votes
2answers
144 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
30 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
47 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
100 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
31 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
74 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
55 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
80 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
91 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
22 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
21 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
30 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(...
1
vote
0answers
16 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://...
2
votes
1answer
39 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
39 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
23 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
39 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
35 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
53 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
24 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
30 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
43 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
44 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
92 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 ...