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
1answer
9 views

How to catch error thrown by require in node.js

I have a solidity function with only one statement i.e., require(). My logic is if that function throws error then the data is invalid otherwise valid. But that error is not caught in err parameter of ...
0
votes
0answers
10 views

Out of gas error while receiving tokens

I have an issue: I want to receive some BOKKY tokens to test it. When I use simple wallets I just send ethers and receive tokens, everything works fine. I also have my own smart contract (multisig ...
0
votes
1answer
32 views

Execution of sending transaction never ends [UPDATED]

I send a transaction with web3 1.0.0 from a script like: async function sending(deployed_contract) { await deployed_contract.methods.mymethod(1).send({from: account}) .on('...
1
vote
1answer
38 views

How to check if the address is an ERC20 contract?

edit) VM execution error was a bug on Web3, confirmed my code works fine. I am trying to fetch random addresses from blockchain and trying to categorize them if it is an ERC20 contract address or not....
0
votes
2answers
14 views

Calling an address array in web3 returns an error that the method needs arguments

I'm declaring a public address array in my contract, but when I call it, I get an error saying it's expecting an argument. Can someone shine a light on what is happening here? Contract.sol uint ...
1
vote
1answer
12 views

web3js recover returns different address than what signed message

Web3js as of version 1.0.0 beta supports an interface for verifying signed messages: https://github.com/ethereum/web3.js/issues/404 This is documented here: https://web3js.readthedocs.io/en/1.0/web3-...
1
vote
1answer
25 views

Where is the wallet location after save with web3?

I want to create a wallet similar to Metamask with Web3.js library. So far I have been playing around with some of the commands. The point is after I create my wallet with web3.eth.accounts.wallet....
1
vote
1answer
29 views

Issue getting Metamask account using Web3 1.1.0

I am working on a React app which uses a library that has Web3 as a dependency. I had previously been able to the get the current Metamask address with the following code: const injectedWeb3 = ...
1
vote
3answers
2k views

Decoding contract output of web3 eth call

I have written data to a contract using sendRawTransaction, and am trying to fetch it using web3.eth.call for the function : function checkRecord(uint id, bytes email) constant returns (uint id2, ...
0
votes
1answer
24 views

Accounts created by using web3.eth.accounts.create() don't appear when web3.eth.getAccounts(console.log)

I am new to Ethereum. I am running a geth devnode. Installed web3. Used web3.eth.accounts.create function to create one account without any entropy and created another account by using the same ...
3
votes
1answer
24 views

Embedding ETH Wallet Address into Webpage

Hey is there a quick way to embed an Ethereum wallet address and a button into my existing website so as to allow people to send in their ETH donations to me? Or do I need to go through the whole npm ...
0
votes
0answers
12 views

Smart contract migration through Proxy delegate pattern in solidity 0.5

I am trying to do smart contract migration in solidity 0.5 using the proxy delegate pattern. When I write the integration test in javascript how should i make a delegate call using the proxy contract ...
0
votes
0answers
4 views

How to get Metamask return the rawTransaction from the JSON transaction?

I am in the process of exposing a web interface to interact with a back-end Web3 Json Rpc compatible node, but it is necessary that I add additional parameters in the jsonrpc request before submitting ...
0
votes
2answers
95 views

When should we call( ), watch( ) or get ( ) an event?

I find this concept to be very confusing, when should I be using watch, call or get to listen to an event? how are they different and when should they be used? var event1 = newInst.getSupplier({'...
0
votes
1answer
25 views

I am unable to install web3 on my mac

I tried to install web3 in my mac by using sudo npm install web3 but failed many a times . Please help me to sort this matter out . i am attaching you the exact error that I am facing while running ...
0
votes
1answer
21 views

Cannot read property 'sendEth' of undefined, 'sendEth' is function in smart contract

Hi I'm trying to interact with an Ethereum smart contract but it is always showing "TypeError : Cannot read property 'sendEth' of undefined" where 'sendEth' is a function in my smart contract Here is ...
0
votes
0answers
19 views

address.replace is not a function

I'm not really sure why this web3 method is being called in my code and why it's not a function apparently. Can anyone help me understand what the issue is here? Unhandled Rejection (TypeError): ...
3
votes
1answer
289 views

Recover address from signature using web3j

I have signed a data string using the following code snippet in web3js var data = "hello world"; web3.personal.sign(web3.fromUtf8(data), web3.eth.accounts[0], function(error, result) { if (!...
0
votes
1answer
40 views

A common error at time of using web3 options

When i use some web3 options as follows, I receive a common error i.e. TypeError: web3.[option] is not a function For example : TypeError: web3.toAscii is not a function web3.toAscii(...
1
vote
1answer
34 views

Sign message twice with web3

a quick beginner's question... is it possible to sign a message twice with web3? For example Alice creates a message and signs it. Then it is sent to Bob. Can Bob sign the message before he executes ...
0
votes
0answers
17 views

Correct way to handle sent signed transaction on ethereum poa network

Hi I’m having issues with sending multiple transactions to an ethereum proof of authority node(network) on azure. To clarify what I mean. I created an api service, using expressjs and node. Its meant ...
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 ...
0
votes
1answer
21 views

How to integrate Drizzle with react

I have currently set up a truffle project with react, redux and react-router. I just finished writing my first implementation of the smart contract, and now want redux to connect with the smart ...
0
votes
2answers
37 views

I'm trying to create an app that allows people to exchange ether between themselves but I have the error: “web3.eth.transact is not a function”

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <center> <title>dEnergy</title> </head> <body> <label for="name" ...
10
votes
5answers
3k views

Elegant way to detect current provider int web3.js

I want to know what provider the user is using (Metamaks, Mist...)so I can give better user experience. E.g. Give tips on how to unlock an account I'm currently doing this, but is far from elegant. ...
0
votes
1answer
36 views

To handle emitted events from solidity in javascript in truffle suite

The function I am accessing will emit events i need to use that event but the function is a transaction when i am accessing the event it turns as promise pending . So suggest me some methods. thanks! ...
3
votes
3answers
104 views

ERC721: How to get the owned tokens of an address

There is a balanceOf function, but it only displays one uint (the token identifier) I see most ERC721 tokens doing this so I am confused on how to view all owned tokens.
0
votes
0answers
23 views

How to keep user's selected account and network from MetaMask updated.?

So the question is pretty straight-forward. I can setup the web3 provider no problem (currently using Metamask + local ganache), i can access the acount the user selected in the first place, and i can ...
1
vote
1answer
97 views

Metamask transaction confirmed but “Internal JSON RPC error”

I am using getWeb3() to instantiate a contract and make calls with, the transaction says that is confirmed but when I open up developer tools there is the following error MetaMask - RPC Error: ...
0
votes
1answer
20 views

should I use server side rendering(Next.js) for a dapp?

Recently I have been studying a lot about dapps and now working on a little complex one. So what I wanted to ask is which is better for a dapp ? SSR or CSR ? I have read in a couple of places that we ...
1
vote
1answer
28 views

Infura - Signing transactions in a multi-user application

I hope this question is not a duplicate. Since I'm using Infura as a full node, I need to send raw transactions by signing them. In a multi-user application how would my application on the server-...
1
vote
0answers
24 views

metamask and infura - Managing and signing with private keys

I am using Infura as a node for my DApp so I need to send raw transactions by signing them. These transactions can come from multiple users of an application so each user must sign and send a raw ...
1
vote
1answer
43 views

Is it guaranteed to preserve the transaction order when using callbacks?

When I watch a contract for transaction events in web3.py or web3.js, In web3.js var contract = web3.eth.contract(abi); var cInstance = contract.at(address); var transferEvent = cInstance ....
1
vote
3answers
374 views

The best Web3 providers online

Does anyone know what are the most popular web3 providers online? (Or is Infura the only one?)
0
votes
0answers
25 views

I am working on a smart contract. I am getting the following error while running the smart contract in the browser console

Uncaught (in promise) ReferenceError: TruffleContract is not defined at Object.loadContract (app.js:55) at async Object.load (app.js:8) here is my code of app.js file App = { ...
0
votes
0answers
10 views

Contract internel transaction and parent hash detail of transaction using web3 Api

I am working on making explorer like etherscan using web3 in this link "https://etherscan.io/block/7378232".7 contract internel transaction and the click any transaction parent hash you see the detail....
1
vote
1answer
37 views

Can't call a function in a contract, returning something from another contract

I use private geth + web3js (in truffle this works good) Here is an example worked as expected: the first contract: pragma solidity ^0.4.24; import "./Second.sol"; contract First { Second ...
1
vote
1answer
42 views

How can I search the latest transaction of specific account in a ERC20 contract?

Here is the TUSD smart ERC20 contract, if I have a transaction hash, how can search the transaction history with this transaction hash? right now the only way I can think is to get the whole history, ...
1
vote
2answers
15 views

How to convert smallest unit of ERC20 with less than 18 decimals to full coins without rounding errors?

I can just use web3's fromWei function for all token that have 18 decimal places but I'm not sure how to convert token to full token without having to worry about rounding errors. For example convert ...
0
votes
1answer
19 views

Web3: web3.utils is undefined

I am kinda new to Ethereum and Web3 so I am trying to implement the Ethereum: Building Blockchain Decentralized Apps (DApps) tutorial. I have already installed web3 and web3-utils. npm view web3 ...
0
votes
1answer
49 views

Intergrating metamask in DAPP

I am trying to integrate MetaMask version 5.3.1 in my Dapp. I am unable to call web3 functions like getBalance with the given instance, also I am unable to post a transaction. Is there any ...
0
votes
0answers
12 views

Can I avoid metamask popups with calls to a server-side js script in order to pay for transactions?

I have a dapp that allows a user to input some info via the GUI, and this info is stored to the blockchain(testnet for now) when the user presses a button. This naturally incurs a cost, which causes ...
0
votes
1answer
95 views

Deploying multiple contracts with web3js 1.0 at once

I'm new to Nodejs and Ethereum so I apologize in advance for any obvious mistakes. I want to deploy multiple contracts in advance to have addresses ready when they are needed. I use this to deploy ...
2
votes
1answer
37 views

Unable to print event without JSONstringify

I am trying to understand the difference among following cases while printing the event: At web3.js listenToEvent: function(){ Contract.deployed().then(function(instance){ instance....
0
votes
1answer
36 views

Error when subscribing to ERC-20 (BAT, i.e. Basic Attention Token)

I'm trying to subscribe to BAT(Basic Attention Token) ERC-20 token "Transfer" event to detect any transaction made to my ethereum address using web3 in nodejs. I'm using parity (Parity/v1.10.6-stable-...
0
votes
1answer
26 views

AssertionError: amount did not match: expected {} to equal 1000000000000000000

Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v10.15.1 const ApprovalContracts = artifacts.require('../../contracts/ApprovalContracts.sol'); // Pulls in my smart contract // the ...
1
vote
0answers
14 views

How to retrieve private key

when an account is created using web3.eth.personal.newAccount(password), it will give u the account address but not the private key. How to get the private key of that newly created account. Can ...
0
votes
1answer
39 views

can not find specific events and list events of the past the last 1day

I'm wrote this sample but I want to filter specific events 'unsealBid' and list events of the past (e.g. the last 1 or 2 days). const Web3 = require('web3'); const web3 = new Web3('https://mainnet....
0
votes
0answers
28 views

Release / Debug build generated json-rpc calls are different

I'm trying to make simple web3 calls in React Native with web3.js, but generated json-rpc calls are different between release / debug builds - IOS/Xcode. Expected behavior const web3 = new Web3(`...
8
votes
1answer
3k views

What is the difference between web3.eth.sign, web3.eth.accounts.sign, web3.eth.personal.sign functions?

Which function should be used to sign message locally? Which function is the most secure?