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

Web3 event listener - timing issue when immediately retrieving contract values

I'd like to be able to immediately get a struct value from a mapping after calling a function that updates the struct, however, when testing with Ganache, sometimes the event arrives to the listener ...
0
votes
0answers
12 views

window.ethereum

When i made web3 instance and run index.html i lose ethereum and window.ethereum when i call it from console i got ethereum is not defined,i have installed metamask and use ropsten network.Why its ...
1
vote
1answer
86 views

Unable to install Mocha Web3 and Ganache-cli

I have been trying to install mocha,Web3 and ganache all through one command but I am facing an issue while installing can someone help me in sorting our this error. Quick response will be appreciated ...
0
votes
1answer
209 views

The geth account new and web3.eth.accounts.create

The geth account new and web3.eth.accounts.create. That both function/command are same are different.To create new account.
1
vote
3answers
2k views

Web3.js browser version only

I want to create a simple page to interact with my deployed contract. I don't want to use Node.js. I want to use html + web3.js browser version. I got a link: https://github.com/ethereum/web3.js/tree/...
0
votes
1answer
15 views

Web3 js proper way to call a Reading contract function

So i recently took over a project that had been abandoned for a while, which involves an ECR20 smart contract and the use of the web3 library to communicate with the smart contract. I've been trying ...
0
votes
1answer
393 views

Truffle-contract error on deployed contract

Playing around with the gnosis multisig, using truffle-contract to interact with already deployed MultiSigWallet using truffle migrate. Contents of the file I am trying to run: var contract = ...
0
votes
1answer
28 views

Updating inflationary token values per block?

Let's say within a specific smart contract, that deals with updating tokens values (due to inflation) on an exchange, the main way of consistently updating is utilizing a preset multiplier called in ...
1
vote
1answer
16 views

Metamask doesn't show token value on erc20 contract interaction

Why using the Transfer method is showing the value of the erc20 that I want to transfer while with a custom method is always showing 0 ETH on metamask instead of the token that I'm transferring via ...
0
votes
1answer
145 views

Solidity Error: Cannot destructure property `interface` of 'undefined' or 'null'

I've got his error in Solidity when compiling my test file: TypeError: Cannot destructure property interface of 'undefined' or 'null'. I know it is related to my compile.js file, but what is ...
1
vote
1answer
9 views

How can I measure the gas used in a block of code?

This answer explains well how to measure the gas used in a block of code. I had actually been using this method before I found that answer: pragma solidity 0.4.26; import './IERC20Token.sol'; ...
1
vote
1answer
4 views

Uncaught TypeError: Cannot read property 'fromWei' of undefined, working good in one tab and failing in another tab

I'm getting this error when I'm trying to convert Wei to Ether using the code window.web3.utils.fromWei("200000",'ether'). This error shows only on the single page and when I console.log in the same ...
0
votes
1answer
55 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
0answers
7 views

How can I call a method on a smart contract with the web3 provided by MetaMask?

How can I call a method on a smart contract with the web3 provided by MetaMask? Building smart contracts with solidity was the easy part for me. I had relatively few problems thanks to https://remix....
1
vote
0answers
11 views

How long does it take it typically take for call value of changed variable to update?

I'm trying to mine a proof of work contract. Each time a solution is found, the return value for units.functions.getChallengeNumber().call() should change. I ran two instances of this script (with ...
0
votes
0answers
10 views

Transaction submits but is not valid when processed

I'm running two scripts that try to solve the same proof of work problem. from web3 import Web3 import json from hexbytes import HexBytes import numpy as np import os import time INFURA_ROPSTEN_URL ...
0
votes
0answers
10 views

Example of web3

Share example of code that connect to ethereum contract and interactive with him.I want use jsdeliver in html not work in node.js.Show me simple example of interactive. <script>src="https://...
1
vote
0answers
19 views

keccak256 output is different on ruby vs javascript…?

Ruby ethereum libraries use: https://github.com/phusion/digest-sha3-ruby require 'digest/sha3' '0x' + Digest::SHA3.new(256).hexdigest('0x0') => "...
1
vote
1answer
82 views

Web3 method call returning unexpected value with certain smart contract setup

I have tried to implement a persistent data storage with smart contracts as seen with the following code (this is an example that mimics what my actual code does). I have a data storage contract with ...
0
votes
0answers
7 views

Metamask and Web3

I use this in html src="https://cdn.jsdelivr.net/npm/web3@1.2.6/dist/web3.min.js" and when i call some functions i get error.Why this happend?Example i cannot call ethereum.enable() for allow ...
1
vote
3answers
175 views

Error: Invalid JSON RPC response: “” from web3

I run: geth --rinkeby --rpc --rpcport=8545 --rpcaddr=192.168.1.37 It works in console: geth attach http://192.168.1.37:8545 > eth.syncing false > eth.accounts ["...
0
votes
1answer
252 views

Browser integration testing with web3.js for dApps

What are the practices to test web3.js codebase in a wwv browser using testrpc chain? Basically emulating Metamask and having Selenium automation to sign the transactions.
1
vote
1answer
54 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 return v,r,s parameters ...
0
votes
2answers
23 views

ERROR: Provided address “6.963865902119903e+47” is invalid

Full error log: formatters.js:471 Uncaught Error: Provided address "6.963865902119903e+47" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can't be ...
0
votes
1answer
26 views

getTransaction sometimes returns null when transaction is pending

I am looking to get real time transaction data as it is broadcasted to the ethereum network, so I have subscribed to pendingTransactions. This only returns the transaction hash though, so I have to ...
7
votes
3answers
5k views

How do I send the entire ether balance from one account to another account?

I'm trying to use web3 to transfer all (or as much as I can) of the balance of an account to another account. Here is the code I have so far: var sender = web3.eth.accounts[0]; var receiver = web3....
0
votes
2answers
109 views

app.vote(1, {from: web3.eth.accounts[0] }) not working

I am following a tutorial from Dapp University about building Election Smart Contract. When I run this command in the console: app.vote(1, {from: web3.eth.accounts[0] }) I get the following error: ...
0
votes
1answer
24 views

Get emitted events of a a smart contract function using infura

I have used infura in my App.js to connect to the kovan network. Then I am creating an instance of the smart contract deployed on that network. Then I am calling a function on that smart contract ...
0
votes
1answer
47 views

getPastEvents on localhost is not a function error

Now, I'm working on an Ethereum Blockchain project to transfer the ownership of stored devices by using local web3 provider at the truffle environment. Truffle v5.0.27 (core: 5.0.27) Solidity v0.5....
0
votes
0answers
18 views

how i know what function run the trasaction?

i have that question , how i know what function runs the transaction ?, let me explain , if i do a transaction in remix.ethereum i can see the transaction in the bottom and in the details of this i ...
0
votes
1answer
28 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 ...
0
votes
2answers
7 views

Transaction won't be mined / Failed signing of transaction

I'm trying to send a transaction that writes somesthing on ethereum(kovan) but it seems my transaction is not mined and probably not even send to the network? All my view requests to ethereum work, so ...
0
votes
1answer
124 views

Getting “gas required exceeds allowance (93846700840810) or always failing transaction” on private network. How to access geth client via nodejs?

I have recently started using Ethereum. I am trying to test my contract using multiple machines. Only solution I found was to setup a private network using Geth and add peers. Following is the genesis ...
1
vote
2answers
154 views

How to get the same SHA3 hash as soliditySHA3(ethereumjs-abi) returns using web3.sha3 in js?

I'm trying to hash a message as shown here: function constructPaymentMessage(contractAddress, amount) { return ethereumjs.ABI.soliditySHA3( ["address", "uint256"], [contractAddress, amount],...
0
votes
1answer
26 views

Web3 1.2.6 appears to ignore require in view function

Given the following function: function checkLock() external view returns (bool) { require( address(this) == IERC721(_nftRegistryAddress).ownerOf(_tokenId), "[...
0
votes
1answer
24 views

In up gradable design pattern how to set the allowed contracts or owner during deployment of smart contracts

Functional Background: Contracts for upgradable design pattern: ProofDB.sol : contract to store the data. Proof.sol : contract that contains the business logic. Registry.sol: contract that ...
0
votes
1answer
100 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 ...
0
votes
1answer
41 views

How to build security into Dapps?

I am building a loan dapp. The functionality is not easy to build but relatively straightforward. My question is though does anyone have any suggestions of how to build in user logins and security? ...
0
votes
0answers
11 views

What's the Difference Between Accessing ChainId Through the Provider or the .net.getId() method?

It seems there are two documented mechanisms for obtaining the chainId to identify if web3 provider is on mainnet or one of the testnets. The first that I've seen is using web3.eth.getId(). However, ...
1
vote
2answers
20 views

Duplicate data in “returnValues” field of event emitted in solidity script

I am using quoram distribution through Azure blockchain service.. we are emitting few events according to our logic and these events are being used to get specific data from the transaction.. though ...
1
vote
1answer
36 views

Debugging solidity function

How can i call second function so that it could return key_Number and key name ? function TransferKey (address receiver, string _name, uint Key_Number) public { name = _name; ...
0
votes
1answer
322 views

web3 Uncaught TypeError: Cannot read property 'createBox' of undefined

i'm trying to create simple application by using solidity 5.0.0 , Truffle v5.0.0 and web3 web3@1.0.0-beta.34. but i've gotten Uncaught TypeError: Cannot read property 'createBox' of undefined. ...
1
vote
2answers
15 views

For multi sign transaction, who will pay gas? [closed]

For multi sign transaction, who will pay for the gas? Any sample code? I am not quite sure about this.
0
votes
0answers
8 views

How to intergrate Etherum Wallets for my business [closed]

What will it take intergrate Etherum Wallets for all my customers. I run a business and would love my customers to be able to create their own Etherum Wallets to receive and send.
0
votes
0answers
7 views

How can I use account1 to sign but use account2 to send signed transaction? Who will pay the gas? [closed]

If I use account1 sign transaction but use account2 send signed transaction who will pay the gas? Account2? Any sample code?
0
votes
1answer
10 views

Truffle Test: Setting blockTime

I'm using Truffle and I want to increase the blocktime to mimic that of the mainnet when i run my tests. As i understand it, Truffle has already instantiated a web3 instance that's ready to use so i ...
0
votes
0answers
6 views

Whether I can use web3.js and ethers.js at the same time? [closed]

Why I can use ethers.js and web3.js together? Thanks. In same nodejs.
2
votes
1answer
45 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
29 views

Error: "Transaction ran out of gas. Please provide more gas:

I'm facing a little issue here, that's the mintTo function from contract for NFT. Which I require the sender to send a value with >= 0.1 Ether: pragma solidity ^0.5.0; import "./TradeableERC721Token....
0
votes
1answer
77 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....

1
2 3 4 5
75