Questions tagged [web3js-v1.x]
For questions specifically about version 1.x of the web3js Javascript API and library for Ethereum
73
questions
0
votes
0
answers
7
views
Minting react app
I build a sample minting app with React, When I built the app on localhost everything ran correctly, but when deploy the app on Vercel appear a blank page. what is wrong?
1
vote
1
answer
2k
views
How to web3 "encodeFunctionCall" a payable function?
I want to encode a call for mint() payable with a msg.value of 8 ETH.
My code:
web3.eth.abi.encodeFunctionCall({
type: 'function',
name: 'mint',
payable: true,
value: web3.utils.toWei(&...
0
votes
1
answer
2k
views
How to get the balance of an ERC 20 token for an Ethereum address using Web3js?
I'm trying to implement the question in a web3js app I have.
The code I have so far is:
// Get ERC20 Token contract instance
let contract = new Web3Client.eth.Contract(minABI, tokenAddress);
// Call ...
1
vote
0
answers
3k
views
TypeError: Cannot read property 'length' of undefined
When I want to call MyContract's function like:
address payable owner = 0x12345.....;
function addHouse(uint _lease,uint _totalRent,uint _tenantNum)public{
houseInfo[owner].push(House(...
1
vote
1
answer
282
views
Cannot send ETH to contract using solc 0.8.4 using truffle console (revert)
I spend like 6 to 8 hours on this issue, finally asking here on the following problem.
Goal
I want to sent ETH from one of the default Ganache addresses to the deployed contract SportBet.
Versions
...
2
votes
1
answer
780
views
Issue in Dapp using Angular 11.1.0 and web3 1.3.4 and Rinkeby metamask, getting error on new Web3(window.web3.currentProvider)
I am trying to create DAPP using Angular 11.1.0. I am able to deploy the contract on Rinkeby test network successfully. But on Client side getting below error on loading [email protected] js.
Getting error:
...
4
votes
1
answer
1k
views
How to set multiple nodes in HttpProvider web3 v1.2.0
I'm working with Nodejs application, and using a multi-node setup on different servers.
If I have single node end point like http://localhost:8545 I can use Web3 providers as below
var web3 = new Web3(...
1
vote
1
answer
2k
views
How to get balance of an address using web3js
Here is a very simple code that i am using :-
let web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/XXXXX"));
var balance;
web3.eth.getBalance("...
1
vote
1
answer
3k
views
Transactions stuck at pending on ropsten test net from one day
I am Writing a simple script for ERC20 token transfer method. which sign transaction offline and then submit it to network.
Transfer method encoded data :
var encoded = await MyContract.methods
...
1
vote
2
answers
800
views
Offline creation of signed contract transactions with web3js v1.2.11
I'm attempting to sign a contract transaction offline using web3js v1.2.11.
signingAddr = //my eth address
signingPk = //my private key
// docs: The options object for the contract instance. from, ...
1
vote
1
answer
172
views
Accessing contract functions from web3 and javascript
I have deployed a contract in a private blockchain using remix and ganache. Now I want to interact with it trough web3 and the console from my browser, but I'm not managing to interact with the ...
1
vote
1
answer
136
views
What's the max number allowed as nonce? [duplicate]
I tried to generate nonce using this formula, so I can avoid 'underpriced' problem and nonce conflicts
nonce: web3.utils.toHex( Math.round (Date.now() / 1000 - 1586000000) ),
But simply these ...
1
vote
1
answer
628
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
1
answer
213
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),
"[...
3
votes
2
answers
8k
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....
3
votes
2
answers
1k
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
2
answers
2k
views
How to use sendSignedTransaction without waiting for confirmation?
I am sending ether to multiple accounts and I want to send them without delay or waiting for confirmation of previous transaction.
const fs = require("fs");
const os = require("os");
const Web3 = ...
0
votes
2
answers
701
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
0
answers
419
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
1
answer
194
views
How can you work around Web3 1.0s bug to check for transaction confirmation?
The following includes a null Tx id:
web3.eth.getTransaction('0x2fc36f9c6593bc1232b3466832c6ee38b5b2b3b4a54be3f6c68fb06e8d82e452', function(error, result){
if (!error) {
console.log(result....
2
votes
1
answer
4k
views
How Can You Find the Ethereum Provider on Web3 Browsers Other Than MetaMask?
MetaMask provides the following way currently to find a provider for their upcoming 2020 breaking change:
// Running on the page, in the browser
// This API will go live in Q1 2020
// It will be the ...
1
vote
0
answers
719
views
Help me fix Error: No "from" address specified in neither the given options, nor the default options. I'm use MetaMask
file web3.js
import Web3 from 'web3';
const web3 = new Web3(window.web3.currentProvider);
export default web3;
file image.js
import web3 from './web3';
const address = '...
0
votes
1
answer
356
views
How to return the result of a Solidity view method from a javascript function?
I want to determine a view function of a smart contract result in web3js 1.x
Suppose we have a view function getName(uint code) and want to get the name of a person having his code. So we write:
...
1
vote
0
answers
2k
views
Solidity calldata for an array of structs
I'm trying to create the calldata offchain for an on-chain low-level call to a method that accepts an array of structs as an argument. I'm not sure how to encode the calldata for this.
Here's a ...
1
vote
2
answers
1k
views
Insufficient funds when transferring ERC-20 token using web3
I am trying to send an ERC-20 token on Mainnet using web3 v1.x and Infura. I get the error in the title while executing this code.
I have a balance of about 0.14 ETH
var provider = new ...
1
vote
2
answers
3k
views
How to provide data for sendTransaction using web3.js 1.0
I'm using web3.js 1.0. I want to use sendTransaction method to call a contract method, but I don't know how to provide data parameter for it.
For example suppose we have a contract named myContract ...
0
votes
1
answer
256
views
Transaction being reverted by EVM during contract creation (Web3 / ethereumjs-tx)
Hey guys I am running into an issue deploying a smart contract with Web3 to the Ropsten network. The code is running seemingly correctly, and there is a contract address being created, but if I check ...
0
votes
1
answer
67
views
Web3 balance is showing OmiseGo balance but not Bitball
You can see on Etherscan that I have 2 types of tokens in my wallet:
https://etherscan.io/address/0xb8fd65fc6919c5b97453eaba6b895144597985b2#tokentxns
2.3 OmiseGo and 10,000 Bitball
I have a short ...
1
vote
2
answers
1k
views
Web3 CDN error: regeneratorRuntime is not defined
When I include the web3 js CDN to my html file, I receive this error
web3.min.js:1 Uncaught ReferenceError: regeneratorRuntime is not defined
at Object.<anonymous> (web3.min.js:1)
Here is ...
0
votes
1
answer
647
views
problem connecting web3 v 1.2.1 with metamask : 'currentProvider' of undefined
I am using Web3 v1.2.1 with nodejs v10 and following this link. I am having issue connecting with metamask,below is my code snippet:
const Web3 = require('web3')
const window = require('window');
...
2
votes
1
answer
642
views
Which version of web3 shall i be using now?
I found the documentation of version 1.0.0 which was released on the 6th of August here. I was told that v1 is not stable and very different than earlier versions. But when i check the available ...
0
votes
1
answer
130
views
Where Do I Find web3.min.js for Beta 55?
There is this issue on github (among several other duplicate complaints): https://github.com/ethereum/web3.js/issues/2623.
There is also this stack question: How can the web3 library be imported in ...
0
votes
1
answer
1k
views
Why Web3 event callback fires multiple times same as the number of the solidity smart contract emitted that event in past?
I am just learning, solidity with react and web3 and I am facing the issue on page load the callback event of web3 called multiple time the number is same as I called a solidity function and that emit ...
0
votes
1
answer
429
views
How does .on work in Web3 1.0, and why do I get duplicate results?
I don't understand what .on event handler does in Web3. Take this example for signing a transaction:
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('...
1
vote
1
answer
2k
views
How do I asynchronously wait for Contract.events.MyEvent data to be returned in Web3 1.0?
The documentation is sparse, and the examples all mix async, arrow callbacks, and promises. One problem I've run into is while subscribing to an event, I can't seem use asynchronous syntax within or ...
3
votes
2
answers
139
views
What happened to the official documentation of web3.js v1.0?
It should be at https://web3js.readthedocs.io/en/1.0/, but now I'm getting this:
Does anybody happen to know why this wonderful tool has been taken off line?
0
votes
1
answer
2k
views
How Do You Parse Web3 Retuned JSON Objects of Events?
I am using Web3 1.0 to listen to events from a contract like this:
tokenContract.events.AddressList({
fromBlock: 6020474,
toBlock: 'latest'
},
(error, events) => {
...
0
votes
1
answer
278
views
Does web3.eth.wallet.create set the newly created wallet file as the 'global' source of addresses for the web3 instance?
I'm playing about with [email protected] and I'm setting an HttpProvider on Ganache for my web3 instance:
this.web3Instance = new Web3(new Web3.providers.HttpProvider(environment.ethereum.provider)...
1
vote
1
answer
453
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",
...
0
votes
0
answers
803
views
How to get the value from the frontend form and save value to the blockchain using +web3 1.0.0-beta.37 + reactjs
I am writing my first Dapp and want to save the value of the form to the blockchain. I am Using React and web3 js 1.0.0-beta.37 on the frontend. Also I am new to react.
Following is my App.js
...
1
vote
2
answers
861
views
Why web3.version.api shows undefined for web3 1.0 and not undefined for web3 0.20.3?
I'm trying to use MetaMask and web3js to talk to my smart contract. Below are my test codes.
This is without defining a web3 js file and I get the result "0.20.3" at console.
<script>
window....
1
vote
1
answer
728
views
What's the difference between web3.eth.personal and web3.eth.accounts?
I noticed that web3.eth.personal has unlockAccount method but not web3.eth.accounts. Why not?
Is web3.eth.personal for personal or single account use while web3.eth.accounts for multiple accounts?
1
vote
2
answers
588
views
web3 1.0 events never fire
First off, my setup.
System: ArchLinux
Ganache: v2.0.0 (correction, v1.3.1)
Solidity: 0.5.8
web3: 1.0.0-beta.37 (anything higher than 37, contract wont deploy)
Node: 'latest'
Some background and ...
0
votes
2
answers
10k
views
SyntaxError: await is only valid in async functions and async generators in web3js [closed]
Below is my code snippet. I wish to wait for the transaction hash value so that I can return my Javascript function with the hash value.
But I get the error "SyntaxError: await is only valid in ...
0
votes
0
answers
179
views
Problem with send method in Infura
Newly Infura site has been changed its interface.
Before that all methods of our client program was successfully working, but now when I logon to Infura, all whitelists has been removed. I added our ...
1
vote
1
answer
247
views
using web3 1.0 for approving signed transaction before appending to the blockchain
I am making a dapp using web3 1.0. I have a contract that stores medical data for every patient (represented by account). Their medical data can be set by doctor (account address) using the set ...
1
vote
1
answer
332
views
Cannot deploy contract
I'm having difficulty deploying a solc-compiled contract to ganache test network using web3.
package.json
{
"name": "smartinvoice",
"version": "1.0.0",
"description": "",
"main": "index.js",
...
0
votes
1
answer
632
views
Unlocking account web3.js 1.0 on AWS Lambda
I'm getting following error message when trying to unlock account on AWS Lambda:
Error: Node error: {"code":-32601,"message":"The method personal_unlockAccount does not exist/is not available"}
...
0
votes
2
answers
91
views
timed transactions using web3-1.0
I am creating a dapp using web3-1.0. I have a contract that stores personal data for a particular user(account). I want to implement a functionality so that a user can share his data (stored in the ...
0
votes
0
answers
224
views
Error: Invalid bytes string given: 0x
Contract code:
function getAddressDnaIds(address owner) external view returns(uint256[])
{
return addressDnaIds[owner];
}
Code causing the error:
var dna = await this.airdrop.methods....