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
28
votes
4 answers

How to connect ethers.js with metamask?

I am using the ethers.js documentation: https://docs.ethers.io/ethers.js/html/cookbook-providers.html . I am getting the error when setting up the provider -: Uncaught ReferenceError: web3 is not defined I want to connect my Decentralized…
Aashutosh Singh
  • 389
  • 1
  • 3
  • 4
24
votes
4 answers

Webpack 5 Errors - Cannot Resolve 'crypto', 'http', and 'https' in ReactJS Project

I have created a new React project using npx create-react-app client and have encountered some issues with Webpack 5. Originally, I had errors with assert, os, and stream, but have fixed them by installing them and including them in…
Wolfizzy
  • 581
  • 1
  • 4
  • 18
21
votes
6 answers

How to Logout of MetaMask account Using web3.js

I am using MetaMask for sending transactions to contract in my DApp. I need help in How to Disconnect MetaMask account from my DApp when the user clicks on logout button. Front-end: ReactJS Back-end: Web3js, Solidity (Ethereum)
Umair Janjua
  • 324
  • 1
  • 2
  • 11
20
votes
2 answers

How to trigger change blockchain network request on MetaMask

I am using web3 for my first dapp test and I'd like to make so MetaMask will prompt the user to change the network to Binance (BSC) network if it is not selected already, just like here: How to trigger such a request?
Andrea D_
  • 2,028
  • 3
  • 15
  • 38
19
votes
4 answers

Unhandled rejection Error: This contract object doesn't have address set yet, please set an address first

Im currently trying to use Infura to run on my machine thru Web3. When I set to run my node index.js file I get the following error: Unhandled rejection Error: This contract object doesn't have address set yet, please set an address first. at…
Steven Aguilar
  • 3,107
  • 5
  • 39
  • 89
16
votes
3 answers

How to get all tokens by wallet address

I am trying to pull a list of token contracts held by a wallet address, similar to how bscscan does, except programmatically. bscscan.com/apis does not have an endpoint, and web3js seems to only report the ETH balance. This is possible to achieve,…
Nomad
  • 163
  • 1
  • 1
  • 6
16
votes
2 answers

Send signed transactions to Ropsten or Truffle develop network with Trezor (Hardware Wallet)

Im trying to integrate web3js with Trezor in a truffle dev network or using ropsten test network. The idea is to sign the transactions using the hardware wallet and then send a raw transaction using web3js Im getting that we dont have balance to…
Marcos Martínez
  • 545
  • 2
  • 9
  • 24
16
votes
3 answers

What is the of use Web3.providers.HttpProvider("")

I want to interact with a smart contract using web3js. Every example will start with following var Web3 = require('web3'); var web3 = new Web3('http://localhost:8545'); // or var web3 = new Web3(new…
Divya Galla
  • 513
  • 1
  • 9
  • 31
16
votes
5 answers

How to send an ERC20 token with web3js

I'm currently using the 0.2x.x version of the Web3 JavaScript API. I deployed my custom ERC20 token by creating smart contract in solidity (on REMIX IDE). I installed the MetaMask and had a test on https://wallet.ethereum.org/ to send some custom…
rachel_hong
  • 471
  • 2
  • 6
  • 15
16
votes
9 answers

Ethereum Web3.js returns "Cannot find module 'web3-requestManager'"

I'm trying to start using Ethereum Web3.js with node 6.11.1 on a macosx I installed web3 with the following command: npm install web3 Then i launch this - apparently - simple node command: Web3 = require('web3'); Well, it returns the following…
Umberto Stanca
  • 193
  • 1
  • 1
  • 4
15
votes
2 answers

how to swap tokens on uniswap using web3 js

I am trying to use uniswap contract method to simply swap eth for token, using eth from metamask wallet. Uniswap contract method is: function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external …
user3338991
  • 431
  • 2
  • 5
  • 9
15
votes
4 answers

Unable to resolve module crypto in reactnative

I have posted this here have created react-native app using react-native init myapp added web3 in package.json npm install react-native run-ios but i am getting the error unable to resolve module crypto from web3-eth-accounts. Is there any way to…
Trinu
  • 1,721
  • 3
  • 21
  • 41
14
votes
6 answers

How to check if Metamask is connected after page refreshing

My dApp have to connect to MetaMask. There are two rude solutions in the docs: make user to click connect btn every time manually or just pop up connection confirmation after page load. I want to implement the only convenient solution: first time…
14
votes
1 answer

How to avoid "This gas fee has been suggested by" message in MetaMask using web3js

I'm currently in the process of upgrading an Ethereum dApp (using React JS) to conform to the new EIP-1559 standard (A.K.A. the London hard fork). The app uses web3.js (v1.5.2) to initiate transactions which take on a form something like const…
Joel Collins
  • 429
  • 3
  • 10
14
votes
3 answers

Is there any way to initiate a disconnect request to the Metamask wallet?

I'm building a decentralized application where users can connect their cryptocurrency wallet (Metamask) to my website. They can initiate a connection request by clicking a button. On success, the wallet is connected and my website can interact with…
vladwho
  • 141
  • 1
  • 4
1
2 3
99 100