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
10
votes
1 answer

How to send an array of structs from web3js to solidity contract?

I am getting an error when passing (javascript array of objects) from web3js, To solidity function that takes (array of structs) as a parameter. could you help me? below is the code and the error // web3js code let slctedItems = [{name:'item1',…
user13602695
10
votes
1 answer

Unhandled rejection Error: Invalid JSON RPC response: ""

I am trying to call a method on my ERC20 token contract. I am connecting to 'https://rinkeby.infura.io/' httpProvider. I can call() constant methods but when i want to change the state of the contract by calling send() function i get this mentioned…
sam k
  • 1,048
  • 2
  • 14
  • 22
10
votes
4 answers

How to authenticate and send contract method using web3.js 1.0

I am confused about how I should be executing a contract's method using the web3 1.0 library. This code works (so long as I manually unlock the account first): var contract = new web3.eth.Contract(contractJson, contractAddress); contract.methods …
Nick Young
  • 885
  • 1
  • 10
  • 21
9
votes
6 answers

Wallet Connect / Web3 Provider showing a lot of errors just by imoprting

I want to use "@walletconnect/web3-provider" JS library in my project, but once I installed the library along with Web3 module (they will be used together) npm install --save web3 @walletconnect/web3-provider and after that import it into my…
Abady
  • 113
  • 1
  • 1
  • 7
9
votes
3 answers

How to connect ethers.js library with Rinkeby programmatically?

According to official docs of ethers.js, this should be the way how to connect to a specific network like Rinkeby-testnet with custom data: const provider = ethers.getDefaultProvider(network, { etherscan: ETHERSCAN_API_KEY, infura:…
delete
  • 18,144
  • 15
  • 48
  • 79
9
votes
3 answers

MetaMask does not inject window.ethereum: Uncaught (in promise) TypeError: Cannot read property 'request' of undefined

To start, let me mention this is an in-browser project, so i can only use So a few months back I made a dapp, which worked fine even tho I never set a provider,…
Bleiserman ADN
  • 141
  • 1
  • 1
  • 6
9
votes
6 answers

Code not compiling in nodejs,throws out an unexpected error(Web3.js)

I tried following this repo:- But I am getting the following error on compiling the code with :- code = fs.readFileSync('Voting.sol').toString() solc = require('solc') compiledCode = solc.compile(code) It throws out this…
abhinayak
  • 143
  • 2
  • 8
9
votes
6 answers

npm install web3 Install fails: undefined ls-remote

Installation Environment win7 64bit I:\nodejs>node -v v10.13.0 I:\nodejs>npm -v 6.4.1 I:\nodejs>npm install web3 npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise Support npm WARN deprecated tar.gz@1.0.7: ⚠️ WARNING ⚠️…
pangjiale
  • 145
  • 1
  • 1
  • 10
9
votes
8 answers

Uncaught Error: Returned values aren't valid, did it run Out of Gas?

I'm listening to events of my deployed contract. Whenever a transaction gets completed and event is fired receiving the response causes following error: Uncaught Error: Returned values aren't valid, did it run Out of Gas? at…
Ferit
  • 8,692
  • 8
  • 34
  • 59
9
votes
4 answers

How to get Smart Contract address when it is deployed with web3.js

I have tried to deploy a SmartContract from web3.js node library, I am getting a transaction hash from it but how would I get the contract address after It's been mined by a miner?
aac
  • 574
  • 2
  • 6
  • 18
9
votes
4 answers

Solidity accessing private variable

currently, I'm practicing solidity. However, I'm a little confused about accessing a private variable in a contract. For example here; address private a; address private b; mapping (bytes32 => uint) public people; mapping (bytes32 => mapping(address…
riyoz
  • 431
  • 1
  • 6
  • 15
8
votes
6 answers

throw new Error 'Returned values aren't valid, did it run Out of Gas?

I am getting this error: Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not…
Rwitesh Bera
  • 389
  • 2
  • 3
  • 9
8
votes
2 answers

Documentation for ethers.getContractAt()

Can somebody please point me to the documentation (official or otherwise ) that explains the function ethers.getContractAt(): the original context of this is as follows: vrfCoordinator = await ethers.getContractAt('VRFCoordinatorMock',…
maskara
  • 329
  • 1
  • 2
  • 12
8
votes
1 answer

How to detect,launch and connect to metamask mobile app by clicking on a button on the webapp like on opensea?

I implemented a shortcode that connects to metamask browser extension and shows the user account using web3 and reactjs, this code works well when using the desktop browser, but when I try it on mobile browser, metamask mobile version doesn't open…
kool Erick
  • 101
  • 1
  • 6
8
votes
3 answers

transaction underpriced in BEP-20 Token transaction

I had do some transaction in Binance Smart Chain in Binance-Peg BUSD-T and it worked successfully. But after 5 transactions. I face to a problem that said Returned error: transaction underpriced ! This is my code: const web3 = new…