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
0
votes
1answer
14 views

Ether Forward and Token Sweep Contract?

I've written a simple ether forwarding contract coupled with a sweep function which when called automatically, sweeps all tokens of specified token contract address to pre-defined recipient addresses. ...
0
votes
1answer
20 views

Private transaction failing with Non-200 status code

I have a Quorum network running on Azure Blockchain service. Sending private messages to a particular public key is failing. It was working till last week. No code or configuration changes have been ...
1
vote
1answer
37 views

Web3js events “fromBlock: 0” doesnt work

I want to get events from block X. I have: quorum-v2.4.0 web3js 1.2.6 And I have my own smart contracts I want to listen for. So I have created listener for allEvents like this: const event = ...
0
votes
0answers
23 views

Can I get a deployable bytecode from a contract?

In my truffle build files there are two types of bytecode for each contract: bytecode deployedBytecode web3.eth.getCode returns only the 2nd one. Can I access the original bytecode from web3? It ...
0
votes
0answers
12 views

window.ethereum: 0 if use MetaMask

I try to connect to MetaMask from my DApp. It used two work well about two month ago, but now window.ethereum object is 0 (not undefined). For some reason ethereum object is 0. I am aware about ...
1
vote
1answer
21 views

Transaction working in remix but not errored from dapp

I have a master contract which deploys instances of other contracts. pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; contract DataEntityContract { DataEntity DE; constructor(...
0
votes
1answer
23 views

What does MetaMask mean by stop injecting web3.js?

MetaMask announced that they will stop injecting web3.js here. I know previously MetaMask will add a global variable in browser window.web3 and this global lowercase web3 variable will be deprecated ...
0
votes
0answers
19 views

“Nonce too low” using contract.methods.myFunction().send()

Using web3 to build a contract from the ABI: contract = new web3.eth.Contract(JSON.parse(abi), '0x17c91A5a6f5e3E4BEaFC478D18C4A44D88833277', { from: '0x0Ad2b5CCe78D677fD000698a7E4Cde866DE189C6', gas: ...
0
votes
2answers
20 views

Web3.js eth.subscribe: on('changed', function(event){}) doesn't work with Metamask?

I write a demo DApp website with this javascript const web3 = new Web3(ethereum); const contractAddr = "0x0Aa27e4B13D5c08A8767B36a0ACb76ED4549B7EA"; const abi = ...; let inst = new ...
0
votes
0answers
13 views

Calling decodelog with dynamic number of arguments

the number of input arguments is dynamic, how can I decode many log by one? this is all i tried to do for (let n = 0; n <= receipt.logs.length-1; n++) { if(event.code === receipt.logs[n]....
0
votes
1answer
46 views

Getting “ReferenceError: unescape is not defined” when trying to call() a smart contract method from rasberry pi to a private geth network

> var contract1 = eth.contract(abi).at(address) undefined > contract1 { abi: [{.....] transactionHash: null, addRecord: function(), allEvents: function(), getPatientName: function(), ...
0
votes
0answers
17 views

Contract not getting deployed and no failed transaction is shown on rinkeby.etherscan.io

I deployed this same contract a week ago and it deployed successfully. Now when I try to deploy it I get a message in the console telling me 'Attempting to deploy contract from (my account)' but then ...
0
votes
1answer
20 views

Cross Origin Blocked? Setting up Infura provider [closed]

useEffect(() => { const loadWeb3 = async () => { const web3 = new Web3( new Web3.providers.HttpProvider("https://mainnet.infura.io/censored") ); let n = await web3....
1
vote
1answer
13 views

What is the max number of Blocks which can be created in Quorum

I have nodes running from past few days, with almost 4100+ transactions successfully completed. When i try to interact with the contracts again to add/modify details it shows error Error when ...
0
votes
0answers
12 views

web3.js - Subscribe multiple addresses and new coming address

I build ETH wallet app by using web3.js. My concept is the new ETH address will generate when user is registered on my app and when they send ETH from other address on another app or whatever to the ...
0
votes
0answers
11 views

Unable to render inside (callback function) using react for web3.eth.subscribe

import React from 'react'; import ReactDOM from 'react-dom'; import Web3 from 'web3'; class App extends React.Component { componentWillMount() { this.loadBlockchainData() } ...
0
votes
1answer
26 views

Accessing Ethereum network via JSON RPC from wallet balance/transactions

sorry if the question is silly.... I am tying to build a simple app that checks ETH wallet addresses balances and transactions (for both ETH and Tokens). As far as my knowledge goes, I think that I ...
0
votes
2answers
20 views

Sending ether from list of addresses with web3.js

I would like to read the csv text file and make a transaction via web3.js like what I did with web3.py Here is my python code #!/usr/bin/python3.7 import os import time import pandas as pd from ...
0
votes
0answers
17 views

Difference between method id, event id and ABI signature for event

I am confused as to what is the difference between method id, event id and abi signature. I got the abi signature of a token transfer function according to the following web3js function const ...
1
vote
0answers
16 views

Retrieve block number from geth and display it on my webpage

I am running geth using this command: geth -testnet --syncmode light console and I am trying to retrieve the block number from geth and display it on my web app. In geth when I type: eth....
0
votes
0answers
18 views

ParserError: Expected token Semicolon got 'Return'

The error pops up whenever I try to compile through truffle, not able to figure out a solution any help is highly appreciated. Here is the error Compiling your contracts... ==========================...
0
votes
0answers
23 views

Access to smart contract's value in Browser

My Truffle project is this contract that just shows Yerevan is love: pragma solidity ^0.5.12; contract TEST{ string public note="Yerevan is love"; function rep() public view returns(string memory){ ...
0
votes
0answers
17 views

Reading all ERC20 token balances

I am aware that the ERC20 balance is easily obtained in web3js by calling token.methods.balanceOf(ADDRESS); However, I was wondering if there are any new developments or API that can now be used ...
0
votes
1answer
36 views

how to send erc20 token without using smart contract abi?

How to transfer erc20 token without using contract or contract abi? The below script i have used to create Signed Raw Transaction to send Ether(ETH). How can i create Signed Raw Transaction to send ...
0
votes
1answer
25 views

Does metamask uses web3?

I was curious if metamask uses web3 for communication with eth node ? I tried google for it; showed bunch of other results but didn't precisely answered my question. Indepth answer on how metamask ...
0
votes
0answers
10 views

Conditionally Return Content Based On Wallet Tokens

Hi all– new to building dapps. I'm working on a little web game that returns content based on what tokens you hold in your wallet. I'm used to building web apps and mobile apps, but I've never worked ...
1
vote
1answer
25 views

Get hash transaction by your encode input data

In my application i must follow the use case: I need to record any document hash on the Ropsten (eth testnet) blockchain. The hash is unique and i'm using a mapping in my smart contract to accomplish ...
0
votes
0answers
13 views

Tuffle. New account from mnemonic during migrations

I'm trying to create a new account from predefined mnemonic during Truffle migrations(both testing and prod environments). I want to pre-create multiple contracts using corresponded factories for this ...
0
votes
1answer
26 views

Access to smart contract's value in Node-js

I am working on a simple Truffle project that just shows "Yerevan is love". My contract code: pragma solidity ^0.5.12; contract TEST{ bytes note="Yerevan is love"; function fname() public view ...
0
votes
1answer
21 views

What is input in web3.eth.abi.decodeLog(inputs, hexString, topics);

web3.eth.abi.decodeLog([{ type: 'string', name: 'myString' } , { type: 'uint256', name: 'myNumber', indexed: true },{ type: 'uint8', name: 'mySmallNumber', indexed: true }], '...
1
vote
1answer
34 views

Is fully synced node required to access ethereum blockchain through geth?

Do i need fully synced node to access ethereum blockchain through geth using web3js? PS. i want to access ethereum blockchain through geth only, not metamask, infura, etc.
0
votes
1answer
27 views

I cannot see Ethereum accounts in Browser

There are 10 Ethereum accounts in Ganache. I work on a Truffle project. Whenever i run the following codes in Nodejs: var Web3 = require('web3'); var web3 = new Web3("ws://localhost:8545"); var acc= ...
0
votes
1answer
30 views

How to render display the console log using react and web3 [closed]

import ReactDOM from 'react-dom'; import Web3 from 'web3'; class App extends Component { componentWillMount() { this.loadBlockchainData() } async loadBlockchainData() { ...
0
votes
1answer
16 views

What is role of pure.js for adding web3.js

I am adding web3.js according to guide in: Adding web3.js. I traversed steps mentioned there that can be seen below: There is no problem with "npm" and "meteor" steps but with "pure js" step the ...
0
votes
0answers
19 views

Using web3.js to interface with smart contract

I am a beginner in Dapp and don't know about web3.js. I complie myslef contracts with Truffle. I did write the following contract: pragma solidity ^0.5.12; contract TEST{ bytes public name="...
0
votes
1answer
20 views

How do I get all logs for all time for a given contract using web3?

This answer worked when filter.get was not deprecated, but now I am not sure how to do the same thing with subscribe - web3.eth.subscribe hears new events and acts on them after I create the ...
1
vote
1answer
38 views

Connect to a public node with web3js

Is it possible to connect the nodes that are listed on ethernodes.org I chose one of the listed nodes and try to connect with web3 but I get connection not open on send() error. const Web3 = require(...
0
votes
0answers
23 views

Send message in blockchain network using web3.shh

I want to send message from one address to another in the ethereum network using shh module of web3js library. const Web3 = require('web3'); const url = 'http://localhost:7545'; ...
0
votes
2answers
42 views

Quorum private transactions not private

I am struggling to enforce privacy using Quorum's privateFor option. I have provisioned a consortium in Azure blockchian service with 3 nodes. I deploy a smart contract from node2 privateFor node1 ...
0
votes
0answers
17 views

Sell Orders Reverted - Uniswap

I'm using node library with web3.js, big number, and ethereumjs-tx, and I can get the "buy" orders that use either solidity function ethToTokenSwapOutput or tokenToEthSwapOutput to work great. But I ...
0
votes
1answer
32 views

Unable to filter events with specific values of indexed parameters

I am currently trying to test a smart contract using the truffle suit ( with 'truffle test'). My contract is of a simple ERC20 token which includes the standard Transfer event: event Transfer(address ...
1
vote
1answer
29 views

Difference between web3.eth.personal.getAccounts() with web3.eth.getAccounts()

What are the differences between web3.eth.personal.getAccounts() and web3.eth.getAccounts()? environment truffle: v5.1.7 using truffle console.
1
vote
1answer
32 views

How to get web3 to interact with smart contract to input string info

Just cannot get what seems like a simple input from html page to interact with a very simple contract to input data. Started off trying to make this tutorial work: Interacting with a Smart Contract ...
0
votes
1answer
54 views

Calling function from existing truffle contract in node.js

This is probably a very simple problem to solve, but I am setting up a node.js backend using express for my Dapp and I can now deploy new contracts just fine. I now need to figure out how to make ...
1
vote
1answer
27 views

What are best practices for submitting multiple sequenced transactions with web3?

I have a dapp that, as part of one logical user operation, must issue an approve() call on a token contract followed by a call to another contract that will use the funds. Since these each require ...
0
votes
2answers
22 views

How does metamask know a contract is for ropsten or for main network?

Im using this code to detect for metamask. Now im using ropsten but i want to know how does metamsk know that my contract only works with ropsten? window.addEventListener('load', async () => { ...
1
vote
1answer
28 views

How does web3 handle new longest chains?

I have a Dapp which subscribes to events using web3. I'm wondering how I can detect that the longest chain has changed or rather how I can make sure the events that I've received are canonical. The ...
0
votes
1answer
31 views

How can I turn this into a human readable output? [closed]

I have this buy function but the output gives me a transaction Nr. or whatever this is async function buy() { var a = document.getElementById("amount").value; var accounts= await web3.eth....
1
vote
1answer
76 views

How can I get a private key from a mnemonic phrase?

I want to convert a 24 words length seed phrase into a private key using web3.
0
votes
1answer
19 views

Why do we use `serialize` function of `ethereumjs-tx` package before broadcasting a transaction

I just want to know the purpose/functionality of serialize function which we use before broadcasting a transaction: const serializedTransaction = tx.serialize() const raw = '0x' + ...

1 2 3 4 5 73