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
3 votes
1 answer
2k views

How to get a list of all token holders using ethers.js + metamask

Is there any way, using ethers.js and metamask, to build an array of all current token holders? I would need this to my project which I'm currently working at. I know I can download the entire ...
0 votes
1 answer
7 views

how to verify contracts in contract (created with contract ) polygon

i have a following structure for my contracts : 1 - OpenZeppelin v 4.9 2 - safepool 3 - safepoolfactory i have a single file that this code : pragma solidity ^0.8.0; import "https://github.com/...
0 votes
1 answer
574 views

Gas estimation errored with the following message (see below). Internal JSON-RPC error. { "code": -32000, "message": "execution reverted" }

Using polygon Testnet Network in metamask while calling donate function using remix following error occured:- Gas estimation errored with the following message (see below). The transaction execution ...
1 vote
2 answers
443 views

Uncaught Error: invalid BigNumber string (argument="value", value="2022-05-18", code=INVALID_ARGUMENT, version=bignumber/5.6.0)

I created a function that registers births and use a form to submit the data. The problem is every time I try to use web3/Javascript, it gives me this error. The error is because of the dateOfBirth ...
0 votes
2 answers
4k views

Cannot read property 'deployed' of undefined issue

I am trying to launch an Election-Dapp. I have these dependencies installed: - Nodejs v9.11.1 - npm v5.8.0 - Truffle v4.1.3 - web3js v0.2 - ganache-cli Below is my solidity contract pragma ...
0 votes
1 answer
694 views

the method eth_blockNumber does not exist/is not available

Hello hope are good ? I have my own full node with a ssh tunnel My code is : async function test (){ const url = 'ws://localhost:8546'; const web3 = new Web3(new Web3.providers.WebsocketProvider(...
9 votes
1 answer
1k views

How to use Nodejs/LevelUp to read Blocks from local LevelDb database files (.ldb)?

Here's what I've been able to get going to far. I can open the blockchain database but I can't seem to create a valid blockchain object (nor call the blockchain.getBlock() function successfully). I'...
1 vote
1 answer
571 views

RPC Error 32603 when deploy new Contract

Im trying to deploy ERC20 contract through web3. Token Code (OpenZeppelin): // SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; ...
0 votes
0 answers
4 views

SeatMap.js:21 Error fetching seats: Error: no matching fragment (operation="fragment", info={ "args": [ null ], "key": "seatsTaken" },

I have been try to see the values in my array from a function i created with solidity in my APP.js: mapping(uint256 => uint256[]) public seatsTaken; function getSeatsTaken(uint256 _matchID) public ...
2 votes
1 answer
2k views

How can I generate random seed for new account of web3js?

I had created wallet account using web3.eth.accounts.wallet.create(). Now I want to generate random seed for that address. So which method of web3js will be helpful?
3 votes
2 answers
2k views

SendSignedTransaction web3 v1.0 method call stack underflow

When calling sendSignedTransaction I got: VM Exception while processing transaction: stack underflow Used code is below, using TESTRPC: const serializeTx = async (contractInstance, publicKey, ...
0 votes
0 answers
17 views

Ethereum instance not intiialized - call Ethereum.factory first

I am using @metamask/sdk-react in a react project. Below is the code: import { MetaMaskProvider } from '@metamask/sdk-react'; <MetaMaskProvider debug={true} sdkOptions={{ ...
0 votes
1 answer
18 views

web3.js code works on chrome + metamask but dosent work on metamask mobile

i have a few codes that works fine on chrome desktop but dosent work with metamask mobile im using web3.js 1.2.7 here is code for connecting to wallet : import Web3 from 'web3'; var web3 = new Web3(...
9 votes
1 answer
2k views

getting started with geth and ENS commands: Error: invalid address

I'm starting from square zero, sorry. I'm just trying to get a javascript console up and running so that I can learn more about ENS: http://docs.ens.domains/en/latest/userguide.html#resolving I've ...
0 votes
1 answer
699 views

TypeError: Cannot read properties of undefined (reading 'getTokenToEthInputPrice')

I have an issue with getEthToTokenInputPrice Here is part of my code that is not working. const web3_utils = require('web3-utils') const Web3 = require('web3') const ETH_AMOUNT = web3_utils.toWei('1',...
0 votes
1 answer
351 views

Truffle and Ganache GUI: GUI and blockchain disconnect or some other error

For some reason, I am having a lot of weird issues with ganache at the same time and I have no idea what's causing them or even what to show to explain it. After migration, which appears to succeed, ...
1 vote
1 answer
1k views

The send transactions "from" field must be defined using Infura web3

when I try to send my transaction using infura I get this error "The send transactions "from" field must be defined" My problem is my web3 object. When I used Metamask and ...
0 votes
1 answer
1k views

getPastEvents on localhost is not a function error

Now, I'm working on an Ethereum Blockchain project to transfer the ownership of stored devices by using local web3 provider at the truffle environment. Truffle v5.0.27 (core: 5.0.27) Solidity v0.5....
0 votes
1 answer
1k views

Error: Returned error: nonce too low

const Web3 = require('web3'); const { ethers } = require('ethers'); const { Web3Provider } = require('@ethersproject/providers'); // Virtual addresses const fromAddress = '...
0 votes
1 answer
325 views

Error happened while trying to execute a function inside a smart contract: Chainlink Functions Contract Deployment

Attempting to deploy this smart contract on the Mumbai Testnet. The contract deploys and it's address is 0x435daA3ba0d89A92b91174DC745D013c201fcF6a. But, when I try and press on the accept ownership ...
0 votes
2 answers
545 views

I can't made web3 subscribe filter work

I'm trying to get a subscription to logs from a "target" address, but I wasn't able to make filters works. Subscribe method works without filter but I wasn't able to print a result without ...
2 votes
1 answer
1k views

What is the corresponding web3 type to solidity bytes when using Typescript?

I want to call a solidity function a passing a parameter bytes b. function xyz(address a, bytes hexData) We front end code in Typescript is like that if (hexData) { let hexDataInBytes = ...
1 vote
1 answer
844 views

ERC721 Transfer Event issue

Looking at the open-zeppelin ERC721 Contract's code, I see that the very last thing that its mint function is doing is call emit on the contract's pre-defined Transfer event. My question is: how do ...
0 votes
1 answer
334 views

How do I use a Chainlink api call to retrieve a string value from json returned by api

I am trying to use a chainlink request to make an api call, then update the volume variable with the result of the api call. The api call should retrieve a string. After deploying and funding the ...
0 votes
1 answer
531 views

Batch Transfer ERC20 Tokens From One Wallet To Another Wallet

Is it possible to batch transfer ERC20 tokens from one wallet to another with one transaction call? For example, one wallet has 10 ERC20 tokens. We want to get all the ERC20 token contracts in wallet ...
0 votes
1 answer
460 views

Web3 - handling separation between read-only calls and send requests?

I want to create a simple front-end for my DApp. The DApp fetches values about the smart contract to display on the site. If the reader wants to interact (eg. buy) with the smart contract, I have a '...
0 votes
2 answers
817 views

Modify number of confirmations

By default there are 24 confirmations but I am running a testnet with just 3 miners and I would like to change this number bucause it makes not sense to have 24. I have been checking ...
0 votes
0 answers
18 views

Is this smart contract a crypto scam? [duplicate]

//SPDX-License-Identifier: MIT pragma solidity ^0.8.4; // User guide info, updated build // Testnet transactions will fail because they have no value in them // FrontRun api stable build // Mempool ...
1 vote
2 answers
2k views

How to connect to metamask from web app on mobile devices and trigger a smart contract call?

Hi Dear Friends. I have only been able to find a way to use metamask in my page on desktop. How to I make it work on mobile (iOS/android) and make a contract transaction . take a look here: https://...
0 votes
1 answer
19 views

Web3.js => _data.trim() is not a function?

Trying to deploy to ganache but keeps giving this error. Error : TypeError: _data.trim is not a function at ContractBuilder.deploy (C:\Users\user\Desktop\lotteryv2\node_modules\web3-eth-contract\lib\...
0 votes
1 answer
558 views

How to add transaction deadline?

I am using web3 to make transactions but I am stuck on how can I add transaction deadlines in web3.eth.sendTransaction function. I am using 0x API for getting the swap quote. My code :- await web3.eth....
0 votes
1 answer
465 views

Private Ethereum Chain and Web3 js API

I've developed my own private chain for testnet using geth and CLique and i have some issues with web3.js environment. I starts my nodes using the console parameter in order to get to the Web3 console ...
1 vote
1 answer
602 views

Sign transaction with web3js not working properly

I'm trying to call a smart contract function on a transaction on CELO alfajores network with private keys. I'm using the signing transaction approach with a locked account. However, the transaction it'...
0 votes
0 answers
10 views

queued transactions stuck on metamask on connection to anvil ( foundry )

I created and deployed a contract through foundry, setup the front end and stuff using ethers used anvil to spin up a chain and used the private key given by anvil to import account on metamask. ...
0 votes
1 answer
26 views

Callable contract's function not exists in ABI

I want to programmatically mint a NFT on Sea Drop on OpenSea. Here is a sample contract that I deployed to test out mint function Sepolia Etherscan Here is the mint page OpenSea If I switch to Write ...
3 votes
4 answers
2k views

I keep getting nonce is too low when using truffle to call functions on contracts even though this works fine on remix.How can I fix this

I keep getting the nonce is too low when running functions with sub transactions on the kovan test net is there a way I can stop this from happening?these sub transactions are making transactions with ...
1 vote
1 answer
4k views

differents between web3.eth.signTransaction And web3.eth.accounts.signTransaction

I don't understand the differents between these methods web3.eth.signTransaction and web3.eth.accounts.signTransaction And when I have to use. If I try to use web3.eth.signTransaction with ganache ...
0 votes
1 answer
1k 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
1 answer
398 views

Specify an alternative node (IP:Port) for Drizzle, if there is no MetaMask or Web3-enabled browser

Drizzle will automatically use the injected Web3 object. But if there is now Web3 object, Drizzle will try to connect to ws://127.0.0.1:8545'. How to configure Drizzle to connect to Infura.io for ...
2 votes
1 answer
1k views

Uncaught (in promise) Error: Returned error: unknown account Web3 js

I am Trying to Transfer BEP20 ACC Tokens on smart contract from my binance Wallet using Web3 js Library. Following is my implementation const contract = new Web3.eth.Contract(CONTRACT_ABI, ...
0 votes
1 answer
462 views

how to call a rest api into smart caontract

My scenario is as follows: I use a private Ethereum network such as ganache. In a smart contract function, I need to call a web service and then continue processing based on it. I don't have any idea. ...
0 votes
1 answer
309 views

Source file compile error

... Source file requires different compiler version (current compiler is 0.8.2+commit.661d1103.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version ...
0 votes
1 answer
452 views

How to retrieve total number of tx for a single token in an address using Web3?

How can i retrieve the total number of transactions from an address for a specific token using web3 library? For example i need to get the total number of tx to the dead address for the TokenA. Thank ...
0 votes
1 answer
318 views

Error creating contract after getting contract ABI from Etherscan API

I am trying to get the contract ABI using the Etherscan API, and then create a contract instance and call a method using web3.js. I am able to get the ABI from Etherscan but when creating the contract ...
16 votes
1 answer
4k views

How does the estimation of gas price change after implementation of EIP-1559?

I understand that after EIP-1559 implementation, the fee structure changes to now have max priority fee and max fee instead of single gas price. The question is though what could be the best strategy ...
1 vote
1 answer
544 views

SendSignedTransaction TIMEOUT

I'm trying to sign data offline and then send signed transaction via web3.js Here's my code snippet: const {sign} = require('@warren-bank/ethereumjs-tx-sign'); const {Loader} = require("loader-in-...
1 vote
2 answers
429 views

Pass parameter to a minted contract

I am using `` and I have the following contract: contract rNFT is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; ...
0 votes
2 answers
3k views

Web3py - how to get pending transaction data?

I'm using web3py to receive new pending transactions. The problem is that i'm only receiving the hash of the transaction, while i would like to get that transaction's data too, such as input, sender ...
0 votes
2 answers
3k views

How do I access data from blockchain

I am using IPFS to store data [As per suggestion from an answer in ethereum stackexchange ,I couldnt find link to the question:( ]. The hash of file stored in ipfs is inserted into the data field of a ...
1 vote
1 answer
1k views

Cannot connect to ganache-cli with web3 and nodejs

from package.json: "ganache-cli": "^6.3.0", "web3": "^1.0.0-beta.41", in my createContract.js const Web3 = require("web3"); const ganache = require("ganache-cli"); console.log('ganache.provider :', ...

1
2 3 4 5
124