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
8
votes
2 answers

Fetch all NFTs owned by wallet address with web3.js

I am new to blockchain. I have done a little bit research and here's my steps to fetching a list of NFTs owned by certain wallet with web3.js balance = ERC721.methods.balanceOf(walletAddress).call(); objects = []; for (i = 0; i < balance; i++) { …
peter169
  • 109
  • 1
  • 1
  • 7
8
votes
1 answer

How do I get all the tokens inside my Metamask wallet by web3 or others?

I make login with metamask on my website (Laravel & Vuejs). I installed Web3 and doing actions such as getAccounts, Sign , getBalance and etc. But I want to get all tokens(Such as BNB, RARI and etc) balance in metamask. I wrote this code: // …
Amin
  • 387
  • 1
  • 6
  • 17
8
votes
5 answers

Cannot add web3 to React project

I'm trying to add Web3 to a React project. I've initalized a new project with gatsby new Then, I've installed web3 npm install --save web3 And when I include web3 in index.js import Web3 from 'web3' And if I call gatsby develop I have some…
Karhunen
  • 175
  • 1
  • 6
8
votes
3 answers

Switch Metamask Network to chain 1 (Ethereum Mainnet)

This past week Metamask introduced a new function called "wallet_addEthereumChain" which allows the user to automatically add a new Etheruem RPC to their wallet when prompted. This function also allows the user to change the network they are…
Alexander Barry
  • 81
  • 1
  • 1
  • 3
8
votes
1 answer

Web3 signature verification is failing - ethers.js

I'm trying to create a signed message off-chain using ethers.js and verify that message on-chain using ecrecover. I'm signing the correct message from my metamask wallet, and passing the r, s, and v from that signature into ecrecover, but not…
a94
  • 564
  • 1
  • 7
  • 16
8
votes
7 answers

Why web3.eth.getAccounts().then(console.log) return empty array?

I got empty array after I tried to web3.eth.getAccounts().then(console.log);and also got a warning which is./node_modules/web3-eth-accounts/src/scrypt.js Critical dependency: the request of a dependency is an expression. In this project I first…
Jessie
  • 1,155
  • 3
  • 16
  • 27
8
votes
6 answers

Is it possible to pay transaction fee from another account in ethereum?

i want to do a transaction in ethereum from account A but the transaction fee should be paid from account B. is it possible in ethereum?
rahul123
  • 81
  • 3
8
votes
1 answer

Can we get transaction information recorded in the past block using Solidity in the Smart contract?

I am studying blockchain with Ethereum, and I want to use past transaction data in the Smart contract using Solidity. If I use Web3.js module in the program written in javascript, I can get these data easily. But I can't get these data in the Smart…
i20gyawa
  • 83
  • 1
  • 4
8
votes
1 answer

how to get token transaction list by address using web3 js

I am using web3.js. I want token transaction list (Not transaction List) by address. I already used the getBlock function but its only for particular block. I have no block list and I want the list by address only. How can I get the token…
7
votes
5 answers

How can I validate a Solana wallet address with web3js?

I'm trying to validate that the input text I get from a user is a valid Solana address. According to the web3.js documentation, the method .isOnCurve() does that: https://solana-labs.github.io/solana-web3.js/classes/PublicKey.html#isOnCurve I've…
7
votes
3 answers

How to properly transfer Solana SOL using web3js via Phantom

Am working with Solana Blockchain. Am trying to transfer Solana SOL via Phantom. To this effect I used the code below which was found on Stack Overflow: source link I already have Phantom installed in Chrome. When I run the code, it displays…
Nancy Moore
  • 2,322
  • 2
  • 21
  • 38
7
votes
1 answer

ERC721: transfer caller is not owner nor approved

I have a nftToken Contract that mints token to msg.sender, then I have a function in a market contract that transfers the nft from owner to market contract. However, I am getting an error that says: ERC721: transfer caller is not owner nor…
sonika
  • 239
  • 1
  • 2
  • 9
7
votes
4 answers

Provided Address is invalid, the capitalization checksum test failed

I am trying to send a method on a contract using web3. I'm creating an account using the privateKeyToAccount method but when sending the method on the contract I get the following error: Provided address [object Object] is invalid, the…
Andrei Florian
  • 131
  • 1
  • 2
  • 7
7
votes
1 answer

Error: Returned error: The method eth_sendTransaction does not exist

I am trying to transfer an erc20 token from contract address to an ETH address using this code: var _from = "from Address"; var contAddress = "contract address"; var _to = "to address"; var _Amount = '50'; var txnObject = { "from": _from, …
Muhammad Noman
  • 155
  • 1
  • 5
  • 12
7
votes
3 answers

Using local private key with Web3.js

How can I interact with smart contracts and send transactions with Web3.js by having a local private key? The private key is either hardcoded or comes from an environment (.env) file? This is needed for Node.js and server-side interaction or batch…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435