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
0
votes
0answers
11 views

Do I use Infura sending transaction using web3 (injected from) Metamask?

I'am working with truffle using MetaMask wallet to send transaction to my Contract on Rospten Blockchain. I have dubs about the flow of my work. I deploy my smart contract on Ropsten thank to Infura ...
0
votes
0answers
13 views

How to get user details from tron smart contract after registration?

Solidity https://tronscan.io/#/contract/TVJHTbGWEvVGCmPsjqTAqQbnjj8P4yGAwd/code Here Solidity Code This is my contract.js "use strict";function _typeof(obj){"@babel/helpers - typeof&...
0
votes
1answer
7 views

Where is the documentation for admin.sleepBlocks?

Sorry for being stupid. > web3.version { api: "0.20.1", ethereum: "0x41", network: "1108", node: "Geth/v1.9.21-stable-0287d548/windows-amd64/go1.15", ...
0
votes
0answers
13 views

contract.methods.function(arg).send() not working in browser console although same line of code working in node console

//contract abi................ const abi = [ { inputs: [ [Object] ], stateMutability: 'nonpayable', type: 'constructor' }, { inputs: [], name: 'number', outputs: [ [...
0
votes
0answers
23 views

How can I handle the UniswapV2: LOCKED revert reason when calling swapETHForExactTokens on the Uniswap router2 contract

I have forked the eth mainnet onto my local machine using ganache cli and am trying to call the UNISWAP router2's SwapETHForExactTokens to swap eth for MEME tokens. I call the function from truffle ...
0
votes
0answers
12 views

web3.version gives warning

>geth version Geth Version: 1.9.21-stable Git Commit: 0287d54847d3297f3ced62cd83a4c95ccbe0045b Git Commit Date: 20200909 Architecture: amd64 Protocol Versions: [65 64 63] Go Version: go1.15 ...
0
votes
0answers
23 views

Web3 - How do I view my own address?

How do I get my own address into a variable when I use HDWallet as provider for Web3? const HDWalletProvider = require("@truffle/hdwallet-provider"); Web3 = require("web3"); let ...
0
votes
0answers
34 views

Contract call: data out of bounds

I'm working on a nextjs/react project in which i want to fetch the health factor of an address on AAVE. This can be done by calling getUserAcountData(address) on the lending pool contract. I can ...
0
votes
1answer
20 views

Ethereum is not transferred on Ropsten network

Here's my code for signing nd sending a transaction on Ropsten testnet which is working properly. However, the value that is set to '1' eth is not transferred to the target address. var Tx = require('...
0
votes
2answers
29 views

Infura returns strange error: `query returned more than 10000 results` [closed]

The purpose of the function below is to track USDT that is transferred to and from Yearn and Fulcrum. When I call search_liquidity(_toBlock), I get an error that says Returned error: query returned ...
0
votes
1answer
23 views

Receiving 'undefined' when using getBalance from web3

I am trying to fetch the balance of an address by web3 and node from Ropsten network with the commands below: var Test = require('web3') var url = 'https://ropsten.infura.io/v3/...' var web3 = new ...
0
votes
0answers
15 views

why are transactions per block so small using web3.js?

When utilizing web3.js and calling on the "getBlock" using "latest" as a parameter, there are only several hundreds transactions.. but when I look at the average transactions per ...
0
votes
1answer
27 views

ethereumjs-tx Returned error: invalid sender

When i am trying to send signed transaction via ethereumjs-tx. I get this Returned error: invalid sender web3Http.eth.getTransactionCount(myAddress,"pending").then(function(blockcount){ ...
0
votes
0answers
16 views

How to catch bad web3 eth node endpoint

In the project I am working on (next.js + react) users will enter their own Infura endpoint to connect on-chain. Now is there a way to validate the endpoint they supplied (in this case their input is ...
0
votes
0answers
17 views

why the below error is thrown when doing transaction with metamask to the truffle

the error is thrown is shown in the below picture.While doing the transaction an error stating ethjs-rpc with payload["id:761..,Jsonrpc:"2.0","params":"0xf8..]
0
votes
0answers
21 views

Can't call balancer from web3?

I'm trying to call the exchange proxy 2 in truffle console with web3.js and i get a VM Exception while processing transaction: revert. My truffle console is pointing to a ganache-cli mainnet fork ...
1
vote
0answers
6 views

Get number of logs in block

Given logs are streamed to a client via the eth_subscribe(“logs”) rpc method with a logIndex, is there a way to tell the number of total logs in a block from its header?
0
votes
1answer
13 views

Serialize a transaction

Do you know what is the purpose to serialize a transaction? Here is an example: const serializedTransaction = tx.serialize() Thank you Take care Pierre
2
votes
1answer
39 views

Is there a way to verify transactions afterwards they are entered in the ethereum blockchain?

Suppose I sent a signed transaction using the web3.js library. But, I might be using some third party API like an Infura node or others. So there are chances of attacks and data manipulation. So, is ...
1
vote
2answers
32 views

What's the advantage of interacting with a smart contract from another smart contract (instead of just calling it using something like Web3.js)?

I've noticed there are lots of tutorials online that talk about deploying a smart contract that allows them to interact with other smart contracts e.g. deploying a smart contract to interact with ...
1
vote
1answer
24 views

How to subscribe to transaction with a smart contract in web3js?

I am trying to write a web3js code. I have already written it using web3j (java) and now i want to do exactly same thing but using web3js. I have seen documentation and stuff, but i am not able to ...
0
votes
0answers
22 views

web3.eth.getAccounts() does not return all addresses [duplicate]

so I'm trying to retrieve all the account addresses that are currently present on MetaMask. So I tried to do that using window.web3.eth.getAccounts(console.log) but that seems to be returning just an ...
0
votes
1answer
11 views

Is it possible to retrieve the gas guzzlers from any APIs?

So what I am trying to get is the top gas spenders, the following websites are displaying the data that I am interested in querying, but cannot find an endpoint for this information, so any knowledge ...
1
vote
2answers
37 views

How can i send ether to multiple address in one transaction by paying one transaction fee?

How can i send ether to multiple address in one transaction by paying one transaction fee. Like i want to publish multiple transaction at one go so i can incur only one transaction fee.
0
votes
1answer
36 views

How to construct a raw Ethereum transaction from transaction data

Let's say I have the following transaction information: { "jsonrpc":"2.0" "id":0 "result":{ "blockHash":"...
0
votes
1answer
20 views

Replaying Ethereum transactions, how could I extract the “from” account key from an existing transaction

I'm trying to replay transactions that exist in one chain on another. I can replicate all transaction arguments that are available through eth_getTransactionByHash, but now need to sign the ...
0
votes
0answers
16 views

architecture to automate sending erc20 tokens from contract to EOA

Let's say I bought a millions worth of USDC and sent it to a multi-sig wallet. I'm trying to reward users in my site with USDC right away whenever they accomplished some tasks. Is it possible to ...
0
votes
0answers
12 views

Listen to contract creations on web3

Is it possible to listen to contract creations on web3? For example someone deploys a smart contract on the ethereum chain. Is there a method in web3 where I can listen to such an event?
1
vote
0answers
8 views

Why did an Event Fire even though Etherscan suggests it failed?

I am attempting to count the number of DepositEvents in the Medalla Beacon Contract. At first, I attempted to do this by counting the number of Deposit Events, however, I noticed a Deposit Event that ...
0
votes
1answer
15 views

VM transaction failed reverting the transaction

Solidity smart contract code is: function recharge() public payable { address payable _wallet=address(this); _wallet.transfer(msg.value); } javascript code is: this.state.contract.methods....
0
votes
1answer
34 views

Gasless transactions - sending transaction instead of signing message. How does it work?

I'm following this tutorial: https://docs.openzeppelin.com/learn/sending-gasless-transactions But it doesn't really explain clearly how it works in details. A standard transaction is pretty simple to ...
0
votes
0answers
31 views

nonce too low , please help

please help, I have 1 transaction stuck 7 days, I have sent 1 transaction with 0 ETH and nonce to the same address, to cancel the stuck transaction but all the nonce too low error, looking forward to ...
1
vote
1answer
21 views

ComponentDidMount doesn' detect Metamask change account

I'm quite new to Web3 and Metamask and would like to ask how should I change the basic componenDidMount of the React truffle box so that it can detect and change accounts when I'm switching an account ...
0
votes
2answers
23 views

Getting address of a new contract in truffle with javascript?

I am trying to use truffle-contract and web3 to create a new instance of a contract and then get the contract address of the contract that I just created. I have tried the following code with a few ...
0
votes
0answers
11 views

contract.method.balanceOf() is not a function

Update 1: When I console.log() the imported contract, it turns out that my contract does not have any methods. What could be the issue? I am working on a functionality where it checks the balance of a ...
0
votes
0answers
7 views

Preventing Errant Nodes

Is there a way to setup my network of private chain nodes so that only approved systems can query a node for the data on the chain? The RPC port has to be open so I can run web3 commands but I don't ...
0
votes
1answer
26 views

How to use web3 to buy ERC20 USDT

We are looking to allow our users to buy/sell USDT-ERC. I am confused about how this process works. Initially thought they could just allow them to buy/sell directly using web3 and the USDT ERC20 ...
0
votes
0answers
54 views

How to rewrite this variable in solidity?

I have this code snippet that i want to modify a bit uint256 public constant decimals = 9; uint256 private constant DECIMALS = 9; uint256 private constant MAX_UINT256 = ~uint256(0); uint256 private ...
1
vote
0answers
12 views

Typechain and Batch Requests

I'm trying to send a batch request of transactions to my contract from web3. Using Typechain, my contract's methods are of type NonPayableTransactionObject<void>, which doesn't appear to support ...
1
vote
0answers
22 views

I could not use web3.js module and perform getAccounts etc. for Consortium networks. Hyperledger Besu

const Web3 = require('web3') //var web3 = new Web3('http://127.0.0.1:8585'); var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')); // https://rinkeby.infura.io/v3/...
0
votes
0answers
12 views

Use web3.js on old Javascript version

I need to use web3.js on a platform (ServiceNow) that uses as backend Javascript engine Mozilla Rhino 1.7R5 that doesn't support Typed Arrays (Uint8Array, etc). See here: https://mozilla.github.io/...
0
votes
0answers
22 views

I can not call a function dynamically

token.methods.balanceOf(accounts[0]).call().then(result=>{ console.log(result); $creditsValue.innerHTML = result; }); In this code when I try to fetch the balance from the contract ...
0
votes
1answer
22 views

Web3 error handling in React

This is really a two part question. First, the only way I can get the error message thrown by a Smart Contract require statement is to call the function first with a call rather than a send. send does ...
0
votes
1answer
32 views

Web3.js Smart Contract Method Call Returning Empty string

I don't know why variable "totalItems" doesn't get incremented after my function call of "addItem" and thus mapping remains empty. Smart Contract pragma solidity ^0.5.0; ...
0
votes
1answer
19 views

Uncaught TypeError: TheContract.at is not a function

just trying my first steps in ethereum and web3. So i found this tutorial: https://www.youtube.com/watch?v=hcTPjpPvas8 But it raise an error: index.html:85 Uncaught TypeError: TheContract.at is not a ...
0
votes
1answer
19 views

(JS) Wait until web3 has been established before running function

I'm using an event listener for "DOMContentLoaded" to hopefully wait until my web3 instance has been established. Unfortunately, this does not work as expected and in my getHash() function ...
0
votes
1answer
63 views

How do I know if I am connecting to uniswap factory mainnet or testnet if the contract addresses are common for both?

I had thought each contract deployment and contract address was unique on Ethereum, including across mainnet and testnets. But in the Uniswap documentation it says: UniswapV2Factory is deployed at ...
1
vote
1answer
18 views

Best Practices for Getter Function

I have an array that I wish to display on a website, unit public x[31]. Via web3.js, I can create 32 different calls to x[0] through x[31]. Alternatively, I could add a getter view function to my ...
0
votes
1answer
31 views

sendTransaction returns Invalid JSON RPC response

I am trying to send a transaction to a Besu node that I have running locally. However, from the following code, when I run npx ts-node myFile.ts, I get Error: Invalid JSON RPC response: const Web3 = ...
1
vote
1answer
35 views

Node version upgrade for contract deployment throws error

I wrote a solidity contract using version 0.4.24 using OpenZeppline-solidity version 1.12.0. This used to deploy using the Nodejs version 8.12. The Nodejs version 8 is no longer being maintained from ...

1
2 3 4 5
80