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

3
votes
2answers
33 views

Passing '-1' to a solidity function which takes a 'uint256' argument as input

Suppose I have: function func(uint256 x) external { ... } I would like to test this function via web3.js, with the maximum possible value of x. In a Truffle test, I have noticed that I can ...
2
votes
0answers
30 views

Why I can't use two functions with same name, but different parameters

I have a function which returns address but it gives me error if I try to read it. I'll explain by a quick example: Solidity: contract TestOneReturn { mapping(uint => uint) m_Data; ...
1
vote
0answers
18 views

Error: Cannot create instance of X; no code at address

Having a little issue. I have deployed a Mock ERC20 contract on development network like so: const ERC20Mock = artifacts.require("ERC20Mock"); module.exports = async function(deployer, network, ...
0
votes
0answers
14 views

Ethereum web3 Browser Only functions

Two of the functions of web3 - web3.eth.accounts.wallet.load - web3.eth.accounts.wallet.save Mentioned in the Doc of web3, these are browser only functions. Already tried to test these function ...
1
vote
0answers
111 views

web3.eth.getAccounts() : Cannot read property 'map' of undefined

const HDWalletProvider = require('truffle-hdwallet-provider'); const Web3 = require('web3'); const provider = new HDWalletProvider( 'passphrase', 'rinkeby.infura.io/v3/mytoken' ); const web3 = new ...
1
vote
0answers
22 views

Unable to retrieve ethereum address from the signed data

I used the web3.eth.accounts.recover method to retrieve the ethereum address but I am getting an error. Here is the code: let v = '0x' + signed_nonce.slice(130,134); let r = signed_nonce.slice(0,...
0
votes
0answers
25 views

Debugging a reverted transaction

I have two wallets: Wallet1: 0x8882528C7104e146E0500203C353C09922575385 Wallet2: 0xddCf0FeC78b5a20B9138F5DDb1357E3B60026a67 Each of them has more than 1 Ropsten ETH. Using web3js and Infura ...
1
vote
2answers
50 views

Geth Proof of Authority Implementation

I have implemented PoA on private blockchain with following genesis.json. { "config": { "chainId": 1515, "homesteadBlock": 1, "eip150Block": 2, "eip150Hash": "...
0
votes
1answer
35 views

can we pay the gas price in form of token?

can we pay the gas price in form of ERC20 token without using the ether? if ERC20 token has a value.then can we pay the gas price in form of ERC20 token.
0
votes
0answers
25 views

Web3js: How to check the progress sendSignedTransaction()?

Im using a job queue for the transactions. I need to know progress to inform the users the status of their transaction. I've just tweak this code https://github.com/ethereum/web3.js/issues/1151#...
0
votes
0answers
20 views

Unable to transfer token from one personal account to another

I have created two personal account on private blockchain with geth. This is the balance of one account web3.fromWei(eth.getBalance(eth.accounts[0]), "ether"); 100000000000 And this is of the ...
0
votes
0answers
45 views

unable to deploy contract on rinkeby network

I am trying to deploy my contract to rinkeby test network but unable to do so here is my contract code. pragma solidity ^0.4.17; contract Inbox { string public message; function Inbox(string ...
0
votes
2answers
10 views

Making a data Registry - does reading from other contract view function cost gas?

As known, reading view functions is free, but is it also free if I use it between two contract? Let's say I have a contract Registry which has mapping that stores string => uint, nextly I pay some ...
0
votes
1answer
24 views

web3 reading memory string gives error

i have declared a string variable in struct like struct test{ string testString; } I have written a function to access the variable like function getteststring(uint256 index)public ...
0
votes
1answer
21 views

Cannot see account created when using getAccounts

i have setup private blockchain on vm using geth and i have created personal account for deployment of contract on private blockchain. Now, when i try to create new account, i am able to do so but i ...
0
votes
0answers
41 views

How to use latest web3 version from metamask?

Im new to web3 and Im using following code to connect my UI to web3. // Modern dapp browsers... if (window.ethereum) { window.web3 = new Web3(ethereum); try { // ...
0
votes
0answers
23 views

Web3 vs. web3.js

Experienced iOS developer here - but very new to Ethereum Smart Contract development. I'm trying to figure out why the web3 version that gets loaded by MetaMask into my browsers when I run my app (...
0
votes
0answers
52 views

CORS policy error while connect to test-rpc

I'm trying to build my first dapp using test-rpc and web3js. I deployed a smart contract (with remix ide) to the testrpc (on linux ubuntu), when executing the following line: web3 = new Web3(new Web3....
1
vote
0answers
35 views

Web3 Version refuses to update

The official documentation of web3.js has this little commented statement saying: // in node.js use: const Web3 = require('web3'); (you can find it here: https://web3js.readthedocs.io/en/1.0/getting-...
1
vote
1answer
54 views

web3.eth.getAccounts() never resolves

I am attempting to connect the frontend of an application to a private chain through Metamask. As no web3 is injected, the following code is run const getWeb3 = () => ... ... ... ... const ...
0
votes
1answer
24 views

drizzle.contracts is empty object after creating new instance of Drizzle

After creating a new istance of Dirzzle and passing the needed options: const drizzle = new Drizzle(options); The object drizzle.contracts is an empty object instead of being an array of the ...
0
votes
1answer
41 views

Call `getPastEvents` with Drizzle raise error: “getPastEvents is not a function”

Calling getPastEvents with Drizzle will cause the exception: TypeError: this.drizzle.contracts.Contract.getPastEvents is not a function How to get all the past events in an array (in-one-shot) ...
0
votes
0answers
27 views

Get the result back of a smart contract function call using INFURA

This is the function I use to send a signed transaction using Infura to invoke a smart contrac function (see details for the params of the transaction). web3.eth.sendSignedTransaction('0x' + ...
0
votes
1answer
55 views

How To Connect Web3 With MetaMask?

No tutorial can help me, I have watched almost every major tutorial on Youtube and read a ton of results from Google... I have on my HTML file imported the web3.min.js (copied from Truffle pet-shop ...
0
votes
0answers
47 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
1answer
52 views

How to make smart contract call using INFURA and NodeJS web3js

I can not understand how I can prepare the transaction to be signed. Because INFURA does not support eth_sendTransaction but only eth_sendRawTransaction (INFURA API which then requires you to prepare ...
0
votes
0answers
13 views

Hot to debug a contract method invocation?

Running this code: PrintProofOfWork.methods.printRequested(gcodeHash).send({from: web3.eth.defaultAccount}) .then((result) => { console.log(`result of the invocation: ${...
0
votes
2answers
77 views

web3 erroneously returning error

This is strange. My web3 script to deploy a contract seems to work, but always activates the .on('error', fcn) clause even though there is no error. The message says Transaction has been reverted by ...
1
vote
0answers
28 views

Geth crashes, “missing trie node”, rlp: expected List

I am struggling with failing geth with my Dapp. I got an error like this: Web3 UnhandledPromiseRejectionWarning: Error: Returned error: missing trie node ...
0
votes
2answers
31 views

Error converting wei using promises in NodeJS

I am running this code on NodeJS application: let destinationBalanceWei = web3.eth.getBalance(process.env.DESTINATION_WALLET_ADDRESS).then(result => result.toString()) let destinationBalance = ...
0
votes
1answer
46 views

Smart Contract function keep return Null value?

Hey I am new with Solidity. And I just tried to link my front end view with the smart contract. With the simplest possible approach. My contract:- My JS code:- Console keep printing 'null' I don't ...
1
vote
0answers
17 views

Can transaction hash be used to get v, r, s parameters using web3js?

I am trying to create a function which can be used to get the v, r, s parameters (ECDSA) of the signature. So i am thinking to pass a random tx hash from etherscan and it will v,r,s parameters of the ...
0
votes
0answers
4 views

showing unknown command “API.HTTP”

For configuring CORS in IPFS config i executed command ipfs config --json API.HTTP Headers.Access-Control-Allow-Methods "[\"PUT\", \"POST\", \"GET\"]" but it giving error unknown command "API.HTTP". ...
0
votes
0answers
37 views

Web3.eth.sign() not working properly. Not sure if this is a MetaMask or Web3 problem

window.ethereum.enable() is working properly, the window pops up from MetaMask and I allow access like normal. I am also able to send transactions between two of my accounts on the test network ...
0
votes
0answers
10 views

Web3js filter, why returns many hashes

When I install filter: web3.eth.filter('latest').watch((err, res) => { if(err) { console.log(err); } else { ...
0
votes
1answer
27 views

Check when a block is mined

Is it possible to know when a block is mined? Is there any timestamp or event/subscription?
1
vote
3answers
58 views

Sign Message Using private key instead of kesytore

I need to sign data using the private key and not keystore file. I can get data using: var hash = "0x" + ethereumjs.ABI.soliditySHA3( ["address", "uint256", "uint256"], [web3.eth....
0
votes
1answer
51 views

Is there any way to get all token transfers of a specific block number?

I am looking for a way to get all erc20 token transfers with specifying block number only. For ETH there is already a way exists here. I have done some search and found this method to find transfers ...
0
votes
0answers
25 views

Understanding web3.eth.subscribe('newBlockHeaders')

I am running two nodes in a testnet. Node1 = miner and Node2 = peer of Node1 I suscribe to both nodes with web3.eth.subscribe('newBlockHeaders') since I want to obtain when a block with a ...
0
votes
0answers
26 views

Contract deployment not working anymore

So I have this following code that was working a couple of weeks ago and today I decided to run a few tests and it just doesn't do its job anymore. function approve(rid, guest_wallet, ctr_key, dti, ...
1
vote
1answer
24 views

Get a Tx hash from truffle

I have implemented a function call in truffle(web3js): await this.token1.transferFrom(holder1, holder2, transferAmount, {from: holder1}); and now I want to get the tx hash for that specific function....
0
votes
0answers
33 views

VM error in Truffle

Running the code below returns a vm error: Error: Returned error: VM Exception while processing transaction: revert at Object.ErrorResponse (node_modules/truffle/build/webpack:/~/web3-eth/~/web3-...
1
vote
1answer
21 views

eth-crypto: How can I use the library in the browser?

Has anyone manage to use eth-crypto in the browser? I tried to use browserify but I failed. Any hints, what to do? EDIT: This is what I did (node:10.15.1/npm:6.4.1) 1) Installed eth-crypto (v1.3.2))...
0
votes
0answers
29 views

TypeError: web3_eth_personal__WEBPACK_IMPORTED_MODULE_0___default.a is not a constructor

I have an application using truffle and webpack. When I run npm run server ( server's definition in package.json is : "server": "concurrently 'webpack --mode development --watch' 'wait-on build/...
0
votes
1answer
44 views

How to get result from contract function called through web3 using sendTransaction

I use the following to call a solidity contract function in nodejs(v10.14.2) + web3(v0.20.7) + ganache(v1.2.3): contract.getItemCount(function(err1,result1){ console.log(result1); } result1(...
0
votes
1answer
53 views

DeployError: Provided address is invalid,the capitalization checksum test failed,or its an indrect IBAN address which can't be converted

I have the following code: var account = web3.utils.toChecksumAddress("0x249eb..") const accounts = await web3.eth.getAccounts(); let Contr = new web3.eth.Contract(abi, {from: account, gas: 47000, ...
0
votes
0answers
61 views

Web3 is injecting but stilling getting an invalid provider error

I'm injecting web3 with MetaMask, and everything works, but when I make a production build, I notice that it injects web3 alright, but when I try to call a web3 function, it throws `Please provide an ...
2
votes
1answer
53 views

Recovering address (web3.eth.accounts.recover) does not return the address of message signer

I am writing a test for a function in my smart contract which attempts to verify that a message comes from the signer. I'm currently using web3.eth.accounts.sign to sign my message with the sender ...
0
votes
1answer
53 views

Send Transaction to smart contract using web3 ^1.0.0-beta.41 throws parsing error

I want to send to smart contract using this code : this.myContract.methods.addData(declaration).send({ from: '0x3b0282D31174B927e102bA71d80dF34F4e596Fc4', gas: 12000 ...
0
votes
1answer
93 views

Ganache provider not working with web3

I am trying to run a test script for my smart contract but ganache provider is not being accepted by web3 here is my code. const assert = require('assert'); const ganache = require('ganache-cli');...