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

Web3 Creating accounts on Private Chain

Im trying to use web3.eth.personal.newAccount to create a new node on a private chain, when I run web3.eth.getAccounts() I see my new account being added but when I put the address/password into a ...
0
votes
0answers
11 views

I cannot transfer the rights to use the smart contract to another wallet

I have a smart contract. I own, it belongs to my wallet. I am trying to implement a function to transfer the OWNERSHIP of this smart contract to another wallet. I have two solutions, but for some ...
0
votes
0answers
12 views

Web3 1.3 Contract method call returns empty string

I am new to solidity and I am facing a strange issue. I have created the following Contract: pragma solidity >=0.7.0 <=0.8.0; //SPDX-License-Identifier: UNLICENSED contract Lottery{ ...
0
votes
0answers
12 views

How can I call TX Timestamp info via Web3.JS

How can I call the timestamp information of the pending tx datas I tried everything I could not.?
0
votes
0answers
5 views

“Getting AGE/TIMESTAMP of a Pending Transaction from a Transaction Checker”

Can I get TIMESTAMP of a pending transaction as soon as it's added to etherscan.io recent transactions list? I'm using GETH and WEB3 for a transaction checker and it's fetching me recent pending ...
1
vote
0answers
9 views

How to continuesly fork mainnet on latest block

How do I keep the fork mainnet use the latest block using web3? I need to fork mainnet to latest block before I send the transaction What originally i do is just run the ganache fork command which ...
0
votes
1answer
11 views

Keccak256 hash different in solidity and web3js

I am trying to sign a message in NodeJS and verify the signature with smart contract. Here is my code: async function prepareAndSignMessage(to, amount, referenceTransaction){ let contractInstance =...
0
votes
1answer
12 views

Give Web3 a description of smartcontract function

Today i tested something on Uniswap when I came across a feature of Metamask or Web3 where a specific function call can have a custom Description. As seen in the Picture, Metamask somehow got a ...
0
votes
0answers
9 views

How can I get a list of all owners of an ERC1155 NFT by using a web3 call?

With ERC721, there's the 'ownerOf' function that takes a non-fungible token's id and returns the owner address, but ERC1155 doesn't officially require that a function like that be implemented. I made ...
0
votes
0answers
11 views

Listening for events on real time with Web3

I want to update UI elements of an app based on contract events. My problem is, that I do not receive any events that happen after the site has been loaded (seems like the subscription does not work). ...
0
votes
0answers
7 views

How to use web3 when one smart contract is interfacing with another?

A few months back I posted this question on this form. Since then, I've used the interface method to make my smart contracts interact together. I didn't have any problem while testing and developing ...
0
votes
1answer
23 views

Is there any way to access abstract contract in web3?

I have a IERC20.sol file which is the interface of ERC-20 standard. In my Dapp, I don't want to implement any ERC-20 tokens. I just want to use the existing tokens so all I need is a interface and the ...
0
votes
1answer
11 views

How can I automate smart contract interaction

I've deployed a smart contract to the blockchain with few functions. I want to know how I can interact with the code e.g. > Contract has 2 functions - deposit and withdraw. Now, instead of me ...
0
votes
0answers
8 views

I am having an error when I interact with my smart contract

first of all here are the codes var web3 = new Web3(Web3.givenProvider); var contractInstance; var x = 0 $(document).ready(function() { window.ethereum.enable().then(function(accounts){ ...
0
votes
0answers
12 views

ganache forked mainnet always revert even on success transaction in mainnet

I am trying to impersonate an account using forked mainnet what I did was unluck the unknown account, approve the erc-20 token and copy then send the transaction of that address. Everytime the address ...
0
votes
0answers
9 views

Ganache forked mainnet impersonate account transaction error

I am trying to impersonate my contract using forked mainnet on ganache whenever the account send a transaction I dryrun the transaction first on forked mainnet but it always give me Error: Returned ...
0
votes
0answers
31 views

I have a problem with the transfer of ownership by a smart contract

I have a smart contract. I own, it belongs to my wallet. I am trying to implement a function to transfer the OWNERSHIP of this smart contract to another wallet. I have two solutions, but for some ...
0
votes
0answers
21 views

retrieving web3 contract.ownerOf NFT ERC721

I'm playing around with web3 and frontend trying to read something off the ethereum blockchain. What i wanted to do is to verify the owner of a NFT (erc721). I've used this piece of code here that ...
1
vote
1answer
9 views

Adding interval on incoming data from web3 subscription

I am trying to set an interval on the incoming data from web3 subscription and use alchemy as provider to avoid rate limit. I tried adding setInterval on the data to do this but it returns undefined ...
0
votes
0answers
11 views

Events and callback

I can't quite understand how events work with web3.js. Events work asynchronously and callbacks are executed when the result returns. These callbacks are already defined or I have to write them myself....
1
vote
1answer
38 views

Web3: current best practice to connect Metamask to Chrome?

I am currently trying to connect my React front-end to Metamask on Chrome. When using the following method, I get that ethereum.enable() is deprecated: if (window.ethereum) { window.web3 = new ...
0
votes
0answers
12 views

The data type of the return value of the solidity function has changed

As you can see, I have designed a struct in the solidity.There is a function in the solidity with the return value type User mapping(address => User) public _userInfoMap; struct User{ uint ...
0
votes
1answer
20 views

web.eth.call() returns a revert even when the transaction is success

I have this snippet to test if web3.eth.call() can check if a pending transaction will revert in advance. web3.eth.call(tx, "pending") .then(result => { console.log(count, "Passed!&...
0
votes
1answer
49 views

Hello. I have a problem with a smart contract transaction between users. Error: gas is missing

I have a problem with a smart contract transaction between users. Error: gas is missing. Here is my function: async function transactionContract() { let signerAddress = gettingOwnerByKey( &...
0
votes
1answer
22 views

How can i get contract data from certain block [closed]

I need to get some data from an smart contract, but i want to generate something like history How can i get that data until some block or maybe be able to replay the blocks somehow? Im using python ...
1
vote
1answer
36 views

How to check if a pending transaction nonce has duplicate?

Is there a web3 function or other workaround to check if the pending tx has duplicate nonce?
0
votes
0answers
27 views

Is there a way to get the ABI of a deployed contract by knowing its address? [closed]

I have a node (infura) that has to return a result to a smart contract in my blockchain network. To do this I have to create an instance of the contract let MyContract = new web3.eth.Contract (abi, ...
0
votes
0answers
27 views

Cannot Deploy to Rinkeby using Truffle, Infura, and Node

I am trying to deploy a contract to Rinkeby using Node and Truffle but I get a lengthy error: Truncated Error: Attempting to deploy from account 'MYACCOUNT#' [object Object] [object Object]...
0
votes
0answers
11 views

Forked Mainnet `INSUFFICIENT_OUTPUT_AMOUNT` on a transaction

I am currently using ganache and forked mainnet to test if a transaction in advance will fail or not. I get error INSUFFICIENT_INPUT_AMOUNT on ganache while the tx success on mainnet and observed that ...
0
votes
1answer
13 views

How do I Encrypt Transaction Input Data Encode ABI

I'm buying erc20 token how can I encrypt my transaction input data . I using Javascript WEB3.JS method Can you help me with this? like this when try on check etherscan. Warning: Unable to decode input ...
0
votes
1answer
34 views

How does myContract.events.MyEvent ([options] [, callback]) work?

I'm trying to understand how events work. My contract emits an event which is captured by the node (I'm using web3js). I need to extract the submitted parameters (msg.sender, id_, location_). I need ...
1
vote
1answer
20 views

Is there a solution to implement this scenario? [closed]

Suppose a user1 in a network wants to change data in a smart contract function, but before this transaction is pushed to the chain the other participants of the network receives a notification saying ...
1
vote
0answers
31 views

What does sendSignedTransaction return?

I want to call a method in the smart contract (UpdateWeather) that goes through several steps before returning the result (an integer). I use sendSingendTransaction but I have doubts. Is the ...
0
votes
0answers
10 views

RPC call with web3

I am using extend on web3 to use the evm_unlockUnknownAccount on ganache whit this snippet const localWeb3 = new Web3(ganache.provider( {fork : web3ws.currentProvider} )); localWeb3.extend({ methods:...
1
vote
2answers
28 views

issues after removing window.web3

I am taking a smart contract course on udemy which belongs to 2017.Many web3 versions have come since then which is making me confused to implement what i am learning in newer versions. When i want to ...
1
vote
1answer
28 views

I am getting UnhandledPromiseRejectionWarning: Error: Returned error: execution reverted error while calling my smart contract methods using wb3js

Here is my code const web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/v3/2a6f2bf907594edfbe6343066c394df8")); // web3.eth.handleRevert = true var address = "...
1
vote
0answers
12 views

Hardhat Can't resolve 'console' on react project

I have a react project and initialized hardhat config then installed the necessary packages but I am getting error when I require hardhat on my project const hre = require("hardhat"); This ...
1
vote
1answer
25 views

How can my decentralized web application hosted on a cloud application (like AWS) interact with a contract deployed from my localhost

I have a decentralized web application that is hosted in the cloud. I recently deployed a smart contract to two different test networks Ropsten and Goerli - my contract deployed to the Ropsten ...
1
vote
0answers
36 views

interaction between the oracle smart contract and the oracle service [closed]

I want to modify this code to recover the temperature. the oracle smart contract issues a RequestWeather event with the city I need to know the temperature. The oracle node captures the RequestWeather ...
2
votes
0answers
28 views

What are the front running bots?

I've been seeing too many threads about this. I was curious about what are they how do they function? Is it basically an automated trading algorithm that just executes trades when a cryptocurrency is ...
0
votes
0answers
24 views

Transactions not getting mined (Web3.js)

I'm trying to make a simple ether transaction with web3.js. Most times I try to execute the transaction, I get the following error: Error: Transaction was not mined within 750 seconds, please make ...
0
votes
1answer
39 views

getting Error: Invalid JSON RPC response: “” when calling getBalance from web3 js library

I'm exploring web3 following instructions from the docs and running the code below. The function throws with the error message being: Error: Invalid JSON RPC response: "" For context the ...
-1
votes
0answers
27 views

Web3.js getPastEvents Returns Event Undefined Proxy Contract

LATEST UPDATE: Actually, you can't use myContract.events.MyEvent or web3.eth.subscribe('logs') to get past events. Even though you can specify the fromBLock with block of these functions, it doesn't ...
0
votes
1answer
32 views

myContract.events.MyEvent() vs web3.eth.subscribe('logs', …);

I'm confused about the difference between myContract.events.MyEvent() and web3.eth.subscribe('logs', ...); Both are subscriptions to events, correct?
2
votes
2answers
34 views

What is in return when listening to an event?

In Hellos.sol, there is event initContract after constructor is called. Here is the solidity code: pragma solidity 0.7.0; contract Hello { address owner; uint256 value; event ...
1
vote
0answers
24 views

capture an event issued by a smart contract and make a web request [closed]

I am making a project using Ethereum and web3js. In this project , I have contract A and contract B (oracle smart contract). When A calls a function of B, B emits an event. An oracle service captures ...
0
votes
0answers
30 views

web3 - Uncaught TypeError: Cannot read property 'methods' of undefined

I am made a coin flip dapp and am using ganache to deploy it. A player has to selects a number between 0 and 1. I read this error means "the contract is undefined" but I do not know how to ...
0
votes
1answer
22 views

Run bot on same server as your own Ethereum node

I have been tinkering with running a bot on a server and it uses Web3 to talk to my solidity contracts via infura. Given the latency of a bot running in location X and the infura API being based in ...
1
vote
1answer
31 views

using only html page for frontend with web3 or ethers.js

I was just wondering, since we are able to write js scripts inside html docs, would we be able to create a dapp with fully functional html front end for our smart contracts? Or would we need to use ...
0
votes
0answers
9 views

dynamic value (amountEth) doesnt work in very basic web3 UI webpage

I am a newbie and try to learn to code web3 interfaces to call basic smart contract funtions. For now I made a button - when clicked it send 1 ETH to a specific (static) address. This worked fine... ...

1
2 3 4 5
83