The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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

About send Ethereum Classic (ETC) coin

Need guideline for send ETC coin using web3js,As per documented flow I understand we can access all methods same as ETH but I have query regarding set provider for ETC after that I can connect to ETC ...
0
votes
1answer
45 views

I get the UnhandledPromiseRejectionWarning: Error: Transaction has been reverted by the EVM in the contract execution

I wrote a simple code that exchanges my eth with dai in Rinkeby using the ethToTokenSwapInput function from the Uniswap exchange protocol. I am getting the UnhandledPromiseRejectionWarning: Error: ...
4
votes
1answer
45 views

couldnt understand implementaion of UpgradeabilityProxyFactory

I want to use UpgradeabilityProxy provided by zeppelin, they have one method createProxyAndCall which they say initialize the new implementation with data parameter we provided which looks like: * ...
0
votes
0answers
47 views

TypeError: Cannot read property 'Crypto' of undefined

I have a code block for sending transaction let address_from = '0x0b2af884cc5a98816ba186ca6f7e839a7dd36053'; let address_to = req.params.address; let nonce = web3.eth.getTransactionCount(...
0
votes
1answer
40 views

Smart contract copy

So I am in a permissioned blockchain setup, using Quorum as a client. I have deployed a private smart contract to members A and B, and now I have the need to redeploy it, giving access to member C. ...
0
votes
2answers
61 views

Where web3.eth.accounts.create() creates new account?

I am using ganache which creates an ethereum blockchain with 10 accounts. The blockchain created by ganache is linked with truffle's pet-shop box using web3. I want to add a new account in that ...
0
votes
0answers
31 views

Deploying contract using web3js but failed

I am a beginner for solidity 👶 My question about deploy using with web3js. I have two smart contract and in main contract I have a createContract function which is create a new subtoken contract ...
0
votes
1answer
25 views

Web3.js is taking lot of time to return a promise

Web3 is taking time near about 5 minutes even after the transaction got 3 confirmations to return a promise from a smart contract which is deployed on kovan testnet. Please give some suggestion how to ...
0
votes
1answer
42 views

Truffle: 'func.call()' retrieves the return-value of a non-constant function

I've just learned that one can easily obtain the return-value of a non-constant function, by using myContract.func.call() (instead of myContract.func(), which retrieves a response object). Up until ...
0
votes
1answer
18 views

How can i `ecrecover` in solidity to verify the digest produced by `web3.utils.soliditySha3` in JS side?

Javascript side: id = 128 uri = "xxx://xxx" hash = web3.utils.soliditySha3(id,uri) sign = web3.eth.accounts.sign(hash1, privateKey) Solidity side: function(uint256 id, string memory uri,bytes v, ...
0
votes
1answer
41 views

web3 on react-native : Error: Returned error: insufficient funds for gas * price + value

using web3@1.0.0-beta.33 and react-native@0.59.10, because latest web3 have install issue on react-native, after deep research 1.0.0-beta.33 is suitable on react-native const web3 = new Web3("https://...
0
votes
1answer
36 views

How do you activate an else statement after a web3.js call is thrown?

General purpose of code: I am trying to create a helper function that returns true if an element exists in a dynamic array in solidity, and false if an element does not exist at a certain index ...
0
votes
0answers
27 views

ERC20 is not working after deploy

I've deployed an ERC20 like this: const fs = require("fs"); const Web3 = require('web3'); const testnet = 'http://localhost:8545'; const PrivateKeyProvider = require("truffle-privatekey-provider"); ...
0
votes
0answers
16 views

How can I update the web3.js of Geth? [duplicate]

Web3.js has so many newer versions than one of Geth. I want to use the 1.2.0 version (or newer) web3 with Geth. When compiling, can I replace the old version with any newer version?
1
vote
2answers
55 views

invalid bytes32 value - Maker Contract Call

I am trying to call the Maker CDP Contract manager smart contract. I want to get the information from this public mapping in the contract. mapping (bytes32 => Cup) public cups and should ...
0
votes
1answer
40 views

getPastEvents cannot handle multiple requests?

When I send about 100-120 requests in async, it is fine, the event will give me a response. But above 150 or so, I get "Invalid JSON RPC response: "" Web3JS 1.2.1 Geth Info: Version: 1.8.12-stable ...
0
votes
0answers
18 views

Error: IPFSInbox has not been deployed to detected network

It's my first time writing smart contract in solidity and using IPFS to develop my dapp. I don't know how to solve it and why it pops up this errorNo web3 instance injected, using Local web3. Error: ...
3
votes
1answer
87 views

MetaMask blocks Web3 requests

I just set up a Block Explorer to interact with my private blockchain. The private Blockchain runs in a VM. The host system connects to the Block explorer (also on VM). When I have meta mask ...
0
votes
1answer
25 views

How to signTransaction of a smart contract methods?

I have a smart contract contains this method: function addOneUser (User memory _user) public { bytes32 hash = keccak256(abi.encode(_user.name)); users[hash] = _user; } I want ...
0
votes
0answers
24 views

Payable function not working properly

Hi everyone hope I will be clear enough with the explanation because I couldn't find a proper solution. I am just trying to checkout an item with my buy function but it seems like I am stuck.Here is ...
0
votes
1answer
43 views

Load Smartcontract in Nodejs

I created the server based on golang. This server can load smart contract that is deployed using its address. It works on my local machine, but it does not work on EC2 instance. So I decided to ...
1
vote
0answers
38 views

EIP712 implementation for web3 1.0

I tried replicating the instructions in this article to implement EIP712 signing, however, it doesn't appear to work for web3 1.0 versions. https://medium.com/metamask/eip712-is-coming-what-to-expect-...
0
votes
0answers
24 views

invalid JSON RPC when using custom domain name

geth --testnet --networkid 3 --syncmode "fast" --datadir "." --cache=2048 --rpc --rpcport 8545 --rpcaddr example.ropsten.hk --rpcvhosts example.ropsten.hk --rpccorsdomain "*" --rpcapi="web3,miner,...
2
votes
2answers
40 views

Why can't I use a contract method in my Chrome console?

I am attempting to call a method from a smart contract from my chrome console. My dApps index.html file is deployed locally at http://127.0.0.1:5500. I set up web3 and instantiate a smart contract ...
-1
votes
2answers
105 views

How to get response from Solidity Smart contract by Web3 client?

Here is the Smart contract code. I want to get the result of function of UserRegister by using web3. function UserRegister(string memory userName,uint feiyong ) public payable returns(string ...
1
vote
3answers
85 views

Alternatives to Metamask

What are existing alternatives to metamask with that works online inside existing browsers, that don't require installing a browser extension? What are some of the tradeoffs between them?
0
votes
0answers
17 views

How to filter by string parameter , web3 2.0.0-alpha.1 Solidity events?

I'm trying to filter some events , and I noticed since I updated the web3 to version 2.0.0-alpha 1 the event catch is a little bit different. I have a Smart Contract with this event : event ...
0
votes
1answer
40 views

Cannot Find Module Error for Truffle-contract

Error:- Uncaught Error: Cannot find module './truffle-contract.min.js' at c (web3.min.js:1) at c (web3.min.js:1) at index.html:27 <!DOCTYPE html> <html lang="en"> <head&...
1
vote
1answer
19 views

Trouble accessing an array inside a struct inside a mapping via web3

Here are a few relevant code snippets from my smart contract struct Constituency{ uint16 id; string name; uint64[] cans; } mapping(uint => Constituency) public constituencies; ...
-1
votes
1answer
33 views

Where is web3.eth.abi with the version of web3.js given with Metamask

Seems the docs doesn’t contain the answer. Looks like that part was moved elsewhere with latest transaction. The aim is to access encodeFunctionSignature() for knowing to which function name the ...
1
vote
1answer
54 views

Web3 - Assign nonce to smart contract transact

I have a smart contract. I want to execute one of its state modifying functions. This is the code: const result = await smartContractObject.methods .addSomething(_valueToAdd) .send( { gas: '...
-1
votes
2answers
32 views

contractAddress: null

I use sendSignedTransaction to send the contract and return contractAddress: null let rpcUrl = "https://ropsten.infura.io/v3/6756e6f8f0e34482a262a7cf1d15f2c2"; var web3 = new Web3(new Web3....
1
vote
1answer
25 views

Getting an error when (attempting to) using Web3js

I'm trying to connect a smart contract to a very simply front end that has html/css/js. I keep getting an error when trying to use web3 to connect - I have the code below but the terminal is giving ...
1
vote
1answer
10 views

ganache test returns characters instead of numbers

mapping(uint256 => uint256) public amount; function saveAmount(uint256 _id, uint256 _amount) public { amount[_id] = _amount; } I have a function that saves amount in mapping. When I test ...
1
vote
1answer
47 views

Both web3.eth.accounts.create() and web3.eth.personal.newAccount() not working

I'm making a dApp on reactjs. I wanted to create a new account and have done it trying 2 methods this.web3.eth.personal.newAccount() this.web3.eth.accounts.create() I have attached the code below(...
1
vote
0answers
21 views

hexToNumberString not require in new web3 versions?

I have such code before let profit = await contract.methods.calculateFundProfit().call() profit = web3.utils.hexToNumberString(profit._hex) but after update web3 version, do I need do only this? ...
0
votes
1answer
58 views

getAccounts in web3 js undefined

I am working on dapp with web3js 1.0.0.37-beta with reactjs. I got blank in web3.eth.getAccounts. Following is my code App.js import React, {Component} from 'react'; import '../node_modules/...
0
votes
1answer
14 views

Get gas limit beforehand with Web3

I know that web3 exposes a function to estimate gas limit, but is it accurate when sending to a contract? AFAIK the amount of gas I'm gonna need if sending to a contract depends on the contract code, ...
0
votes
0answers
55 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 ...
0
votes
1answer
51 views

How to unlock account to deploy contract without using personal.unlockAccount()?

When I have account keystore file on geth node http://192.168.43.201:8545 , I can deploy a contract like below: const web3 = new Web3('http://192.168.43.201:8545'); ... const contract = new web3.eth....
2
votes
2answers
49 views

Web3 - Access return value of events

I want to get the value that my smart contract returns in javascript. Here is the contract. (version 0.4.25 - web3 version 1.2) pragma solidity ^0.4.25; contract SimpleStorage { uint public ...
0
votes
1answer
165 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'); ...
0
votes
1answer
33 views

Can't log struct member in truffle test

Contract : mapping (bytes32 => MyStruct) public myMapping; struct MyStruct { uint256 myMember; uint256 someOtherMember; } Test (Truffle) This works: let ...
0
votes
1answer
27 views

Code:const web3 = new Web3(window.web3.currentProvider) Error: window.web3 is undefined

I am going to connect my contract with the website.However,there was something wrong with the web3? I'm not sure. import Web3 from "web3"; const web3 = new Web3(window.web3.currentProvider); const ...
0
votes
2answers
16 views

How to prove existence of a function with estimategas

How can I prove the existence of a function in a smart contract with the EstimateGas ? Thanks.
3
votes
2answers
97 views

Solidity - Return value of Smart Contract Transact

Why do Solidity transact functions not return any value? Here is an easy example. I tested it in remix and web3. pragma solidity ^0.4.25; contract SimpleStorage { uint public storedData; ...
0
votes
3answers
74 views

Response stuck when creating contract

I am creating a contract on my local blockchain network using web3. On my node , contact is created and address is generated. But on node application, response is struck. Here is my node code: ...
2
votes
1answer
84 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 ...
2
votes
1answer
33 views

How are we able to send 512 bit hash as a bytes32 variable?

I have a code that is working: solidity function checkSignature(bytes32 h, uint8 v, bytes32 r, bytes32 s) public pure returns (address signer) { bytes memory prefix = "\x19Ethereum Signed ...
1
vote
1answer
46 views

Get Ethereum private key from loom private key

I deployed my contracts to a local dapp chain with the private key generated by Loom. Since that private key is not compatible with the Ethereum one, I cannot use web3.eth.accounts.privateKeyToAccount ...