Questions tagged [web3js]

Javascript API and library for Ethereum To develop applications on Ethereum, you can use the web3 object provided by the web3.js library. Under the hood it communicates to a local node through RPC calls. web3.js works with any Ethereum node, which exposes an RPC layer. https://github.com/ethereum/wiki/wiki/JavaScript-API

Filter by
Sorted by
Tagged with
2 votes
0 answers
46 views
+50

abi-decoder's decodeMethod returns undefined

I am trying to decode the input field of this transaction as below, const decodedInput = abiDecoder.decodeMethod(transaction.input); but decodedInput returns undefined despite the my ABI having the ...
0 votes
1 answer
407 views

how to call a rest api into smart caontract

My scenario is as follows: I use a private Ethereum network such as ganache. In a smart contract function, I need to call a web service and then continue processing based on it. I don't have any idea. ...
1 vote
2 answers
522 views

Send custom ERC20 tokens and deduct gas from master/another wallet

What I have currently - Master wallet : Contains ETH balance Deploys ERC20 contracts to mint custom tokens. User wallets : NO ETH balance owns tokens of the deployed contract. Contract : Custom ...
1 vote
1 answer
847 views

Unhandled Exception: Connection refused - Truffle Ganache Connection with Flutter

I am getting this error when trying to link a smart contract deployed on a Ganache local blockchain with Flutter web3dart package. Note: Testing on android (both emulator and physical device give the ...
1 vote
1 answer
101 views

Track logs of a specific wallet address not emitting anything

I am trying to track a wallet address and whenever it does something to emit an event. This is for BSC btw Here is the code var subscription = web3.eth.subscribe('logs', { address: '...
2 votes
0 answers
1k views

How to catch reverted transaction while using metamask

I'm working with metamask and was testing a transaction that should trigger a revert statement inside my contract. When the error is thrown metamask gives the following output: this was while using ...
8 votes
4 answers
17k views

How to get reason revert using web3.eth.call

I have a smart contract with required message and pretend to use the required/validation message in front end. require(bytes(hashAlreadyRegistered[hash]).length == 0, "Hash already registered&...
1 vote
1 answer
462 views

miner.start() is not a function?

"web3": "^1.0.0-beta.37" "web3": "^1.0.0-beta.55" import {Miner} from 'web3-eth-miner'; then const options = { defaultAccount: "0x78dB3e2129D58685444989dD9682DDDC70dd3C82", ...
1 vote
1 answer
514 views

How to prevent user to change recipient address when MetaMask transaction window pops up?

I want to integrate MetaMask as one of payment methods on my website. The idea is to lock my content, when user made a successful ETH payment so the content will be revealed. This is the source code: &...
1 vote
1 answer
621 views

Batch request returns undefined

I'm trying to get batch requests to work with an Amazon Managed Blockchain, so I set up a simple test. The error I get is Invalid JSON RPC response: {}. This returns undefined if I don't log the error;...
0 votes
1 answer
12 views

Creating a token for my personal dapp use only

I want to store the money in a smart contract from my user as long the user wants and pay back the user once he asks i will not charge for this service if I store ether in it and the value of Ethereum ...
1 vote
2 answers
365 views

How to enter a uint256[] function input in java script?

I'm trying to interact with my smart contract using java script. My function uses an uint256[] input. In python the desired input would be input = [1,2] In java script I tried const arrayindex ...
0 votes
2 answers
504 views

Insufficient funds whie sending transaction to contract, even if balance is big enough

I'm trying to send a transaction in order to call a minting function of a smart contract on the Rinkeby Testnet. The problem is that I get the following error: Error: Transaction has been reverted by ...
0 votes
2 answers
3k views

Web3py - how to get pending transaction data?

I'm using web3py to receive new pending transactions. The problem is that i'm only receiving the hash of the transaction, while i would like to get that transaction's data too, such as input, sender ...
0 votes
1 answer
9 views

Staking pool for native coins

I wanna build a staking pool for native coins like trx to test my skills as an engineer and yet due to my limited knowledge I don't know how to make a staking platform without creating a new token. Is ...
0 votes
2 answers
18 views

Test BNB / WBNB for Development testing purpose

I am in need of 100 test BNB for testing purpose but with faucet its not possible to get that much is there any way to have that much test bnb. OR is there any existing liquidity of test BNB / WBNB ...
1 vote
2 answers
683 views

Sending entire ether balance to another wallet

I found the same question but it was asked over 4 years ago but it doesn't seem to work anymore? How do I send the entire ether balance from one account to another account? const Web3 = require('web3')...
0 votes
0 answers
8 views

How Remix IDE compiles smart contract code to ABI and bytecode?

I am building a DApp where user uploads his smart contract code file and his smart contract gets deployed using his private key ( After he connects his metamask account to the DApp ) . How RemixIDE is ...
0 votes
1 answer
1k views

How can I call a function that performs a transfer in web3?

I would like to call a function in smart contract using web3. In the function, I perform few transactions. The first method that I tried is await myContract.methods.endAuction().call();. This reverted ...
0 votes
0 answers
13 views

Strange order of transactions in the same block

recently i saw next thing: There is a nft game contract, the goal is to be the first (top 100). Each game starts by Tx from admin, let's say he calls start() function in his transaction. Then all ...
1 vote
1 answer
585 views

As a developer how to let user of your DAPP choose the preferred wallet

In the DAPP I am building I want to let users log in with their wallet of choice. Currently I have two wallets, Metamask and coinbase wallet. The function window.ethereum.enable() injects web3 ...
0 votes
2 answers
334 views

Get latest log of Event with web3

I have read all the other answers, but it doesnt seem to really work for me. At first I thought it worked but then I noticed it didnt. What is the best way to retrieve the value of the last event that ...
1 vote
1 answer
322 views

web3.admin.addpeers return BigNumber Error

When I using ethconsole to deal with a private chain. I hope it can connects to another node which I get the node information. But the command "web3.admin.addPeer("enode://[email protected]:30304",...
1 vote
1 answer
1k views

How to Serialize/Deserialize array of bytes?

I'm writing a smart contract and inevitably need to have arrays of bytes as input and output of functions. In remix arrays work just fine but with web3j and web3js there are several issues with arrays ...
0 votes
2 answers
346 views

Can't send ETH to smart contract with Ganache: Invalid or unexpected token

I'm having issues sending ETH to an extremely basic smart contract. Here's the smart contract code: // SPDX-License-Identifier: MIT pragma solidity 0.8.9; contract hodl { uint num; uint value; ...
2 votes
4 answers
1k views

How can one secure Web3 JSON-RPC API endpoint?

When using geth as client and web3(javascript api) to interact with it through a web browser, other nodes in the network can access the client given the IP and the port on which the client is running. ...
1 vote
2 answers
2k views

Geth and Web3js: invalid sender when sending signed transaction

Im using https://trezor.io/ to send signed transactions I have succesfully send transactions to: Truffle development network Ropsten Right now im using a private local go-ethereum node, the ...
0 votes
1 answer
585 views

How to add a fee for each swap

I'm making a small NFT tool and I'm having troubles calculating the fee and making the user pay for it, the fee itself is 0,10% and I want to apply it to each time the function createMarketSale is ...
1 vote
1 answer
762 views

insufficient funds for gas * price + value even though balance is way more than gas * price + value

Getting this error only on some of the wallets I tried. Too low is for sure not the problem. Working on infura. sendEth = async function(fromm, frommPUB){ fromAcc = web3.eth.accounts....
0 votes
1 answer
15 views

React (opts:) not working, am i missing dependency?

I have a basic walletconnect web3 module here. I am following a video from https://www.youtube.com/watch?v=L65gP0cGC30 but it errors (opts:) on the example video the text actually is grayed out so it ...
1 vote
1 answer
335 views

How can i get Abi from the byteCode using ethersjs i am using following code:-

Its not working for me const byteCode = await provider.getCode(address); const AABBI = ethers.utils.Interface.parse(byteCode).abi; console.log("AAABBBIII", AABBI);
5 votes
1 answer
1k views

web3.eth.getBlock returns null

I have a very similar problem as https://github.com/paritytech/parity-ethereum/issues/8788 When I use web3.eth.getBlock for the first 1 million and latest 50,000 blocks (approximately), I get the ...
1 vote
1 answer
622 views

Get Return value back from smart contract function

I am using "web3": "^1.5.1", and "web3-eth-contract": "^1.5.2". I have the following solidity function in my contract: function mint(string memory ...
0 votes
1 answer
307 views

Proper way of signing message in web3 and recovering in solidity

Can anyone help me with the proper implemented documentation on how to sign a message in web3 and then the secure way of recovering it in solidity smartcontract?
1 vote
1 answer
307 views

How to get Buys and sells of a token on a Dex

Im trying to rebuild a simple app that gives me the latest buys or sells of a token on pancakeswap. Im using this code here and it kind of works: def handle_event(event): print(Web3.toJSON(...
0 votes
3 answers
2k views

ERC20 Transaction failing due to invalid nonce value

I am trying to send an erc20 transaction but I keep getting an error telling me that the account I'm sending the transaction from has a nonce value of 1 while the tx has a nonce value of 31613. I am ...
1 vote
1 answer
989 views

ERC20 Token support for metamask website payment

I have the following code working in my site to accept ethereum payments in my website via metamask.... <!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/...
0 votes
2 answers
2k views

How do I set my transaction's gas to 0.5 ether?

I am trying to set my gas to 0.5 ether, but I'm not sure how to do that. I have a transaction tx here: var tx = { to: "0x73E7D230586B118898aA1FB95FAA6E4119FA0996", value: ...
1 vote
1 answer
446 views

Why does triggering a send on a contract method work, while call doesn't?

I'm still somewhat new to web development and solidity, so do correct any of my misunderstandings. I've been working with web3 on the front end, but now I'm trying to set up a server side web3 ...
0 votes
1 answer
13 views

in cloud window.ehtereumundefined,in local window.ehtereum is object

I am developing a dapp now, deploy the dapp in local PC, it can connect with browser extension, window.ehtereum is Object, but deploy it in aws cloud, it cann't connect with browser extension, window....
0 votes
0 answers
22 views

Swap functions seems to not swap?

I have deployed a smart contract on a local network and I am trying to do swaps from a metamask account. I have allocated a quantity of tokens to the smart contract so it can use it using the approve ...
0 votes
1 answer
455 views

Gas limit is not set REMIX

I set the gas limit to 1 000 000 for every transaction. But each transaction takes less amount of gas than 1 000 000. Could you please explain why it happens or what I need to read to get this right. ...
3 votes
2 answers
8k views

Error: "Transaction ran out of gas. Please provide more gas:

I'm facing a little issue here, that's the mintTo function from contract for NFT. Which I require the sender to send a value with >= 0.1 Ether: pragma solidity ^0.5.0; import "./TradeableERC721Token....
2 votes
3 answers
570 views

Given transaction hash, how to proof that it was a successful erc-20 token transfer using web3?

I have a transaction hash and an RPC access to fully synced node. How to check if the token was actually moved? The transaction might be old, so there is no point in querying the contract. If I ...
1 vote
1 answer
1k views

Uncaught Error: CONNECTION ERROR: Couldn't connect to node web3.min.js:1 http://localhost:8545

**Hi, I am doing a sample project on Ethereum where 2 fields ( Emp name, Emp Id) will be taken from the UI and set those values using a smart contract and show the values back to UI. Getting below 2 ...
0 votes
1 answer
363 views

Smart Contract Deployment through React JS

I have deployed multiple contracts using Truffle and Hardhat from a NodeJS project, but I wanted to know if there is a way to deploy smart contracts from ReactJS?
0 votes
1 answer
2k views

How to send transactions Infura + Web3.js + WalletConnectProvider

I want to initiate transactions using the following stack. However, Infura doesn't support web3.eth.sendTransaction(tx) because it requires the server to hold private keys. Here is a link to how it ...
25 votes
6 answers
47k views

Invalid JSON RPC response: undefined, when running web3.eth.accounts (Node)

I'm very new Ethereum and trying to follow this tutorial: https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2 But when I run: web3.eth.accounts I ...
0 votes
2 answers
2k views

How can I automate smart contract interaction

I've deployed a smart contract to the blockchain with few functions. I want to know how I can interact with the code e.g. > Contract has 2 functions - deposit and withdraw. Now, instead of me ...
0 votes
1 answer
4k views

Module not found: Error: Can't resolve 'crypto' in '/Users/user/Desktop/esample/react-minting-website/node_modules/eth-lib/lib'

I am building a development web 3 project and can't figure out why I get this error WARNING in src/App.js Line 2:10: 'useWeb3React' is defined but never used no-unused-vars Line 4:8: ...

1
2 3 4 5
122