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
0answers
9 views

How to deposit ETH into my contract from React front-end with web3.js, truffle, ganache?

currently, I'm struggling to solve an error that occurs when a user deposits funds into a contract from the react.js interface. ●Environment Solidity Compiler 0.6.0 Blockchain: Ganache 2.4.0 Web3: ...
0
votes
0answers
14 views

Why do I get big number occasionally wherever I call Smart Contract functions using web3js?

I have column named total balance, which has a type of uint and function named getBalance which return its balance and the corresponding functionality has been also declared in Web3js..They get called ...
0
votes
0answers
11 views

geth javascript console: web3.eth.subscribe ==> “Object has no member 'subscribe'”

I must be missing something -- I am trying to use the web3.eth.subscribe() function in my geth node's javascript console and there is no subscribe function. Welcome to the Geth JavaScript console! ...
0
votes
1answer
8 views

How to only watch for new events?

My code: mainContract.events.Transfer({ fromBlock: 0 }, function (error, event) { console.log(event) }) This method returns all the past events (I guess because of that fromBlock: 0) Now my ...
0
votes
1answer
32 views

Help For Web3 MetaMask

I have a complete script When you click the Buy YFD button, this script will be clicked on another contract address and another address will appear to send ETH. How can I change it and leave my token ...
0
votes
0answers
21 views

web3.js convert hex value to string [duplicate]

I use web3.js to read all events and I get the return values when convert this field to original string (string indexed name) original name like mmmm the hex retrund is ("...
0
votes
0answers
14 views

how to get(catch) returned value from function that changes state, in front-end

contract test{ function test1(string memory _name) public returns(address) uint tempData = uint (keccak256(abi.encodePacked(_name,block.timestamp))); address batchNo = address(tempData); return ...
0
votes
0answers
20 views

How To Resolve Uncaught (in promise) TypeError: web3.fromWei(…).toNumber is not a function

i have problem Uncaught (in promise) TypeError: web3.fromWei(...).toNumber is not a function if I delete the code .toNumber () will be like this this my code app.js App = { web3Provider: null, ...
0
votes
0answers
20 views

Transaction has been reverted by the EVM - Help would be insanely appreciated :)

When I call the function myFunction in Remix IDE, it runs, however, when I call myFunction with Web3Js and React, I receive the error: Transaction has been reverted by the EVM: { "blockHash&...
0
votes
1answer
18 views

What is the proper way to check if msg.sender is the contract owner?

I'm trying to make a function that returns true if msg.sender is the owner. This is my function; function isAdmin() public view returns (bool){ require(admin == msg.sender); return true; ...
5
votes
2answers
45 views

How to call a method after a specific tx in a block

With web3, it is possible to call a method of a smart contract at a specific block : myContract.methods.methodName().call(transactionObject, blockNumber, callback) Is there a way to call it after a ...
0
votes
1answer
15 views

How to encode data for low level call? (Compound/Uniswap governence)

I can't get the transaction to execute no matter how much I play with it. I know that it reverts during the secondary call because I always get this revert message: Timelock::executeTransaction: ...
0
votes
0answers
24 views

Require not working properly, always lead to an error

There is a login page and register page in my dapp based on refer and earn concept to authenticate and authorize user respectively..Login part is working fine, but when I try to register a new account ...
0
votes
1answer
37 views

Etherscan “Write” buttons not interacting with Metamask [closed]

For some reason, I cannot get any of the "Write" buttons on Etherscan to intereact with my metamask. I made sure to "connect to Web3" before I proceed to click on the "Write&...
0
votes
0answers
35 views

invalid rpc response on ethereum geth

despite thinking this is an solved issue. After 1 years i have faced this issue, never met before. here is the environment; have dockerize aws ethereum instance which makes mining geth node 8545:8545 ...
1
vote
0answers
19 views

Best practice for securely verifying Ethereum addresses

What is the best practice for users to securely send a POST to an API with their Ethereum address? My inclination is to have the user sign a message with their private key, send the resulting ...
0
votes
0answers
32 views

throw new Error(“Could not find artifacts for ” + import_path + “ from any sources”);

I’m receiving then ex error: C:\Users\xxxxx\AppData\Roaming\npm\node_modules\truffle\build\commands.bundled.js:455204 throw new Error("Could not find artifacts for " + import_path + " ...
0
votes
1answer
11 views

Uncaught ReferenceError: TruffleContract is not defined 2

Firstly, I have viewed (Uncaught ReferenceError: TruffleContract is not defined) and am getting the same error for my smart contract: However, I received this error while having the contract script ...
0
votes
0answers
14 views

How to filter events with indexed bytes32 array?

I have the following event in my contract: event onDocHashSubmission(bytes32[] indexed docHash); I want to filter the indexed docHash array using web3.js var filter = {docHash: ["...
1
vote
1answer
18 views

Why does some of the DAPP uses PHP and how would they do so?

I always wonder how come many DAPPS uses PHP extension at the end of the filename and how did they do so ?? There is slighlty possibility that they are using the Web3PHP library to interact with the ...
0
votes
0answers
17 views

Can't estimate gas on Infura using web3 or axios

I'm trying to estimate gas required to transfer usdt using Infura node but always receive gas required exceeds allowance (12451164) or always failing transaction error. I have tried both using web3 ...
0
votes
1answer
30 views

this error while sending transaction using infura.io . The method eth_sendTransaction does not exist/is not available,

My ERC20 token dapp is giving an error only while using 'transfer function' even when I am using a given address as defaultaccount ( otherwise the error was "No "from" address specified ...
0
votes
1answer
25 views

Sending ether directly from metamask to fallback function

I want to send some amount of ether to a smart contract from metamask (without using web3) and want it to perform some specific tasks based on that amount. For example, if I send 0.9 ether, I want it ...
0
votes
0answers
26 views

How to mimic abi.encodeWithSignature in web3?

I have the following function that I would like to test. function createPlanet(bytes memory _data) public returns (address) { emit ProxyCreated(planetImplementation); emit ...
0
votes
1answer
21 views

Get enum value from smart contract with javascript

This is my contract: enum State { Active, Refunding, Pending, Releasing} function state(uint orderid) public view returns (State) { return State.Releasing; } In one Javascript to ...
0
votes
0answers
8 views

How to change contract interactions to kovan?

I am using newest web3 v1.2.4 const Contract = require('web3-eth-contract'); Contract.setProvider(INFURA_KOVAN_HTTPS); const contract = new Contract(CONTRACT_ABI, CONTRACT_ADDR); I have that code and ...
2
votes
0answers
65 views

Swap tokens to Ether on Uniswap V2 TRANSFER_FROM_FAILED

I am trying to swap DAI to ETH on kovan testnet my wallet and contract both have DAI tokens. Whenever I swap the token through web3 the transaction fails Fail with error 'TransferHelper: ...
0
votes
1answer
32 views

How to get privateKey from Metamask by code? [closed]

Try to create ether wallet by privateKey from Metamask account
0
votes
1answer
27 views

How do I get the decimals of an erc20 contract when the decimals variable is not there?

What is the best practice for doing this? In the ERC20 standard having a public decimals: uint256 is marked as optional. But obviously you cannot display a token balance in the UI without having the ...
1
vote
0answers
16 views

How to filter 2 indexed event fields, both fields array?

I have this event: event onSubmissionBoth(bytes32[] indexed docHash, string[] indexed doc4DHash); Now I log into the event like this: function submitHash(bytes32[] calldata docHash,string[] calldata ...
1
vote
0answers
7 views

Check on `window.ethereum` fails with Metamask active

I have a web frontend which checks for the window.ethereum object as follow if(window.ethereum) { console.log("Metamask available") ... } else { console.log("Metamask not ...
1
vote
0answers
9 views

Unable to inject Web3 1.x version into Metamask

I am creating a dapp which interacts with Metamask on the browser. Metamask is injecting by default the 0.20.x version (deprecating soon) and I am trying to figure out how to inject 1.x version of ...
0
votes
0answers
19 views

How to withdraw some amount(not ether) from smart contract using web3js

I'm trying to make a system something like 'anyone can send some amount to the register centers' and after that those center can withdraw the amount. But this amount is not ether. It can be some ...
0
votes
1answer
25 views

Contract Interaction and Batch Transaction with Web3

I've reviewed most all of the posts on this topic, but none of the answers are doing exactly what I need. I have an application that allows users to submit their tokens from their contract into my &...
0
votes
1answer
23 views

Default gas limit set by web3 is unreasonably high?

I am trying to learn and understand solidity/defi by creating some copies of current popular protocols; I've created a small copy of the Curve Dai strategy from harvest finance, but I'm getting really ...
0
votes
0answers
15 views

Hoe to get the gas used by each transaction in a block in a single API call?

I am working on service which monitors Ethereum based blockchains using web3 API calls. For each new mined block, it has to parse each of the transactions in the block. In addition, it needs to parse ...
0
votes
0answers
37 views

Swap Ether to tokens on Uniswap V2 Router Gas Estimation Error

I am trying to buy DAI tokens from my smart contract using IUniswapV2Router02: contract BuyToken { address internal constant UNISWAP_ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; // ...
0
votes
0answers
9 views

How to get events from transaction receipt in web3JS ( Solidity )

I have tried using events.eventname.returnValues[index] but I am not getting any response. Below is the smart contract code - pragma solidity 0.5.12; contract Dflip{ uint contractBalance; ...
0
votes
1answer
10 views

How do you handle a chain re-org with contract events?

Given that events are fired whenever a transaction is included in a newly mined block, how do you handle the situation when the mined block containing the transaction gets orphaned? Say I have a ...
0
votes
1answer
22 views

myContract.getPastEvents returns undefined event

I am using Web3 1.3.0. Connecting using Node. Also if I try to enter the name of my Event I get an error saying that event does not exist. This is what I get, shouldn't event have a value ? I am using ...
0
votes
1answer
27 views

How do I read ALL of the data in a hashmap/array in a smart contract

To read from a mapping in ethers/web3.js, we do this: const value = await myContract.someMapping(someKey); We can search up one key/value in the mapping at a time. How can I get ALL values within the ...
0
votes
1answer
23 views

Web3 estimateGas error: gas required exceeds allowance?

I would like to estimate the amount of gas required for a transaction before actually sending it with web3. For some reason I always get a gas exceeded error. I've double-checked my solidity code and ...
0
votes
1answer
27 views

Web3 and Metamask interaction doesn't work

I have my Metamask open connected to the Rinkeby network. In Andreas' Mastering Ethereum book he has the following instructions to interact with Web3. "Open a Javascript Console in a Broswer with ...
0
votes
0answers
104 views

Invalid parameters: must provide an Ethereum address. Code -32602

Here is the transaction I am trying to send using web3.eth.sendTransaction: { data: "0x11a861a700...." from: "0x8ccb1711ea5562596f146608fdcf27ccf0d5429c" gas: "...
0
votes
0answers
24 views

Deploying Smart Contract On Infura (Kovan Testnet) Using Web3 & Truffle HDWalletProvider

For better or worse, I'm following a tutorial from late 2018 to help me understand how to deploy a smart contract on Kovan testnet. I'm aware versioning might be an issue, so before I show the deploy....
0
votes
0answers
18 views

Only see the last item of struct using for loop in web3.js

I don't understand what mistake I did in my code. I created a folder before and I was successfully see the correct result of smart contract. For more clarify , Actually I want to see the struct result ...
0
votes
1answer
31 views

Access private transactions(payload or state) on a smart contract using tessera

I am pretty new to quorum/tessera and am trying to set up a small POC with 3 nodes. I followed the 7nodes setup example and similarly deployed 3 nodes on my system using Mysql as the database for ...
1
vote
0answers
16 views

How to catch contract exception in Web3 py?

I'm using infura.io with web3.py and I would like to catch exception thrown by smart contract. Currently, web3.py does not throw any exception even if the contract does, and hence it burns a lot of ...
1
vote
1answer
46 views

web3.py ( web3.exceptions.CannotHandleRequest: Could not discover provider while making request: method:eth_call ) --help

proveedores= ['https://mainnet.infura.io/v3/KEY_KEY','https://ropsten.infura.io/v3/KEY_KEY'] from web3 import Web3 , HTTPProvider, IPCProvider, WebsocketProvider from web3.auto import w3 web3= Web3(...
0
votes
0answers
17 views

A public node URL which can take connection of ethers.js in React Native app

I just installed ethers.js in my React Native 0.63 app and would like to conduct brief checks to see if the lib is up and running. What I need is to have a Ethereum node URL as there is no Metamask or ...

1
2 3 4 5
81