Questions tagged [javascript]

JavaScript is a dynamic, weakly-typed language used for client-side as well as server-side scripting.

Filter by
Sorted by
Tagged with
0 votes
0 answers
6 views

Unpacking arguments when calling a smart contract function with web3.py

I'm trying to reproduce some code on python that is currently working on javascript. The main goal is to select a function to query from the contract abi and call it (just view functions). Let's say ...
user avatar
  • 111
0 votes
0 answers
4 views

IPFS upload is creating uselless subfile

I am using Web3 Storage in order to upload my data to IPFS. The link always ends up being ipfs://CID/1.png instead of ipfs://CID. This is my code: import { Web3Storage, getFilesFromPath, CIDString } ...
user avatar
  • 81
1 vote
1 answer
9 views

Wait for incoming ethereum transactions and credit them after n confirmations

I'm trying to create a website where users can deposit ethereum. For my server I'm using node.js and express.js. I looked into web3.js but the docs are unclear to me and I don't know which functions ...
user avatar
  • 11
0 votes
0 answers
5 views

Is there any way to get autocomplete for Solidity function definitions in JavaScript?

By autocomplete I mean something akin to how functions that would be declared in JavaScript get prompts/autocomplete in IDEs. (Also, I'm using VS Code)
user avatar
0 votes
0 answers
20 views

Error: Transaction reverted: function call to a non-contract account (while running tests)

I've been getting this error while testing my staking contract, the earlier tests where i am calling getter functions work correctly but I am getting an error probably while calling the stake() ...
user avatar
  • 11
0 votes
0 answers
7 views

How to decrease computation time of generating addresses

I tried to create a mass wallet generator for a vanity address but it only checks 33 wallets a second. Is there any optimizations or bad practices you see? const cluster = require("node:cluster&...
user avatar
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); $(...
user avatar
  • 1
1 vote
0 answers
21 views

A library for converting general cryptocurrency's private key to address

Is there a library on npm to convert a given private key and cryptocurrency's name to an address? E.g. Tron and Ethereum give different addresses when using the same private key: let addrEthereum = '...
user avatar
  • 111
0 votes
1 answer
17 views

Sha256 Hash from Solidity Smart Contract doesn't match web3.js Hash

I'm struggling to match two hashes. I hash a Json in String format in my Smart Contract like this. function verifyProof(string calldata _fullProof) public returns(bool r){ bytes32 hashed = ...
user avatar
0 votes
0 answers
12 views

Metamask login not working in alchemy "building a full stack nft dapp" lesson

I'm trying to go through https://www.web3.university/tracks/build-your-first-nft/building-a-full-stack-nft-dapp but for some weird reason it doesn't connect to metamask. Another simple script just to ...
user avatar
0 votes
0 answers
8 views

Truffle test: Error: expected event argument '_ids' to have value 1 but got 1

I wrote an ERC1155 Nft whith this following function: contract Nft is ERC1155{ using Counters for Counters.Counter; Counters.Counter private id; event MintBatch(address indexed _to, ...
user avatar
0 votes
0 answers
18 views

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'eth')

I am following what seems a relatively simple tutorial to create a smartcontract, however, I am getting the above error and I am stumped as to what is causing it Below is my html file <!DOCTYPE ...
user avatar
0 votes
1 answer
16 views

Alchemy - calling eth_getTransactionReceipt - HardhatError: HH110: Invalid JSON-RPC response received

Please see my deploy.js.The code fails at line 23 with await fund.deployed(); const hre = require("hardhat") const { fundConfig } = require("../helper.config"); async function ...
user avatar
0 votes
1 answer
45 views

Getting the address of a contract before its deployed with brownie

While working with the lens protocol contracts I saw that they were able to precompute the address of a contract using hardhat with the following code import { hexlify, keccak256, RLP } from 'ethers/...
user avatar
0 votes
0 answers
11 views

Get correct price value

I am attempting to get the current prices for some tokens from Uniswap and SushiSwap. I am using this function: async getBuyPrice() { const pathToBuy = await this.routerContract.methods....
user avatar
  • 111
0 votes
0 answers
8 views

Error receiving data from uniswap.Division by zero Java Script

Here is my simple code that is looking for a tri-ang arbitrage opportunity: // Loop through each trade and get Price information for (let i = 0; i < fileJsonArrayLimit.length; i++) { console....
user avatar
0 votes
1 answer
21 views

Etherscan sends back garbage values through API for the same query that works on the website

I'm trying to fetch data through the etherscan API from a proxy aave lending pool smart contract. This works absolutely fine for AaveV1 but for AaveV2, it just sends back garbage values (uint min and ...
user avatar
0 votes
0 answers
28 views

How to increase an account nonce on web3js?

i'm running a script using web3js in which one i have my accounts[0] that is running 2 transactions. When i do: await web3.eth.getTransactionCount(accounts[0]) , i receive X (number) as a response. ...
user avatar
0 votes
1 answer
14 views

How to use variables set inside a beforeEach with hardhat testing

describe("func", function () { let owner beforeEach(async function () { const [owner] = await ethers.getSigners() }) it.only("should correctly set the address", ...
user avatar
0 votes
0 answers
23 views

Get pending transaction in Golang?

I know how to get pending transaction, from Mempool that is, in JS/NodeJs. I want to do the same thing in Golang, though. How to do it? I haven't found any example.
user avatar
  • 1
0 votes
1 answer
24 views

hardhat testing JavaScript got data from array via [ index ] instead of ( index )

in javascript and in solidity if you need to get gata from array index you can write like that let data = array[ index ] but in the testing phase, i saw javascript got data from array like this array (...
user avatar
0 votes
1 answer
12 views

How to wait block confirmations after transfer

fundMe = await ethers.getContract("FundMe", deployer); it("Check fund and withdraw", async function () { await fundMe.fund({ value: sendValue }); await ...
user avatar
0 votes
0 answers
12 views

Why isn't copyto clipboard function working in metamask mobile browser?

navigator.clipboard.writeText(walletAddress); I used this piece of code to copy to clipboard. It is working properly in desktop browser but not in metamask mobile browser? Is there any alternative ...
user avatar
0 votes
1 answer
37 views

The constructor of function 01-deploy-fund-me.js expect 1 argument but got 42

I am at moment 10:59:00 in the tutorial https://www.youtube.com/watch?v=gyMwXuJrbJQ&list=PLMippBqdcHKavY7WqPnoWbRgkgjn0dq9v&index=27&t=297s&ab_channel=freeCodeCamp.org, I try tu run: ...
user avatar
  • 1
1 vote
1 answer
11 views

Passing an error testing suite in contract

hello how do i make a proper testing suite for error? the contract has this modifier for freeMint() fn modifier protectTier(uint256 _level) { require( _level != privateTier, &...
user avatar
1 vote
1 answer
37 views

Difference between const ethers and const { ethers }

can anybody explain what is the difference between const ethers = require("hardhat"); and const { ethers } = require("hardhat");
user avatar
0 votes
2 answers
18 views

How to get the actual workflow (event)

I've got several enums in solidity : enum WorkflowStatus { RegisteringVoters, ProposalsRegistrationStarted, ProposalsRegistrationEnded, VotingSessionStarted, ...
user avatar
  • 11
0 votes
1 answer
15 views

Chain tests in mocha framework with smart contract testing

I am doing smart contract testing with hardat and mocha framework. Suppose I have two following it blocks testing contract A. it('test1', () => { contractA.updateValue(val); // some other ...
user avatar
  • 163
-1 votes
3 answers
73 views

how to test if array contains any value? [duplicate]

this is my smart contract // SPDX-License-Identifier: MIT pragma solidity ^0.8.8; contract SimpleStorage { uint256 public favoriteNumber; struct People { uint256 favoriteNumber; ...
user avatar
0 votes
0 answers
25 views

convert a hex string to bytes32[] using web3js

I have a string thats 64 characters long and I need to convert it into a bytes32[] to be passed into a contract method call. How can I do it using web3js? I tried using hexToBytes in the utils package ...
user avatar
0 votes
0 answers
28 views

Authorization using Metamask - Signing and validating - can you find any weaknesses in this approach?

I would like to develop a webapp (frontend: ReactJs, backend: Spring Boot) in which users can interact without logging in in the traditional sense of the word (username + password) but instead using ...
user avatar
0 votes
0 answers
7 views

Best way to update addresses in web3js subscription

I am using web3js to subscribe to logs for specific contracts. This list of contracts is pulled from a database. However, every once in a while this list will be updated. I am not sure of the best way ...
user avatar
0 votes
0 answers
9 views

Simulate txn using script

Is there any way to simulate the transaction programmatically? I know we can do it via Gnosis Safe UI but interested in doing it programatically.
user avatar
0 votes
0 answers
13 views

Writing special character inside the addParam when writing task function. ex: addParam("my:example")

Is there any way to write ":" or "_" or "-" in function "addParam()" inside "task". For example .addParam("my:example") or .addParam("...
user avatar
0 votes
0 answers
72 views

Invalid BigNumber value error. Arguments="value", value=undefined

so I'm getting this error on my deploy script. I have seen the other questions and have tried their solutions but they are not working for me. So this is my deploy script const { netowrk, network, ...
user avatar
0 votes
1 answer
29 views

How to get transaction link into etherumscan to my website using etherumscan API

please help me with my problem : I am creating a website with blockchain. Now I need to get my transaction results into etherscan.io to my website with a link for this transaction and all these by ...
user avatar
0 votes
1 answer
16 views

How to read a mapping through devtools

I'm working on Ethernaut challenge lvl 1 follow the link or scroll below for the smartcontract code. I check my addresse in the "contributions" mapping, I add some eth, and I recheck. what ...
user avatar
  • 1
0 votes
0 answers
23 views

how to figure out IERC20 token address from javascript

I would like to send some IERC20 tokens from metamask for contract I link an HTML button to following javascript function const placeFunds = async (side, e) => { e.preventDefault(); await ...
user avatar
  • 101
0 votes
1 answer
21 views

Testing a SmatContract on Ropsten - The transaction is "Success" but I didn't get token in my wallet

I'm trying to take my first steps in the blockchain, and sometimes I stuck with some very weird issue (for me), this is one of them. I've deployed a very simple SmallContract that inherit from @...
user avatar
0 votes
0 answers
9 views

Solidity event doesn't include args

I'm emitting an event from a Market.sol contract with three indexed args but they aren't showing up in my frontend after calling the contract function. Contract code: event MarketTokenEvent ( ...
user avatar
0 votes
0 answers
17 views

fetch the event data in the console

please what should I put inside the console.log() to fetch the 2 returned addresses of the event(args[0], args[1])? and thank you! const filter = { address: '0xbc4...', topics: [ ...
user avatar
  • 3
0 votes
1 answer
60 views

Call to contract doesn't work when sending a merkle proof (using ethers & JS)

I basically have a contract whose mint function looks like this: function mint(uint256 _mintAmount, bytes32[] calldata merkleProof) public payable isValidMerkleProof(merkleProof, ...
user avatar
  • 1
0 votes
0 answers
11 views

My test doesn't pass but expectation return correct value (truffle)

I have a voting Contract which contains 3 functions , 1 Struct, 1 mapping, 1 modifier and I use Ownable from openzeppelin : struct Voter { bool isRegistered; bool hasVoted; ...
user avatar
  • 11
0 votes
1 answer
128 views

UNIT Test Error: No Contract deployed with name Raffle

This is the section of my unit testing... I've been working on this problem for the last few hours. I couldn't, however... I think the error is in const { deployer } = await getNamedAccounts() this ...
user avatar
0 votes
1 answer
263 views

Error: chainId address mismatch

i'm trying to deploy a simple smart contract with node-js on a ganache-GUI but i keep getting this Error: chainId address mismatch; may chainId is the same as the networkId in the ganache app witch is ...
user avatar
0 votes
1 answer
50 views

Does Smart Contract pay gas fees in this case?

Lets say there are 2 smart contracts A and B. A contracts approves B contract for some allowance, as B has approval to withdraw from A contract. Lets say contract B withdraw some X coins from A ...
user avatar
0 votes
1 answer
49 views

How can I batch execute multiple Gnosis Safe transactions via js/ts?

I've been using the typescript npm libs gnosis.pm/safe-core-sdk and @gnosis.pm/safe-service-client to execute Gnosis Safe transactions one-by-one. Recently I've noticed in the web UI that one can ...
user avatar
0 votes
1 answer
57 views

Flashloan Arbitrage error 'SafeERC20: low-level call failed'

So I finally am almost finished with my flashloan arbitrage how ever when I run it I get this error 'SafeERC20: low-level call failed' here is my contract code // SPDX-License-Identifier: MIT pragma ...
user avatar
  • 107
0 votes
1 answer
184 views

web3modal error during Wallet Connect function for web3 in javascript

i try to follow github web3modal guide to con figure my wallet connect in javascript . pls help me on this issue. appreciate https://github.com/Web3Modal/web3modal-vanilla-js-example html <...
user avatar
  • 17
0 votes
0 answers
18 views

Transfer multiple tokens with one confirmation in Smart chain

I want to send several tokens at the same time with a transaction in Smart Chain with the web3 DApps Trust Wallet
user avatar
  • 1

1
2 3 4 5
23