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

Filter by
Sorted by
Tagged with
1
vote
0answers
56 views

How to use web3-react with truffle Dapp? any sample code / tutorial?

I am new to react and finding issues with the front-end of the Dapp application. Especially in web3 version > web3 1.0.0 I just heard about the web3-react and I think it will be a lot easier. I ...
1
vote
1answer
45 views

where does the metamask fits in Dapps architecture?

i am learning building Dapps. And i got to know to know about metamask. I've read about metamask is an ethereum wallet which we can use to sign Tx's without running a full node and inject web3 to ...
0
votes
0answers
25 views

web3.eth.getBlock in order

I am a beginner for Javascript & web3(0.20). I am using Metamask for watching allevents, and I need to get timestamp. I use getBlock.timestamp. Due to Javascript, timestamps are not inorder. I ...
0
votes
1answer
38 views

Object to Hex function (like in sign transaction)

I am reading the Web3 documentation about signing transactions (see example below). As I understand it, the "transaction object" gets turned into a hex string and enveloped, this is the "message". The ...
0
votes
1answer
67 views

How to hash multiple values including array keccak256 Solidity v5.0.x and web3 'Autodetection of array types is not supported.'

How can I receive the same hash in solidity and web3? Multiple values where one is a multi dimensional array. Solidity v0.5.x: pragma solidity 0.5.6; pragma experimental ABIEncoderV2; contract Hash{...
1
vote
0answers
109 views

Web3 in the browser

Importing web3@1.0.0-beta.55 in a stencil+typescript file for a frontend application directly triggers an error, even without using the imported Web3 object whatsoever. import Web3 from 'web3'; -> ...
0
votes
0answers
27 views

web3js batch execute method gives error

I have private/local network/chain setup. I'm building this with Nodejs-->expressjs. const contract = new web3.eth.Contract(abi, address); const batch = new web3.BatchRequest(); batch.add(contract....
0
votes
2answers
38 views

Cannot declare web3 object in JavaScript

When I try to declare a web3 object It's always undefined. I'm writting in JavaScript and using Infura as my provider for the ETH mainnet. I also tried with a local blockchain instead of Infura, but ...
0
votes
1answer
45 views

How to call setter method of smart contract with web3 1.0.0

I don't know why but i'm not able to perform transaction with this code. please help me out i'm stuck. i just have to call setter method of my contract with some arguments. router.post("/set", async ...
0
votes
0answers
44 views

Why this error occurring when i running my dapp?

I create a dapp using Solidity,Web3Js,Javascript and Html with metamask i always getting this error when i am trying to submit my transition i am getting this error at c (inpage.js:1) at ...
0
votes
1answer
69 views

Sending a transaction without using MetaMask

I have designed a contract deployed on the Rinkeby with web3. I have also implemented a react app to interact with the blockchain. I want to use my application without metamask but I got this error ...
1
vote
1answer
73 views

Solidity Error:Running Out of Gas / selfdestruct problem

I've been going through 'Building Cryptocurrency and its ICO' by DappUniversity. I know many have questioned this issue and I've been through all the post but couldn't resolve it. The problem is self-...
0
votes
0answers
23 views

Web3js v0.20.7 - callback ls not a function

I'm facing issue of callback is not a function in web3js 0.20.7 when i call the method of sendRawTransaction to deploy smart contract with web3. When i used the same method just to call deployed ...
2
votes
1answer
50 views

How to find the Bytecode of Ethereum Smart Contract by just it's address using JSON RPC

I am wondering that is there any way to find the byte-code of the Smart Contract which is published on a blockchain just by having only idea about it's contract address using JSON RPC running at 8545 ...
0
votes
1answer
34 views

In node.js event is not fired

I am using web socket to get event. sending transaction works fine. but event is not fired. also I referred Web3 events not working but it does not work, too. I used eventemitter also. but it did ...
1
vote
1answer
61 views

web3 - Contract deployment has been reverted by the EVM

I want to deploy a contract but my transaction gets reverted. This only happens with Web3, while it works fine with Remix.I can assure the ABI and Bytecode are correct because I pasted them from Remix,...
1
vote
1answer
110 views

Smart Contract is being deployed but call does not return contract address after deployment

So I have been trying to deploy a smart contract using nodejs, but when I call the function to deploy, I get no contract address on my console. It's like the send() function never completed its ...
1
vote
0answers
76 views

Problem connecting web3 via websocket to node with nginx

we are trying to connect to a geth node via WebSockets to be able to subscribe to contract events. This node is created with docker and this docker uses nginx as a proxy. We can connect easily with ...
0
votes
1answer
43 views

Web3 connecting to Infura

installed web3 and follwed steps int he image
1
vote
0answers
28 views

Connection dropped by Kaleido websocket

Connecting to Kaleido with websockets and listening on contract events works fine, but after some time (even if constantly receiving events) the connection is dropped by Kaleido. The problem appears ...
1
vote
1answer
19 views

Developer downloading ledger reasoning? [duplicate]

My question is a little odd, but I will ask it anyways. From a development perspective, knowing that there is a service such as Infura, why would a developer download the whole ledger? Infura ...
0
votes
0answers
63 views

cannot unmarshal hex string of odd length into Go value of type hexutil.Bytes?

const Tx = require('ethereumjs-tx').Transaction; const Web3 = require('web3'); const web3 = new Web3('https://ropsten.infura.io/161d7c8443f14babb3c176023628a055'); // console.log(web3.eth.accounts....
0
votes
0answers
94 views

Error: The data field must be HEX encoded data

I am trying to make a simple dApp by using a tutorial. I am using the following command ; npm install ganache-cli web3 so that we can use web3 to get fake ethereum nodes/accounts by connecting it ...
0
votes
0answers
12 views

How can I use the parameters of an event as a function input?

how can I use the indexed parameter of a triggered event as a input for a function called in response to that event triggered? This is the event: event LogOfferAccepted( uint _id, ...
0
votes
0answers
75 views

Can't connect to localhost:8545 while using ethereumjs-testrpc web3?

I am developing a simple Voting dApp by following a tutorial. In this tutorial we are using npm install ethereumjs-testrpc web3 so that we can get the fake nodes of Ethereum. For that i first ...
0
votes
1answer
23 views

having difficulty getting a value from a contract with web3

I have been trying to replicate the following simple tutorial but deploying to the ropsten network using infura instead of to local host: https://medium.com/coinmonks/interacting-with-ethereum-smart-...
0
votes
1answer
38 views

extract address of used library

Is there anyway or method to extract the address of a linked library from the contract bytecode (not a verified contract code) or deployment transaction? my question is about step 3: step 1. ...
1
vote
2answers
121 views

Contract error: TypeError: abi.forEach is not a function

mac OS 10.14.15 node version v10.15.3 web3 version 1.0 version Parity-Ethereum/v2.5.1-beta-adabd8198-20190514/x86_64-macos/rustc1.34.1 I am trying to follow a YT tutorial to instantiate a contract ...
1
vote
0answers
23 views

How to do loop all the metamask Accounts loop and display data from that address in React frontend + Dapp App JS [duplicate]

I want to Display data stored on the Ropsten Network in more then 2 metamask accounts. I want to display the result on the Home page in the table form. For that I need to loop through each ...
0
votes
2answers
64 views

how to get contract address after its been mined with web3.js

I have tried to deploy a SmartContract from web3.js node library, I am getting a transaction hash from it but how would I get the contract address after It's been mined by a miner? here is my code ...
2
votes
1answer
84 views

Couldn't connect to node because cross-origin request is blocked

I am running a full rinkeby node via geth --rinkeby --rpc --rpcapi db,eth,net,web3,personal --cache=2048 --unlock="..." --password ... --rpccorsdomain "*" --allow-insecure-unlock --rpcaddr "...
0
votes
1answer
107 views

Web3 Contract.balanceOf is not a function

I have read this helpful SO answer about sending ERC20 contracts, but it seems that the Web3 docs and API have changed dramatically since then. I am trying to get the balance of a smart contract using ...
0
votes
1answer
49 views

Web3: How to get price of ETH at time of transaction?

Example transaction: https://etherscan.io/tx/0x2edfb0bf11355a48bbb93c567a8c6de39f80de515ceb8b26dbcbf4729bd8a217 In code given a transaction object, how would I fetch the price of ETH at the time of ...
0
votes
0answers
27 views

How to get web3.eth.getPendingTransactions on JavaScript?

I read in the official document for web3js v1 https://web3js.readthedocs.io/en/1.0/web3-eth.html#getpendingtransactions getPendingTransactions web3.eth.getPendingTransactions([, callback]) ...
0
votes
1answer
18 views

How to create account by web3 0.20 version?

I try to create new account by using web3, i found that I can only do this in 1.0 of web3 but not in 0.20 version? it does not support personal.newAccount
3
votes
2answers
52 views

Web3.js - where to find prepackaged bundle to be included with my HTML page

Is there any way i can download web3.min.js and include "" in my html directly, without using npm to install, just like adding a js file, i know there is 0.20 version but i cannot find the version of ...
0
votes
0answers
35 views

React + Ethereum + Solidity. Private Blockchain ether mining issue?

I'm making an app using react, ethereum and solidity. I'm signing up the user using.. web3.eth.personal.newAccount(); Then all users need to do certain tasks on app. They need to do certain ...
0
votes
1answer
80 views

miner.start() is not a function?

"web3": "^1.0.0-beta.37" "web3": "^1.0.0-beta.55" import {Miner} from 'web3-eth-miner'; then const options = { defaultAccount: "0x78dB3e2129D58685444989dD9682DDDC70dd3C82", ...
1
vote
0answers
74 views

web3.eth.sendSignedTransaction from address is different from Signer's address

I'm signing transactions using an HSM and when using Web3js to send the signed transaction, the from property on the receipt shows an address that's: Different every time a sent signed transactions ...
1
vote
0answers
84 views

Error: Connection error: Connection is not open on send()

After a few hours the socket to Infura seems to drop and we get the error, Error: Connection error: Connection is not open on send() Why does this happen or what is the best way to solve it? version: ...
0
votes
0answers
24 views

How to get list of pending transactions for particular address on JavaScript using public API?

I'm building web-wallet on javascript, and I want to show not only available balance, but also pending amount. From web3js v1.xx documentation I've learned that I can do web3.eth.subscribe('...
0
votes
0answers
55 views

Can I subscribe to events emitted by another contract?

I am trying to subscribe to an event emitted by an existing library's smart contract. I've found examples of how to subscribe to events emitted by my contract using web sockets and my contract ABI as ...
3
votes
1answer
99 views

Generate Ethereum address with private key

How can I generate ethereum account address and private key that works on ethereum main network using web3 in nodejs?
0
votes
2answers
143 views

Uncaught TypeError: e is not a function from getAccounts() + web3 1.0.0-beta.37 + truffle + React Dapp

I am creating my first Dapp by using web3 1.0.0-beta.37 and trufflfe While getting the accounts in app.js by using ganache-CLI and Metamask, I am getting following error. Uncaught TypeError: e is ...
0
votes
1answer
30 views

how to send a transaction with web3 and metamask

I'm trying to learn how web3 works and I'm creating a simple HTML page to send a transaction, but I'm getting the following error: (inpage.js:1) MetaMask - RPC Error: validateTxParams@moz-...
0
votes
2answers
18 views

web3js returns non-checksumed addresses!

Why does web3js 0.20.6 returns all-lowercase addresses on contract creation not a checksumed address?! How to deal with this trouble?
0
votes
1answer
94 views

myContract.getPastEvents(“allEvents”) returns empty array

I want to get all past events from a contract I deployed on the Ropsten network. Contract is: pragma solidity ^0.5.1; contract SampleContract { uint storageData; event MamboNumberTwo(uint ...
1
vote
0answers
17 views

Can't get event data selecting the event by name

This is my contract pragma solidity ^'0.5.2'; contract MyContract { event ContractCreated(address newAddress); constructor() public { } function createOtherContract() public { ...
0
votes
1answer
23 views

how do etherscan get all the token balance of particular address?

I want to create service where just by providing address i can fetch all the token (erc 20 & erc721) balance just like etherscan for a private network? is there any way to do it by writing for ...
1
vote
2answers
103 views

Can't deploy contract with web3.js and ganache-cli

I'm using the solc module to compile a Solidity contract. The compilation step looks to be working correctly, however, when I attempt to deploy the contract to the Ganache network (in a Mocha test), ...