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
1
vote
1answer
23 views

Get data from smart contract interaction before or whitout sending transaction

I have a contract with an ABI and I'm currently interacting with it on ropsten network. I have this function that ask metamask to sign transaction, it's a smart contract interaction and I transfer a ...
0
votes
0answers
38 views

web3.eth.abi.encodeParameter for array of structs

Here I have a smart contract with one method batch that accepts array of users to push into users state variable. contract UserFactory { struct User { string name; uint age; } User[] ...
0
votes
0answers
17 views

I am trying to connect my Website with Remix Ethereum IDE and getting one issue { setInstructor} function is not responding.help me with set function

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1....
2
votes
1answer
38 views

web3js.eth.getAccounts() and ethersjs.listAccounts() always returning one account in an array even when more are in metamask?

I have tested web3js.eth.getAccounts() of web3js and ethers.listAccounts() of etherjs and they are returning an array with a single account although my metamask has one or more accounts. Is this the ...
1
vote
0answers
57 views

How to create a wallet with web3.js

From what I understand, a wallet is a smart contract and in order to create a wallet, you need to deploy the contract to the blockchain as stated here, which is different from creating accounts. When ...
1
vote
1answer
47 views

Is Metamask a web3 provider?

Is Metamask a web3 provider? I am aware it is a wallet. But is it also a web3 provider? I have read from here that: Web3 provider is a website running geth or parity node which talks to Ethereum ...
0
votes
0answers
11 views

How to get smart contract assertion message thorugh web3.js? [duplicate]

I revert a transaction in my smart contract when a specific condition is met. For instance: function doMoneyLaundering(uint256 millionsOfDollars) public { ... require(...
0
votes
1answer
31 views

Is ABI necessary for calling ropstend smart contract?

I only have ropsten's smart contract address, so I'm trying to get it through web3.js with: window.web3.eth.Contract(abi, address) but i see in the documentation it receives two parameters, i don't ...
0
votes
0answers
39 views

Calling function from web3 fails, calling it from truffle console works

I have the following JS code to call a contract: const txHash = await timelockContract.methods.executeTransaction( "0x71c1179e3C351De2641845cDAe537aCFC1808Fd2", 0, "&...
0
votes
0answers
16 views

VM Exception while processing transaction: revert - buying transaction

Hey bit of a newbie to ethereum dev over here. I'm building a marketplace for ERC 721, currently, i've been getting this error when I called in buying method. Contract code: function buyJam(...
0
votes
0answers
21 views

What happens when you 'create' an item on the OpenSea app?

Very noobie here. I'm sorry, Does anybody know what happens on OpenSea when you actually CREATE an item? I know it doesn't mint one but what it does? (As it signs a transaction tho). I've been trying ...
1
vote
0answers
20 views

eth_signTypedData does not exist [closed]

with any web3 or ethers provider I am getting this error. This is suddently startedoccuring. Noticed it when my hardhat test cases started failing. Is anyone else facing the same and has solution?? ...
0
votes
0answers
25 views

Transfer ERC20 token from smart contract to wallet using sendSignedTransaction

I have s smart contract that holds ERC20 DAI token that needs to be transfer to my wallet. Using javascript web3 side on kovan testnet: const EthereumTx = require('ethereumjs-tx').Transaction const ...
0
votes
0answers
15 views

Use Web3js library

I am new to the use of blockchain we are building an application where I have the following problem to solve: Users when registering in our system will create a wallet of an ethereum token Be able to ...
0
votes
0answers
14 views

Why is a proxy object created when you try to access the same web3 object outside of the scope where it was created?

I have two functions, called one after another. The first one called creates a new Web3 object and sets it to window.web3: async loadWeb3() { window.addEventListener('load', async () => { ...
1
vote
0answers
23 views

Sending bytes to contract from web3

so I have the following function in my smart contract: function proxy(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) { callData = ...
1
vote
0answers
47 views

How to connect web3.js 1.3.4 to MetaMask?

I am trying to connect to MetaMask and I have read their docs about the breaking changes and everything. From what I understand, they are not injecting web3 into window.web3 but instead are using ...
0
votes
1answer
23 views

What is the equivilent to Solidity's abi.encode() function in Web3 JS?

I have a function in Solidity, that I would like to replicate using Typescript and Web3 function mint( address to, uint256[] memory ids, uint256 indexToMint ) public { ...
1
vote
1answer
58 views

web3 get_transaction get_transaction_receipt how to see the error-Message for a failed transaction

I am using the web3-implementation from python (web3.py) and use the both methods get_transaction and get_transaction_receipt to lookup failed transactions. If the status-field from ...
1
vote
1answer
18 views

web3.getPastEvents return events but can't subscribe to an event

I have a contract which has an event. The contract's code is pretty simple: pragma solidity >=0.7.4; import "./Crowdfunding.sol"; contract Factory { address[] public ...
0
votes
1answer
15 views

Display tokem amount in dollar in dApp frontEnd

How do I return token amount in USD using web3js ..or is there some kindof API to be used ? For instance , say user has 3ETH and also want the user balance to show in USD just as metamask does
0
votes
0answers
12 views

Web3.js call() on view function on Smart Contract is failing

I am trying to access a simple variable on my smart contract, locally inside my nodejs application. The relevant parts of my contract look like this import "@openzeppelin/contracts/utils/Counters....
1
vote
1answer
53 views

How do I identify the right gas to set in web3 send?

This is my send code: window.videoContract.methods .mint(account, 'https://ipfs.io/ipfs/QmRQC1...') .send({ from: account, gas: 20100000 }); If I set it too high, I get ...
0
votes
0answers
4 views

Transaction has been reverted by EVM (Matic Mumbai Testnet)

I am getting the following error when trying to mint through my ERC721 contract. How can I determine the cause of the failure? https://explorer-mumbai.maticvigil.com/tx/...
0
votes
0answers
9 views

The Graph Compound API

I want to build a small project to simulate app.compound.finance (with just eth token let's say) with The Graph , how can I get supply/borrows balance per users? (my defi app initial setup is done, ...
0
votes
1answer
19 views

How to send erc20 tokens through web3 on nodejs

My transactions go through without errors, while they're pending the data field shows the amount of tokens I'm sending, but when the transaction goes through the data field is empty. Here is my code: ...
0
votes
0answers
16 views

Simple Web3 installation and calling contracts

I have been trying to inject metamask into my site using web3. I have called web3 in my site as below and started the site using local server(VS Code extension which gives me port:5500) window....
0
votes
0answers
4 views

tracking state changes via function calls that does not include event usage

Is it possible to track changes made to a smart contracts via its functions if the functions are not emitting events. I suppose if I know the function signature representation, then I should be able ...
0
votes
0answers
21 views

How to increase the maximum blocks for `getPastEvent` method for web3?

I'm trying to get the past events from a contract's Deposit method: const events = await tornado.getPastEvents('Deposit', { fromBlock: 0, toBlock: 'latest' }) However, web3 throws an error saying it'...
0
votes
0answers
36 views

Transactions are mined before monitored transaction with same params (BSC)

On BSC chain, i am facing this situation. I am scaning mempool for a transactions ( nodejs and web3.eth.subscribe('pendingTransactions', ...) ) and when i find the one i am concerned, i fire a ...
0
votes
0answers
17 views

Deploy a contract (factory) with web3 based on the connected wallet?

A big newbie into solidity here. I’ve managed to compile and deploy (with truffle) a ContractFactory from OpenSea repository. Long story short the part with the deployment is this if (...
0
votes
0answers
9 views

Access old transaction from a web react dapp

I have create a dapp react app with this command: $ truffle unbox react I have a sample web application in src/client/ folder. This web application is able to communicate with Ethereum smart-contract ...
0
votes
1answer
38 views

Web3 transaction execution is slow (5 secs)

I am trying to send a transaction to a contract through web3, with the following code: const c = new web3.eth.Contract(contractData.abi, address) console.log(new Date()) const x = await c.methods....
0
votes
1answer
24 views

Why do web3 dApps need servers?

I see a lot of projects run into server capacity issues at launch (token sale, nft launch, etc). [1], [2] What reason(s) would require these projects to have a server, versus deploying a static ...
0
votes
0answers
9 views

Should my application be decentralized? (Basic Question)

I know this is a seemingly basic question, but one that I have not found many solid answers to. I have been programming for a few years now and with the recent NFT boom, DApps have caught my interest. ...
0
votes
0answers
13 views

Send web3js event to webhook when it happens

I have a transfer method that transfers a token using the deployed smart contract in Web3JS. I have to return the values to the customer, so I subscribe to the transfer event and wait for it to ...
1
vote
0answers
40 views

eth_estimateGas Error when balance of an account < the amount to send in a transaction

I have used the following request to estimate gas in an ETH transaction in Ropsten. ## JSON-RPC over HTTPS POST curl https://ropsten.infura.io/v3/YOUR-PROJECT-ID \ -X POST \ -H "Content-...
1
vote
0answers
27 views

How to let the user sign a nonce in frontend and check the authenticity in the backend?

My frontend code: html (using cdn, couldn't make the npm run...): <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script> javascript: web3.eth.personal....
0
votes
1answer
37 views

I AM Trying to connect my Website with Remix Ethereum IDE and getting Error { (index):85 Uncaught TypeError: CoursetroContract.at is not a function}

''' Document <link rel="stylesheet" type="text/css" href="main.css"> <script src="https://unpkg.com/web3@latest/dist/web3.min.js"&...
0
votes
0answers
56 views

Are binance ERC20 token transactions not on the ethereum blockchain?

I'm using web3js get transaction info on a specific ETH address. When I make the getTransactions call, no info is presented. I then check etherscan and also see that my binance ETH wallet (for ...
1
vote
1answer
43 views

ERC20 token transfer attempt resulting in underpriced (price change attempted)

It's almost an exact copy of this but when I ran it, I get the following error message. (node:5189) UnhandledPromiseRejectionWarning: Error: Returned error: transaction underpriced Below is the code ...
3
votes
1answer
84 views

Solidity's keccak256 hash doesn't match WEB3 keccak hash

TL;DR: I have a method in a contract to calculate a keccak256 hash, and I'm trying to replicate it in Web3, but the hashes don't match. My problem is very similar to the one in this question, but the ...
1
vote
1answer
15 views

Solidity contract does not update variable when calling it from web3.js

my solidity code compiled using solcjs // SPDX-License-Identifier: MIT pragma solidity >=0.7.4; contract FirstContract { int count = 0; function incr() public{ count = 15; } function ...
0
votes
1answer
20 views

Getting the v, r, and s parameters using web3js or ethersjs

web3 documentation says that using the web3.eth.signTransaction returns the object which (inside the other object) has the r, s, and v of the message: However, I am not getting that: Any idea in how ...
0
votes
1answer
44 views

Interact with a contract function using Web3.js

I finished testing my smart contract functionality with "unlocked accounts" (which don't require complex signing) on a local dev blockchain, but now I would like to deploy on MAINNET and use ...
0
votes
0answers
28 views

Deployed truffle contract: Cannot create instance of <contract>; no code at address

I deployed my contract at 0xa518a732606baae1c72490313cb7bb42c62c7a50. Now, what I try to do is to interact with my functions.. I've created an node.js application over web3 and truffle/contract but I ...
1
vote
0answers
30 views

Still Unable to Unlock Personal Account in Geth - Syntax Errors, GoError

In my MacBook Terminal -> Geth, I have successfully created my new -> personal.newAccount(0xA93d5aC3B28587DA16E4821F571ACF44B6B28176) along with its given generated password. I’m still unable ...
0
votes
1answer
41 views

Trying to send transaction on next block

I'm trying to understand block time and speed of transaction. For now I'm testing on Binance Smart Chain and then I will go to ethereum network. I have a simple code in nodejs using web3 library, I'm ...
1
vote
0answers
52 views

Encode nested structs using web3

I'm using Solidity 0.8.0 (so I'm using ABIEncoderV2) and web3.js 1.3.4 and I'm trying to call a contract's method passing a nested struct. erc1155.methods.safeBatchTransferFrom( owner, ...
1
vote
0answers
13 views

get all transfer events with getPastEvents that are from or to an address

i want to get all the events transfer from a erc20 token , that has a relation with an address either he send tokens or he recived them ,but filter with both fields with the same addres is like an &...

1 2
3
4 5
89