Questions tagged [web3js]

Use this tag with questions about programming for the Ethereum JavaScript API.

Web3.js is open source and continuously updated since 2015. It has everything you need to start interacting with the Ethereum blockchain, giving easy access to accounts, events, smart contracts.

Useful links

2372 questions
0
votes
0 answers

Invalid Amount Error from Metamask mobile app during USDT transaction using web3js

I am facing Invalid Amount Error from meta mask (mobile app) during USDT transaction using web3js the error looks like below My code looks like this var provider = new WalletConnectProvider.default({ infuraId :…
Manimaran
  • 405
  • 2
  • 8
  • 20
0
votes
1 answer

How to ask a Web3 RPC client which chain it is working with?

How to ask a Web3 RPC client which chain it is working with e.g. Ethereum Mainnet/Polygon Mainnet/Binance Smart Chain/etc.
M. Azyoksul
  • 1,580
  • 2
  • 16
  • 43
0
votes
0 answers

Web3js Http/Ws advanced configuration (Error: socket hang up)

I have a private network compatible with EVM, some smart contracts deployed on it and an API that provides endpoints to interact with the contract (to make it easier to use for people without Blockchain knowledge). This API is written with NodeJs…
Alberto
  • 1
  • 1
0
votes
1 answer

How to disconnect Metamask Wallet in Angular

I want to disconnect Metamask wallet using web3 in Angular. //here is my wallet connect code async connectWallet() { const accounts = await this.ethereum.request({ method: 'eth_requestAccounts', }); this.selectedAddress = accounts[0]; } kindly…
0
votes
1 answer

Web3.js pair contract events.Swap not correctly subscribing to swap event

I am trying to run a section of (nodejs using Web3.js) code whenever a swap occurs on a given pair contract (qPair is the pair contract derived from Quickswap's router contract (Polygon blockchain) and sPair is the same pair contract derived from…
Liam Goss
  • 15
  • 6
0
votes
1 answer

@solana/web3.js subscribe to incoming tokens

I want to recieve callback when I receive tokens on some account in nodeJS. This code work properly, but only for SOL. How to do the same for USDT in solana or for any token? const web3 = require("@solana/web3.js"); (async () => { const publicKey…
Makasin
  • 5
  • 1
0
votes
1 answer

How to handle the error thrown by "_fireError" in web3.js?

I was trying to catch the error thrown by the web3.js during the calling of a function in my smart contract. This is the code I use for calling the function: contract.methods.mintBatch(quantity, data.nonce, data.hash, data.signature,…
Terry Windwalker
  • 1,343
  • 2
  • 16
  • 36
0
votes
1 answer

How to store and retrieve private key - dapp

When a button is pressed, I send custom tokens to the user using the code below by signing and sending it from my account. The code works perfectly, however, how do I safely store and retrieve the "private key"? The code below is stored in a plain…
Selene
  • 1
  • 1
0
votes
1 answer

webjs execution reverting when calling deployed contract: var err = new Error('Returned error: ' + message)

I'm running the following javascript file and using web3js to call a smart contract (0xF3885ca057a42B10b6cb432B816FE11426a2E369) on Goerli: const Web3 = require("web3"); // Loading the contract ABI // (the results of a previous compilation…
0
votes
2 answers

Why is useEffect running once?

When I try to test this code portion by running useEffect on the info state, I notice that the info state runs 1 time less than it should be. Can I know why? data.length = 2 const fetchData = async function (contractAddress) { …
0
votes
1 answer

MaxListeners Exceeded when combining web3UIkit and React/Moralis

I am continuously running into a MaxListeners Exceeded issue in my project and I cannot find the solution to it. The problem presents itself when browsing between pages in the navBar a few times and after a couple of clicks the console notifies the…
Patrick H
  • 47
  • 1
  • 8
0
votes
1 answer

Jest Mock Default Constructor

The test: import Web3 from 'web3'; jest.mock('web3', ()=>{ return jest.fn().mockImplementation(()=>'Hello, world!') }); describe('app', ()=>{ test('mock web3', ()=>{ console.log('web3:', Web3); let web3 = new…
lmat - Reinstate Monica
  • 7,289
  • 6
  • 48
  • 62
0
votes
2 answers

web3 stuck at sendTransaction

I'm following the tutorial here: https://chainstack.com/how-to-create-blockchain-bridge/ and getting stuck (seeing nothing) at line 34 in contract-methods.js and if I set timeouts, I get a timeout. Here's the repo for it:…
Ayudh
  • 1,673
  • 1
  • 22
  • 55
0
votes
0 answers

how to insert data available for both sender and receiver in solidity?

---------Solidity--------- This is a create request: function createRequest(Requests memory rqst) external { Rqst[msg.sender].push(Requests({ status:rqst.status, amount:rqst.amount, …
KD.S.T.
  • 573
  • 1
  • 5
  • 27
0
votes
1 answer

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? Internal JSON-RPC error. { "code": -32000, "message": "execution reverted" } I have implemented the safemoon…