Questions tagged [javascript]
JavaScript is a dynamic, weakly-typed language used for client-side as well as server-side scripting.
1,319
questions
0
votes
1
answer
42
views
How to enable support for the experimental syntax 'classPrivateProperties'?
I am getting the following error in my React project when trying to import ethers:
./node_modules/ethers/lib.esm/abi/abi-coder.js
SyntaxError: /node_modules/ethers/lib.esm/abi/abi-coder.js: Support ...
0
votes
1
answer
31
views
How to pass parameters to upgradable contract
I'm trying to use this deploy script for an upgradable contract
async function main () {
const Box = await ethers.getContractFactory('NFT');
console.log('Deploying Box...');
const NAME = "...
0
votes
0
answers
23
views
Can anyone help me write this for the Ethereum blockchain?
const fs = require('fs')
const Web3 = require('web3')
const { Client, NonceTxMiddleware, SignedTxMiddleware, LocalAddress, CryptoUtils, LoomProvider } = require('loom-js')
function loadAccount (...
2
votes
1
answer
338
views
Uniswap Universal Router - Decoding the Execute function parameters
I used the method described in this thread (Decode Uniswap Universal Router transaction in ethers.js) and decoded most of the data of a transaction at this link: https://arbiscan.io/tx/...
0
votes
0
answers
23
views
Please can anyone help me in converting this from Loom to Ethereum testnet?
I am trying to deploy this on Ethereum Goerli instead of Loom but do not understand what all to change. I am getting a lot of errors. Please, can anyone help me?
Error Message
PS C:\Users\VidhanMangla\...
3
votes
7
answers
4k
views
TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')
const ethers = require("ethers");
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/MYKEYISHERE')
web3.eth.getBlockNumber().then(console.log)
Error:
...
2
votes
2
answers
30
views
Sending TX in Ethereum won't return a response
I'm trying to send ETH in goerli by this code
let
provider = ethers.getDefaultProvider(process.env.ETHEREUM_NETWORK);
let wallet = new ethers.Wallet(prK, provider);
wallet.sendTransaction({
to: ...
0
votes
1
answer
103
views
While I was working on solidity project I got the following error
npx hardhat run scripts/deploy.js --network localhost is not working.
It says
TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')
My deploy script
const hre = require("...
0
votes
0
answers
47
views
TypeError: ethers.getContract is not a function | Lesson 07 Hardhat
I'm Following Patrick Collins's Blockchain Course from Youtube.
On lesson 07 at timestamp 11:18:00, I run the following command to run test
yarn hardhat test
I get the following error
1) "before ...
0
votes
0
answers
108
views
Solidity project error with my deploy.js script
I cannot get this to work:
npx hardhat run scripts/deploy.js --network localhost
The deploy script returns:
TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')
This is my ...
1
vote
2
answers
484
views
Nextjs 13 and Ethers properties of undefined (reading 'Web3Provider')
I'm trying to access the ethers provider like this in Nextjs 13.0.1:
import { ethers } from "ethers";
export const signMessage = () => {
const provider = new ethers.providers....
0
votes
1
answer
18
views
I was working on solidity project and got the error that Identifier not found or not unique
/ SPDX-License-Identifier: MIT
// SPDX-Licence-Identifier: MIT
pragma solidity >= 0.7.0 < 0.9.0;
contract ChatApp {
// USER STRUCT
struct user {
string name;
friend[]friendlist;
}...
0
votes
3
answers
21
views
getting error that says expected ';' but got '}' please some one help
// SPDX-License-Identifier: MIT
//SPDX-Licence-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract ChatApp{
// USER STRUCT
struct user{
string name;
friend[] ...
0
votes
1
answer
14
views
Chainlink UpKeep Registration ABI Error Problem
Everytime I try to register my UpKeep on Chainlink Automation, I get this error, "ABI must be of type { "name": string, "inputs": { "name": string, "type": ...
0
votes
0
answers
51
views
Error: Expected private key to be an Uint8Array with length 32
const HDWalletProvider = require("@truffle/hdwallet-provider");
require('dotenv').config();
const privateKeys = [`0x${process.env.PRIVATE_KEY}`]
this is my code in truffle-config.js but its ...
0
votes
0
answers
14
views
Receiving Invalid Address on Web3
I am having issues launching my web3 connected to Solidity (on Remix) and MetaMask. The error that popped out was that I have an invalid address and they were referencing the function called ...
0
votes
1
answer
139
views
How can I get transactions from a specified wallet, ethers.js, Alchemy websockets
I can't get the transactions from a specific wallet provided, it's weird because I can get transactions filtering with the to argument and other arguments but when using from it doesn't. I don't ...
0
votes
1
answer
35
views
Finding size of a block number
Below is a simple programme which includes web3 :-
let web3 = require('web3');
var real = new web3(web3.givenProvider) // web3.givenProvider is having value of my infura endpoint
discuss();
...
1
vote
1
answer
74
views
Retrieve Ethereum public key from transaction data
I'm trying to get an Ethereum address public key from its previous transaction data. What I'm trying to achieve is to be able to get this data from a block explorer API like Etherscan API and then ...
1
vote
1
answer
40
views
Object Promise message is displayed
const readData = async () => {
const data = window.contract.methods.getName().call();
document.getElementById("dataArea").innerHTML = `Message is here: ${data}`;
why am i ...
0
votes
0
answers
8
views
Error message in hardhat snaps project in @ethersproject dependency
Can someone please look into the error I am getting while building a Metamask Snaps project within FEVM Hardhat Kit. Here's the error message:
TypeError: Cannot read properties of undefined (reading '...
0
votes
1
answer
107
views
Calling contract function to send ETH from contract to wallet only shows gas on metamask transaction
I have the following smart contract function that is supposed to be called from a web app, using ethers and Metamask, running on Hardhat localhost blockchain. Its purpose is to send the specified ...
0
votes
1
answer
49
views
the method eth_blockNumber does not exist/is not available
Hello hope are good ?
I have my own full node with a ssh tunnel
My code is :
async function test (){
const url = 'ws://localhost:8546';
const web3 = new Web3(new Web3.providers.WebsocketProvider(...
0
votes
2
answers
37
views
Web3.js Integration not working
Below is the simple programme which I wrote to use EVM compatible functions in VS code.
let web3 = require('web3');
const tr = new web3(web3.givenProvider || "ws://localhost:8545"); // ...
1
vote
2
answers
122
views
Difference between provider.sendTransaction vs signer.sendTransaction?
I am finding it difficult to see the difference between these two, what are their respective use cases?
0
votes
1
answer
60
views
How to generate the correct hash for signatures?
I want to create a hash in JavaScript for a signature.
The hash needs to have the same output as this in solidity:
keccak256(abi.encodePacked(address, bytes32))
My solution in JavaScript so far ...
1
vote
1
answer
75
views
"execution reverted: ds-math-sub-underflow" when processing swap
I get this error or another error err: insufficient funds for gas * price + value, which has been exhaustively discussed, but no real solution has worked for me here.
I saw the suggestion made here, ...
0
votes
1
answer
38
views
Testing and Deploying a Solidity Contract on Ethereum - Error: Transaction reverted: function call to a non-contract address
Having trouble testing the following code as I get the following error in the photo: "Error: Transaction reverted: function call to a non-contract account"
According to the error, the issue ...
0
votes
1
answer
15
views
Why am I facing error here? Related to signing transactions
Why this error occuring?? Can someone direct me to some good resources where I can see what units to provide in the parameters?
0
votes
0
answers
12
views
How do I retrieve the account balances for proof of solvency?
I read Vitalik’s article “Having a safe CEX” and got curious about builting my own proof of solvency program. I understand how the merkle sum tree works in theory but I am having issues understanding ...
1
vote
2
answers
43
views
Listening to multiple smart contracts
Is there an "optimal" way to listen to multiple smart contracts?
For example, listening to an event emitted by one smart contract in a useEffect:
useEffect(() => {
const ...
0
votes
2
answers
44
views
Could not create addresses from your mnemonic or private key(s)
I'm trying to use truffle to deploy a smart contract onto the ethereum blockchain. There are four commands to make this happen:
truffle compile
truffle migrate --network mainnet
truffle test
truffle ...
0
votes
0
answers
33
views
Getting this error on deploy "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'context')"
I'm getting this error
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'context')
When i deploy my next js Dapp on localhost it's running perfectly! And i really don't ...
0
votes
0
answers
16
views
My staging test and unit tests are exceeding timeouts
Whenever I try to pass my staging tests, its exceeding the timeout of 500000ms. Same is for my unit test "picks a winner , resest the lottery , and sends money:" test. I am pasting my code ...
0
votes
0
answers
13
views
Truffle migrations - it doesn't recognize the network from external file, why?
1_initial_migration.js file:
const Globals = require("../globals.js");
const Migrations = artifacts.require("Migrations");
const Test = artifacts.require("Test");
...
0
votes
1
answer
24
views
Why doesn't formatEther apply to my simple code?
So I have a React app and in it I need to check the balance of USDC tokens in my smart contract. For that there is a simple solution, but somehow the USDC value on display does not format (it has 12 ...
0
votes
1
answer
45
views
Invalid opcode OR Cannot read properties of undefined (reading 'length') (depending on the situation)
I'm working on a bot that loads in a bunch of values from an array and uses an event handler to take action upon an event. This was originally built as a bot to monitor a swap on two exchanges for a ...
0
votes
1
answer
22
views
deployment errors in code due to constructor arguments
here is the contarct I am trying to deploy:
// Raffle
// Enter the lottery (paying some amount)
// Pick a random Winner (verifiably random)
// Winner to be selected every x-minutes -> completely ...
0
votes
1
answer
29
views
Facing constructor arguments error while running my staging tests on the goerli network
here is my staging test below which I am trying to test on goerli network:
const { assert, expect } = require("chai")
const { getNamedAccounts, ethers, network } = require("hardhat"...
0
votes
1
answer
25
views
Staging test errors: Error: No Contract deployed with name Raffle
const { assert, expect } = require("chai");
const { getNamedAccounts, ethers, network } = require("hardhat");
const { developmentChains } = require("../../helper-hardhat-...
0
votes
1
answer
50
views
Metamask SDK window is not defined on nextjs
I`m trying to integrate Metamsk SDK to my Dapp, but when implementing the steps on the basic tutorial of their documentation I get the Reference error related to window, here is my code:
import { ...
0
votes
2
answers
130
views
How to use getReserves() in a forEach loop?
How can I use getReserves inside a forEach loop to call the reserves relative to each array object (the array objects are token addresses)? Details below:
I have an array of addresses being monitored ...
0
votes
1
answer
51
views
Intrinsic Gas Too Low - Where Do I Add The Gas?
I've seen this question here a lot, but just to restate for my purposes, I'm using truffle and attempting to monitor the blockchain for price swaps. I do not currently have a contract deployed but, I ...
0
votes
0
answers
61
views
How many ERC-1155 NFT's can be burned together as a batch?
I want to create an NFT Marketplace for ERC-1155 tokens, where after buying the NFT, one can burn the different NFTs together (as a batch) to get rewards. Can anyone help me determine if this is ...
0
votes
0
answers
17
views
Gnosis Safe SDK createAddOwnerTx returns Error: Invalid owner address provided but the address is actually an owner
I'm building an app to manage a Safe using the Gnosis Safe SDK. The deploySafe method works fine for creating one but if I try to add or remove an owner it returns this error:
Error: Invalid owner ...
0
votes
2
answers
87
views
Error: connection not open on send()
I'm using Web3.js and am trying to monitor the Ethereum mainnet. Up until now I have been testing on a local environment, but I want to test it live now. Here's the relevant code:
const Web3 = ...
1
vote
2
answers
110
views
Problems with transfering ERC721 tokens using safeTransferFrom
I'm trying to create a functionality where users can send their ERC721 tokens to my smart contract. I want to use the safeTransferFrom method, as it calls onERC721Received which ensures my system that ...
0
votes
1
answer
36
views
is it possible to make a whole blockchain from scratch using javascript?
I was wondering if javascript has alot of tools of doing stuff and help with hashing and helper nodejs modules that help with web3 development but my question is it possible to make something like ...
1
vote
1
answer
47
views
How to use web3.storage in-place of Infura as IPFS for my NFT Marketplace?
I wanted to use Infura as my IPFS for a project, but now as it has been deprecated, I got a suggestion to use web3.storage instead. But I couldn't find any useful tutorials for using it in my project. ...
0
votes
1
answer
179
views
Programmatically sending 1,000 transactions at once in JavaScript - how many transactions can 1 wallet send at once?
I'm writing a script that will send 10 MATIC to 1,000 addresses. What I have written so far seems to achieve this on my local Ganache server (pretending ETH is MATIC). But I am assuming this is going ...