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
7
votes
5 answers

How to properly use revert reason in web3.js to show meaningful error message in UI

I want to use web3.js to show revert reason to user, for example in the case of user trying to mint erc721 token that has already been minted. I am using try catch block and see the error message but I want to isolate the error message to show the…
Anas Shad
  • 179
  • 3
  • 11
7
votes
1 answer

How do you estimate the amount of gas required for a smart contract invocation?

I want to send a transaction in RSK network and I get this message in logs: Not enough gas for transaction execution. I got the gas limit parameter from my testing environment, using web3.eth.estimateGas.
7alip
  • 895
  • 6
  • 11
7
votes
4 answers

Sender account not recognized on private ethereum network

I'm currently developing a dApp in Solidity and am working on a web3 library to handle communication with it. I struggle with the process of new account creation and transaction signing in web3. Before I continue it worth noting that I'm running my…
Karim Stekelenburg
  • 633
  • 12
  • 26
7
votes
2 answers

How can I create a new account or address with web3.js?

I'm trying to interact with geth, and I need to create a new deposit address (and be able to control it). How can I implement this with web3.js?
Shamoon
  • 41,293
  • 91
  • 306
  • 570
7
votes
4 answers

Using web3 from MetaMask in React

I'm attempting to use the web3 from MetaMask in a React js app like so: import Web3 from 'web3'; componentDidMount(){ if (typeof web3 !== 'undefined') { console.log(web3.currentProvider); // Use…
iicaptain
  • 1,065
  • 1
  • 13
  • 37
6
votes
2 answers

Angular: utils/util.js -> Uncaught ReferenceError: process is not defined

I feel like this should be resolved simply, but after several attempts, I'm just not coming to a resolution. Here is the error I've received: Uncaught ReferenceError: process is not defined 38509 @…
LeftBrain
  • 326
  • 2
  • 10
6
votes
1 answer

How can upload metadata json to IPFS by javascript codes and how can programatically mint this URL by frontend

I have started studying how to mint an NFT using solidity and IPFS. The project flow is: Install IPFS Upload asset photo by IPFS and get its hash Create a metadata.json file using the above hash { "name": "NFT", "description": "This image…
user16945874
6
votes
2 answers

MetaMask conflicting with Coinbase wallet

I am trying to connect to the metamask from my dapp. following the docs: https://docs.metamask.io/guide/getting-started.html#connecting-to-metamask but when I call eth_requestAccounts method it's opening coinbase popup as well. how to work around…
Xaarth
  • 1,021
  • 3
  • 12
  • 34
6
votes
1 answer

Getting an error Argument of type 'unknown' is not assignable to parameter of type 'Error | null'

I am fairly new to typescript so I am getting an error which say Argument of type 'unknown' is not assignable to parameter of type 'Error | null' and i can't understand why am i getting that. How do I solve this? export function subscribeToAccount( …
Avinash Toppo
  • 349
  • 1
  • 2
  • 10
6
votes
2 answers

Using web3js get coin price on uniswap and sushiswap exchange without using their api

I want to get token prices for uniswap and sushiswap exchange by using web.js I am new to the crypto dev world, so please elaborate as much you can and if possible an example will be a lifesaver. This is the best shot I could make... but don't know…
AtiqGauri
  • 1,483
  • 13
  • 26
6
votes
3 answers

Web3js fails to import in Vue3 composition api project

I've created a brand new project with npm init vite bar -- --template vue. I've done an npm install web3 and I can see my package-lock.json includes this package. My node_modules directory also includes the web3 modules. So then I added this line to…
meh
  • 2,591
  • 4
  • 20
  • 33
6
votes
2 answers

Is it possible to make smart contract trustlessly know addresses of RSK pegnatories in real-time?

Is there any way to use a smart contract on RSK to query the addresses of all current pegnatories? And to do so without relying on 3rd party oracles on RSK? For context: The intention here is to make smart contract allocate a part of incomes…
Jack
  • 121
  • 4
6
votes
1 answer

Disconnect wallet from site using web3

I am using web3 to connect to metamask using below method await window.ethereum.request({ method: 'eth_requestAccounts' }); var address = await window.ethereum.request({ method: 'eth_accounts' }); but when i am refreshing screen it still shows as…
Rohit Maurya
  • 730
  • 1
  • 9
  • 22
6
votes
2 answers

How to calculate the total volume transacted for a token on RSK?

I would like to be able to find out the total volume transacted for RDOC, from deployment until now. Unable to get this information from the block explorer: 0x2d919f19d4892381d58edebeca66d5642cef1a1f What's the best way to get this using RPC or…
7alip
  • 895
  • 6
  • 11
6
votes
4 answers

How to get ERC-721 tokenID?

I have created a ERC-721 contract deployed on ropston network. Using contract I'm creating NFT's and its totally working fine. Now for the transfer part I need to get tokenID of any NFT and transfer to to other address but I'm not able get the…
Omar
  • 145
  • 1
  • 1
  • 9