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
1 answer
3k views

differents between web3.eth.signTransaction And web3.eth.accounts.signTransaction

I don't understand the differents between these methods web3.eth.signTransaction and web3.eth.accounts.signTransaction And when I have to use. If I try to use web3.eth.signTransaction with ganache ...
9 votes
5 answers
28k views

How can I get my address via web3?

I'm using web3, truffle and testrpc. In my smart contract, some of the functions can only be called by the owner (or creator) of the contract (i.e. onlyOwner functions). So, I've defined some ...
0 votes
1 answer
811 views

getPastEvents on localhost is not a function error

Now, I'm working on an Ethereum Blockchain project to transfer the ownership of stored devices by using local web3 provider at the truffle environment. Truffle v5.0.27 (core: 5.0.27) Solidity v0.5....
0 votes
1 answer
236 views

How to Export public key from Metamask

【Front】 const keyB64 = await window.ethereum.request({ method: 'eth_getEncryptionPublicKey', params: [accounts], }); const publicKey = Buffer.from(keyB64, 'base64') ...
0 votes
1 answer
27 views

Web3 related jobs

I am looking for job opportunities in the web3 space. May I know what are some areas/ websites where I can find such jobs? Would greatly appreciate some help here. Thanks!:)
5 votes
3 answers
5k views

How to catch solidity contract revert message using web3js

Is there any way to catch solidity revert message like Remix Javascript VM in web3j Revert message(Remix) transact to Erecruitment.issueNewAdmitCard errored: VM error: revert. revert The ...
1 vote
1 answer
321 views

Tuple in Javascript

I'd like to send a transaction to a smart contract (token swap). https://ftmscan.com/address/0xa38cd27185a464914d3046f0ab9d43356b34829d#code The smart contract requires an additional boolean value ...
0 votes
2 answers
448 views

app.vote(1, {from: web3.eth.accounts[0] }) not working

I am following a tutorial from Dapp University about building Election Smart Contract. When I run this command in the console: app.vote(1, {from: web3.eth.accounts[0] }) I get the following error: ...
0 votes
1 answer
222 views

Web3js can not touch smart contract, always return 0

web3js can not touch smart contract. var id = dragoncore.getGenesNum(); has no error, but always return back 0, never changed. -----------------------------web3js code ----------------------------- ...
0 votes
1 answer
202 views

Gas estimation errored with the following message (see below). Internal JSON-RPC error. { "code": -32000, "message": "execution reverted" }

Using polygon Testnet Network in metamask while calling donate function using remix following error occured:- Gas estimation errored with the following message (see below). The transaction execution ...
0 votes
1 answer
422 views

Proper way of automating trades on uniswap with nodejs

I am wondering what would be the proper way (if possible at all) to automate trades on uniswap using their SDK or just web3 or ethers with the router and factory contract instances. I want to build a ...
0 votes
1 answer
10 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. ...
0 votes
1 answer
231 views

Source file compile error

... Source file requires different compiler version (current compiler is 0.8.2+commit.661d1103.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version ...
-1 votes
1 answer
6k views

Getting error -> unexpected token. You may need an appropriate loader to handle this file type

root@kali:~/Documents/oraclize-test# npm run dev truffle-oraclize-api@0.0.2 dev /root/Documents/oraclize-test webpack-dev-server ERROR in ./app/javascripts/app.js Module parse failed: /root/...
0 votes
0 answers
9 views

Fetch Transaction Data/Block Data on Solidity

is there a method to call web3.eth.getTransaction or web3.eth.getBlock on Solidity? Or is there an oracle that allows to do so?
0 votes
1 answer
418 views

Private Ethereum Chain and Web3 js API

I've developed my own private chain for testnet using geth and CLique and i have some issues with web3.js environment. I starts my nodes using the console parameter in order to get to the Web3 console ...
0 votes
1 answer
13 views

contract.methods.payFund is not a function. Unable to call any of my contract function

I am unable to call any function of my contact.............. when I am printing my contract object it shows that all the functions are in the object but unable to call. It is the output when i print ...
1 vote
1 answer
676 views

Call `getPastEvents` with Drizzle raise error: "getPastEvents is not a function"

Calling getPastEvents with Drizzle will cause the exception: TypeError: this.drizzle.contracts.Contract.getPastEvents is not a function How to get all the past events in an array (in-one-shot) ...
8 votes
1 answer
1k views

getting started with geth and ENS commands: Error: invalid address

I'm starting from square zero, sorry. I'm just trying to get a javascript console up and running so that I can learn more about ENS: http://docs.ens.domains/en/latest/userguide.html#resolving I've ...
0 votes
1 answer
23 views

"Cannot read property 'utils' of undefined" on web3.utils

This is my code: import {web3} from "hardhat" const OWNER_ROLE = web3.utils.keccak256("OWNER_ROLE"); This is the error in my terminal: const OWNER_ROLE = web3.utils.keccak256(&...
0 votes
1 answer
522 views

Problem to connect my DAPP to Rinkeby smart contract

I make small samart contract using Remix and Ganache. I deploy it to Rinkeby test net and got problem to connect my dapp (small web site) to it. My web3 require. window.addEventListener('load', ...
2 votes
1 answer
350 views

Set method name for MetaMask history

I have a question about the Metamask UI. Is it possible to set custom transaction method name for metamask history to make it more user-friendly? I want to rename "Bid" (default method name) to "Made ...
0 votes
1 answer
73 views

this.state.manager returning an empty array

I've made a solidity contract which was deployed perfectly. Now, when I'm connecting with it my react Dapp after getting the ABI and address and trying to render it, it renders nothing. my web3.js ...
1 vote
0 answers
22 views

Public key to ethereum address in javascript without (or minified sha3 library)

I am trying to get rid of the web3js library and this is the last hurdle. Before i used web3.utils.keccak256(eth_public key) How can i do this with minimal amount of code in javascript. I tried https:/...
0 votes
1 answer
257 views

Truffle and Ganache GUI: GUI and blockchain disconnect or some other error

For some reason, I am having a lot of weird issues with ganache at the same time and I have no idea what's causing them or even what to show to explain it. After migration, which appears to succeed, ...
0 votes
0 answers
9 views

Parameters that can be passed in curly braces for message call and delegate call

When I use "call" in solidity I am able to pass parameters in parenthesis and in curly braces. What is the full list of parameters I can pass in curly braces? What is the main difference ...
1 vote
3 answers
2k views

Transfer erc721 token to another address

I'm currently using transferFrom / safeTransferFrom to transfer the token to another address but I encounter this error. Error: Error: invalid address (arg="to", coderType="address", value="...
2 votes
1 answer
482 views

Events stop triggering after a while

I created a script that subscribes to PairCreated event on Uniswap using Web3 and Infura API. The event works for a few minutes but stops working after a while (timeouts?). How can I make it watch the ...
5 votes
1 answer
5k views

Injecting a private key into web3.js execution context

I'm trying to achieve what seems like a simple goal but having trouble finding a simple solution to it. Here's my problem: Given a private key, I would like the simplest way to "inject" this key ...
1 vote
2 answers
3k views

account recovery with web3 privateKeyToAccount()

I'm currently stucked by this strange thing: I started by exporting my private key(fdba67e41f7c6767100969ae3f045d10a59e35d380acf5b37a3b208bd2969347) from my metamask account, which i can use to login ...
1 vote
1 answer
9 views

Work out Eth price from getAmountsIn method

I am attempting to create a test arbitrage bot using Uniswap & SushiSwap. I can successfully get the amount of X tokens I would get for 1 WETH on both dexes. For example: ​ Uniswap: WETH / USDT ...
0 votes
1 answer
1k 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){ ...
2 votes
1 answer
1k views

Removing LP from Uniswap/Pancake using seth and removeLiquidityWithPermit(). How is the correct hash for the permission signing calculated?

I'm trying to figure out how I can remove LPs from Uniswap/Pancakeswap using the function removeLiquidityWithPermit(address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 ...
1 vote
0 answers
10 views

In geth, `eth.syncing` gives `false`

In geth, eth.syncing gives false but when I check the eth.blockNumber I get the latest block? And also all of my eth account has zero balance? how can I add balance or its just node not syncing yet or ...
1 vote
1 answer
267 views

SendSignedTransaction TIMEOUT

I'm trying to sign data offline and then send signed transaction via web3.js Here's my code snippet: const {sign} = require('@warren-bank/ethereumjs-tx-sign'); const {Loader} = require("loader-in-...
1 vote
1 answer
282 views

getPastEvents undefined(please help)

I had asked this question before. I looked carefully at the exchange section, which I advised, and I think there is no problem with the exchange section. At least in my opinion there is no problem and ...
0 votes
1 answer
466 views

web3 Uncaught TypeError: Cannot read property 'createBox' of undefined

i'm trying to create simple application by using solidity 5.0.0 , Truffle v5.0.0 and web3 web3@1.0.0-beta.34. but i've gotten Uncaught TypeError: Cannot read property 'createBox' of undefined. ...
0 votes
0 answers
14 views

How to detect which Wallet is connected?

I have a web3 application where I use three types of wallets: MetaMask, WalletConnect, BianceChain, users can connect to these wallets,Problem is I can not detect which wallet user comes from, is ...
0 votes
1 answer
19 views

Is there sdk to create new account in Polygon through web3

Is there any functions or API to create a new account in polygon, like hashgraph in hedera, is there any function or API to create a new account through code in the polygon? I really appreciate any ...
0 votes
1 answer
570 views

Connect to my EC2 geth node with JSON RPC

I have set up a geth node on an EC2 instance. I'm running it with tmux to make sure it continues to run after I disconnect from the server. To make the node remotely accessible I followed this NGINX ...
0 votes
2 answers
464 views

TypeError: value.forEach is not a function when calling a function

I am using Truffle to deploy a contract on Ganache and retrieve the contract in an express app. While I can get the contract instance and it can console.log a list of function object, the function ...
2 votes
1 answer
1k views

Transferring an ERC20 token from one address to another

I'm using web3 to transfer an ERC20 token (for a contract already deployed on the Ethereum blockchain) from one address to another. The code I'm using is shared below: // script.js Web3 = require('...
1 vote
1 answer
584 views

Solidity Error:Running Out of Gas / selfdestruct problem

I've been going through 'Building Cryptocurrency and its ICO' by DappUniversity. I know many have questioned this issue and I've been through all the post but couldn't resolve it. The problem is self-...
0 votes
0 answers
7 views

Can i create pending transaction that get execute once there is enough gas fees in my wallet?

I have a permession for a scam smart contract that steal every eth that transfer to my wallet I also have some other tokens like USTD I can't transfer the usdt out because I don't have enough gas fees ...
0 votes
1 answer
15 views

Why am I getting incorrect WBTC when swapping it with DAI using Uniswap?

Hi I created a smart contract but when I am swaping 1 Million DAI with WBTC tokens I am getting only ~3379786784 WEI (~34 WBTC) but when I am checking its value on UNISWAP website it is showing 43 ...
0 votes
1 answer
346 views

end process after web3 sendTransaction return transactionHash

I want to end the process after sendTransaction return transactionHash. Here is my code currently : const Web3 = require('web3'); const web3 = new Web3("http://127.0.0.1:8545"); async function task(...
0 votes
0 answers
8 views

Hello please give me answer in my questi [closed]

How to connect web3 in react native App, How to get balance web3 in react-native
0 votes
0 answers
7 views

Setting an array useState([]) variable in React.js returns undefined

I have been trying to create a Web3 dApp using React.js. My first step was to connect the browser to a MetaMask wallet. So I first started by initializing a useState array variable named "wallets&...
1 vote
2 answers
1k views

How to call my smart contract method using new metamask

I am able to connect or call the send txn method of ethereum using new metamask script. But i m not able to call the method of any of custom contract. Can someone tell me how can i do in javascript? ...
0 votes
1 answer
22 views

Data from smart contract not properly showing JavaScript code

async function viewmyactivedeposits() { const result = await myLoanContract.methods .viewMyActiveDeposits() .call() .then(function (result) { let data = Array.from(result); $(...

1
2 3 4 5
117