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
2 views

Web3 not connecting with ropsten through infura

so my truffle based application is communicating fine with my smart contracts on my private network, ganache and ganache-cli. I then deployed it to ropsten where i used the endpoint i got from infura....
1
vote
1answer
8 views

Web3 1.0 Nested contract promises

What is the best way to handled nested contract call with web3 1.0? I'm trying to collect all data needed and format it into something useable. It could require 2 or 3 calls though. Is there a easy ...
0
votes
0answers
6 views

Invalid JSON Response while connecting DApp, Metamask and Backend

I am getting some error(picture below) while trying to connect DApp with a backend. One day ago, everything worked fine, now I got an error: "basic auth failure". Contracts are deployed on Ropsten ...
0
votes
0answers
11 views

Revert on ERC20.transferFrom

I am getting Error: Returned error: VM Exception while processing transaction: revert when testing MyContract.deposit() Here are simplified versions of my code to highlight where the issue is ...
2
votes
1answer
12 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
20 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
12 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
6 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 ...
0
votes
0answers
15 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
15 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
7 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
1answer
10 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
21 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
15 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
13 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
14 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
8 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
14 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
12 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
17 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
17 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
19 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
25 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
0answers
18 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
6 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
7 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
16 views

Metamask not being detected

I have written a simple application that takes in values from a form and uploads them to a blockchain, for all intensive purposes it works – the accounts are charged and the values are updated. BUT, ...
0
votes
0answers
14 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
21 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
21 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
0answers
16 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
9 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
21 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
15 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
19 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
28 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
11 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
3 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". ...
-3
votes
0answers
17 views

What is the method of secret key storage of Metamask

Can any one explain the method of secret key storage of Metamask, especially from security perspective. Specifying file name and line number of source code of the secret key storage part in metamask. ...
0
votes
0answers
17 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
9 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
23 views

Check when a block is mined

Is it possible to know when a block is mined? Is there any timestamp or event/subscription?
0
votes
3answers
33 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
29 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
10 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
22 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
17 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
21 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-...
0
votes
1answer
34 views

what is the web3 code for this function

function depositToken(address token,address User,uint amount)public { if (!ERC20(token).transferFrom(msg.sender, address(this), amount)) revert(); _balances[token][User] = _balances[token][User]+...
1
vote
1answer
19 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))...