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
0
votes
3 answers

deploy solidity smart contract

I am learning Solidity. I wrote solidity code using openzeppelin and compile it using solcjs. It returns multiple bytecode for main.sol and imported other sol file. should I deploy only bytecode for main.sol? (main.sol bytecode contains other sol…
takumi
  • 1
0
votes
1 answer

how to swap tokens on pancakeswap using web3 js

I am trying to use pancakeswap contract method to simply swap BUSD to WBNB token, from metamask wallet. pancakeswap contract method is: var web3 = new Web3(new Web3.providers.HttpProvider('https://data-seed-prebsc-1-s1.binance.org:8545/')) const…
0
votes
1 answer

How to save / get a value with the redux store?

Hello Stackoverflow Community, I was hoping you could help me with the following logic. I would like to return from a custom-built hook the last item the user selected in a onClick function. const useActiveWeb3React = ():…
Digital Dom
  • 412
  • 5
  • 12
0
votes
1 answer

Error while related to big number in react for input in smart contract erc721

I want to integrate my smart contract with reactjs. I have this method called set_price() where i enter the value of token ID (in uint256) and price (uint256) . TokenID is basically a hash of some other values so it was of type byte32 and i have…
Zoha Akram
  • 47
  • 9
0
votes
1 answer

Why is my Uniswap v3 contract failing transactions

I am creating a trading bot using web3 and wanted to buy a token address instantly after script received token address: var originalAmountToBuyWith = '0.001'; var bnbAmount = web3.utils.toWei(originalAmountToBuyWith, 'ether'); var amountToBuyWith =…
Ali Avcı
  • 1,281
  • 1
  • 11
  • 24
0
votes
1 answer

Getting Error: Returned error: Must be authenticated! , while sending erc20 code using web3.js

const fs = require('fs'); let web3 = new Web3(new Web3.providers.HttpProvider('http:127.0.0.1')) const abi = fs.readFileSync('erc20_abi.json', 'utf-8') const contractAddress = '0xB4...' const privateKey = '...' let contract = new…
Vishal Tyagi
  • 177
  • 1
  • 8
0
votes
1 answer

How to integrate Gnosis Wallet into my Dapp?

My dApp already supports MetaMask, but does anyone have any helpful documentation that allows for my users to connect using a Gnosis Safe wallet as well? As of now, I have Wallet Connect integrated, and on my Gnosis Safe App on my phone it shows…
hcwil
  • 59
  • 1
  • 5
0
votes
1 answer

CoinbaseWalletSDK does not work with server side rendering

I was trying to load CoinbaseWalletSDK in my NextJS application, but it always throw an error of ReferenceError: localStorage is not defined due to it was imported before the window is loaded. I tried dynamic loading but it doesn't work. The…
Terry Windwalker
  • 1,343
  • 2
  • 16
  • 36
0
votes
1 answer

web3.utils.toBN vs new web3.utils.BN

From the document toBN is safer than new BN. However, given the same hex hash string, it results in something different: (new web3.utils.BN('0x149e7b36b314b81fbe1762060fcae0f43be82f1251166a61fc7669e7c236c4bf')).toString() // results in:…
daisy
  • 22,498
  • 29
  • 129
  • 265
0
votes
1 answer

async result not resolved in web3

I'm playing Ethernaut Level 3, so I wrote the following code to retrieve the "guess" value: async do_guess => { let no = await web3.eth.getBlockNumber() let block = await web3.eth.getBlock(no) let factor = new…
daisy
  • 22,498
  • 29
  • 129
  • 265
0
votes
1 answer

transaction not mined on rinkeby network even with a very high gas price

I'm playing Ethernaut level 1, and I created a truffle script. But the transaction is not mined. So I increased the gasPrice to gasPrice * 5, but it still times out in 750 seconds. Does anyone know what's wrong? The program first prints txHash:…
daisy
  • 22,498
  • 29
  • 129
  • 265
0
votes
1 answer

web3js says method is not found in ERC20 contract

The Open Zeppelin ERC20 contract has a name(), symbol, and totalSupply() function. This is my smart contract that inherits the ERC20 contract pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import…
Emily Kuo
  • 61
  • 4
0
votes
0 answers

File not found when reading in truffle abi file

I am using truffle and web3 to assemble a smart contract that I deployed on Ropsten testnet. I did the following: const Web3 = require('web3') const fs = require('fs') const { token_abi } =…
Emily Kuo
  • 61
  • 4
0
votes
1 answer

JavaScript Nextjs- why is my return mapping values twice?

My code is displaying the output twice for some reason and I cannot figure it out. Any help would be appreciated. this is the output that i am getting now . I believe it is something to do with setting setImagesCount. I tried transposing this from a…
0
votes
1 answer

how can i pass constructor values when deploying through truffle?

How can I deploy a smart contract with constructor predefined parameters values, I am using truffle, ganache!! constructor (uint256 _targetAmount, uint256 _setDeadline) public { totalAmount = _targetAmount; deadline = block.timestamp…