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

How can you make HTML Text Box print the value of console.log?

How can I enter input data value in HTML Text Box? The output is good in console.log, but the HTML Text Box displays the error Object Promise. I want to know how to print the value of web3.eth....
0
votes
1answer
22 views

How can I extract only the transaction input data value of geth in web3.js?

var tto_count = document.getElementById("to_count"); //var transaction = web3.eth.getTransactionFromBlock(1865, 0).input; //var transaction = web3.eth.getTransactionFromBlock(1865, 0)....
0
votes
0answers
26 views

Which Ethereum library is the one to use nowadays? Contract events on mobile must work

I used drizzle in our dApp and contract events work fine on Desktop browsers with MetaMask. However, on mobile (tested with Rinkeby deployment on MetaMask and Status on Android) the contract events ...
1
vote
2answers
37 views

Web3's eth_sign with metamask notification never closes and promise doesn't resolve!

I'm trying to call web3's eth_sign with metamask's provider, like so var signature = await web3.eth.sign(web3.utils.utf8ToHex(randomMsg),acc0) The metamask windows notification pops up and ...
0
votes
1answer
26 views

Gas cost when calling Ethereum view functions on remote or local node

There are dozen of sources on the internet that state the view functions, which are called externally (i.e. from oustide of contract), that do not call other contracts' functions and do not change the ...
0
votes
1answer
71 views

How to estimate gas limit for “payable” smart contract?

We all know that gas limit for EOA to EOA transfer is 21000. I am got stuck at a point and unable to get dynamic gas limit estimation for "payable" smart contract using Web3. When sending Ether from ...
0
votes
0answers
32 views

Web3 library to use with Laravel [duplicate]

Is there some library like web3.js or ethers.js but in PHP to use with Laravel? (Which code is hopefully maintained) Or is PHP just the strongest choice possible I want to work with web3?
3
votes
1answer
55 views

How to create private key from mnemonic and extra-word using web3

In web3js, I can use below code to get private key and wallet address from mnemonic. But how can I get private key if user has mnemonic and extra-word from MEW const ethers = require('ethers'); let ...
1
vote
1answer
24 views

Correct approach of replicating smart contract balances

We are storing user balances on smart contract and as well as on our local db, so that we dont always have to query blockchain for user balance. For this we use contract events to update balances ...
0
votes
0answers
18 views

contract.deployed() not working when trying to submit an html form

i am using web3.js to communicate with my smart contract. how ever, when i try to submit the html form, and then use contract.deployed(), it isnt working below is the code.Html <div id ="input" ...
1
vote
0answers
23 views

How to speed up ethreum transaction after initiating

Is there any possibility to speed up transaction after creating transaction receipt. My project need to similar functionality we have with metamask is there a way we can accomplish this using any ...
0
votes
0answers
20 views

Is there a way to know if a Solidity method will revert?

I have some solidity methods in my contract, and when i make a send in web3.js i would like to know if there is a way to know if the functions are going to revert by using call. Per-example , in ...
0
votes
2answers
43 views

Signature test failed at Truffle js

I'm trying to test validAddress function from my contract ValidationUser, using truffle and test with JS. I checked the V value from the signature and its 27,28 so it is not the problem. Also, I have ...
0
votes
1answer
39 views

How to implement ether transfer from one EOA to another using a contract?

I am working on a private development network set up with geth with PoA consensus. Everything is working well from the geth console. I have written a Solidity contract to initiate some ether transfers ...
0
votes
2answers
32 views

Call and Save Returned Value from Method in React

I am trying to call a method from my smart contract (myMethod) and save the result (result) as a state (this.state.result) in react. However, my state is not being updated to the result. My code is ...
1
vote
2answers
16 views

Contract method returns a Promise instead of a value

I am trying to store a unit from my smart contract in a variable. My code currently looks like this: var variable = this.contractInstance.methods.myMethod().call({from: account, gas: 5000000}); ^...
2
votes
2answers
202 views

Should I set GasPrice on my own?

If I want to send a transaction on my frontend of my smart contract I have the possibility to set the optional field gasPrice. Should I set this value on my own, fetching it from an oracle like ETH ...
1
vote
1answer
46 views

WebSocket connection dropped in Web3.js with Infura

I know this question have been asked several times and many solutions are being proposed as a workaround but not sure why it is not been working on our case. In our case we have to listen for ...
1
vote
1answer
33 views

How can I determine which transactions have failed using a web3.js call

I am attempting to call transactions that execute methods on a contract in order to collect specific data. I am currently using web3.eth.getTransaction(hash) in order to view the transaction ...
1
vote
1answer
46 views

How to send signed transaction to blockchain from different account

I have user's private key to sign a erc20-token transfer transaction in my DAPP. Now I want to send this transaction from different account so that 2nd account pay the gas fee. Is it possible through ...
0
votes
1answer
33 views

How can I make an off-chain call to get the data stored at a specific storage slot on-chain? [duplicate]

I want to get data from on-chain that is not explicitly available through a getter. For example, if I know that there is data at position ...
0
votes
0answers
21 views

Can we determine gas price for a function without deploying it? [duplicate]

I want to store a document hash on an Ethereum network. I have two options. 1st one is to send the transaction directly through a node js application with input field as the document hash ie, ...
0
votes
0answers
28 views

How to listen for contract creation, or all block events?

I'm building a web app with web3 where users can deploy a certain contract and assign some people to it. Inside the constructor of that contract I also output a certain event. I want these assigned ...
0
votes
0answers
17 views

Why is Smart Contract call() method returning NULL in Ethereum Private Blockchain

This is where I am calling the contract function certify_find (hash, callback) { contract.methods.findDocHash(hash).call( function (error, result) { if (error) { console.log("Returned ERROR ...
1
vote
0answers
26 views

In Web3, why is simply signing transactions with private key more secure than unlocking the account and using sendTransaction?

In Can anybody Point out the Difference between Web3.eth.sendTransaction and web3.eth.signTransaction?, the author of https://ethereum.stackexchange.com/a/73705/61096 mentions how unlocking an account ...
0
votes
1answer
40 views

Truffle Contract and nodejs

I want to send a data to a function created in a smart contract. function notarizeHash(uint256 id, bytes32 documentHash) public onlyOwner noHashExistsYet(id) { hashesById[id] = documentHash; ...
0
votes
0answers
18 views

Error calling view function: Returned values aren't valid, did it run Out of Gas?

I compiled my code on 0.6.6 solidity compiler and the code ABI for the function im calling is: { "inputs": [{ "internalType": "address", "name": "user", "type": "address" }], "name": "getAssetIds", "...
0
votes
1answer
32 views

Error: invalid type (arg=“type”, value=“a”) web3.js

I am trying to get the balance of user for specific token type using web3.js. Here is my code block: var tokenContract = new web3.eth.Contract(erc20abi, tokenAddress) tokenContract.methods....
0
votes
0answers
10 views

Writing a function, where users are allowed to deposit their token

i want to create a smart-contract, where it is allowed for users to deposit their ether/tokens in. As far i researched i found this function to get it happen. address owner; // this is where you ...
1
vote
0answers
17 views

is “newBlockHeaders” in web3 emits a legit block?

I'm using web3.eth.subscribe('newBlockHeaders') to track transaction I sent to the blockchain. My question is that is the block emitted from "newBlockHeaders" legit or in other words, the block has ...
0
votes
0answers
28 views

why web3.eth.getBlockNumber().then(console.log) returns 0

I have build a Ethereum Full Node in Ubuntu 18.04. geth is running through the following command: nohup geth --rpcaddr 127.0.0.1 -rpcport 8545 --rpc -rpcapi "wb3,admin,eth,personal,net" --ws --wsaddr ...
0
votes
0answers
9 views

How can I inject a custom web3 provider into the drizzle app when using Nightwatch e2e tests?

I have setup a basic e2e test with a Drizzle VueJS app. It appears that when the tests run drizzle uses the fallback option for connecting to the blockchain using web sockets (ws://127.0.0.1:8545). I ...
0
votes
1answer
32 views

Sending transaction to a Web3 contract object in Truffle test produces 'file import callback not supported'

I need to send a state-changing transaction to a Web3 contract object in my Truffle tests, which is hitting a fork of Kovan in my local ganache chain (ganache-cli --fork https://kovan.infura.io/v3/[...
2
votes
2answers
77 views

How do you normalize client-side web3 libraries?

In my web front-end, I need the ability to interact with the Ethereum blockchain. It's possible a user has MetaMask installed. It's possible a user is using the web without MetaMask installed. It's ...
0
votes
2answers
28 views

Are events collected in Web3js asynchronously?

I am collecting a set of previously generated events, based on certain filters/test, and trying to display them on my HTML page. The code I am using to fetch the events is as follows: var eventList = ...
0
votes
1answer
22 views

web3 providers for ethereum apart from metamask, to connect web and mobile dapps?

I want to create a list of ethereum web3 providers available apart from metamask, which could be used to integrate blockchain functionalities in our apps or dapps created in various platforms (web app,...
0
votes
0answers
15 views

How to connect with web3-eth-miner?

I have connect to my rpc geth via web3 successfully, but I can't connect web3-eth-miner to my server. Here is my code I started my rpc server as geth --datadir ./tolotolo --rpc --rpcapi="db,eth,net,...
0
votes
0answers
22 views

Can you call a contract's (C) function with the msg.sender value of another contract (B) while originating the transaction from a third contract (A)?

If there exists a proxy/implementation system (two contract system) where Contract C (the proxy) only accepts calls from Contract B (Contract B is the owner of Contract C via {owner = msg.sender} in ...
1
vote
1answer
92 views

How to disconnect MetaMask wallet using Web3modal

I am using metamask with kovan to connect to the wallet import React, { useState, useEffect} from 'react'; import Web3 from "web3"; import Web3Modal from "web3modal"; import Navbar from './components/...
0
votes
0answers
17 views

Ethereum Logs since Beginning of Time

I can subscribe to all events in ethereum network (logs, pendingTransaction etc) so I can get only newly generated events (while I am subscribed). For my analysis I need to retrieve all logs from ...
0
votes
1answer
17 views

Event filter not returning correct events web3js

I am trying to filter certain events emitted in the past based on the value of a certain field. The code I have used corresponds to the method specified on the web3js documentation page. However, the ...
0
votes
0answers
17 views

How to deploy my java web app on ipfs?

How to host my java web app onto decentrailsed network like ipfs as my web need a web server like tomcat to run and serve the dynamic content so how can i install tomcat on ipfs and push my war in it ...
0
votes
1answer
14 views

How is data sent to the front-end by a View function?

I am required to send some data from a view-only function to the front-end. I tried using the standard approach by emitting an event with the required fields. However, when the emit call is placed ...
2
votes
1answer
26 views

How to import the Contract type from the web3.js library?

Here's how I can do that in ethers@4.0.47: import { Contract, ethers } from "ethers"; const contractInstance: Contract = new ethers.Contract(address, abi); But in web3.js@1.2.8 none of the ...
0
votes
0answers
10 views

web3.js error ethjs-query gives out error in write contract functions

Hi I am getting error Error: [ethjs-query] while formatting inputs '[{"0":false}]' for method 'getTransactionReceipt' error: Error: [ethjs-format] hex string '[object Object]' must be an ...
0
votes
0answers
13 views

How to unlock eth account using web3?

Hi I'm trying to unlock an account using web3 but it returns empty error. When I use cli it returns true > personal.unlockAccount(eth.accounts[0]) Unlock account ...
2
votes
2answers
33 views

ERC20 contract not able to transfer large amount of tokens

I am building an ERC20 Token. I want to the decimals properly so that people can do transaction in deciamls also. So, I am trying to transfer 10^21 tokens from my address to another. Minted tokens : ...
2
votes
0answers
38 views

Why does Ethereum use JSON-RPC and not gRPC?

I am fairly new to networking protocols especially JSON-RPC and gRPC as they are not nearly as common in web development as REST. I was reading around and seems like gRPC generally performs better. So ...
0
votes
1answer
52 views

How to send an array of structs from web3js to solidity contract?

I am getting an error when passing (javascript array of objects) from web3js, To solidity function that takes (array of structs) as a parameter. could you help me? below is the code and the error /...
0
votes
0answers
21 views

How to deploy huge contracts using web3?

I have a huge contract (which exceeds the default contract code size set in Quorum). I have increased the Code size and Transaction size in the Genesis file to 128Mb. The contract works well when ...

1 2
3
4 5
79