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
1 answer
26 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
9 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
0 votes
1 answer
17 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
15 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
21 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
14 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
29 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
31 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
13 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
0 votes
0 answers
17 views

erc721 was created but does not appear in wallet

I am attempting to create a Factory which mints NFTs and while it seems that my transaction has completed, metamask does not register the NFT. See the screenshots of my app: https://imgur.com/a/...
user avatar
0 votes
0 answers
33 views

require ERC20 transferFrom

I have a deposit function where I want to require that the transferFrom worked and if not it should be reverted with "Transaction declined by user". function deposit(uint256 _amount) ...
user avatar
0 votes
1 answer
20 views

How to Call Smart Contract Function After Migrations

In my 2_deploy_contracts.js file, I can successfully migrate all my contracts using the command truffle migrate. My problem is that after migration, I want to call a function from contract D and pass ...
user avatar
  • 117
0 votes
0 answers
20 views

HardhatError: HH700: Artifact for contract "Greeter" not found

Following the instructions on Hardhat (https://hardhat.org/getting-started#installation) to deploy a smart contract on VScode. Previously created a Hardhat project where I changed the name from ...
user avatar
0 votes
0 answers
21 views

The block number when you await solidity call in javascript

If I await two solidity calls in javascript sequentially: await contract.A().call(); await contract.B().call(); does it mean they will guarantee to happen in two different blocks? Thanks. EDIT: both ...
user avatar
0 votes
0 answers
28 views

How to get solidity custom errors on dApp?

I would like to get the custom error code from my dApp, however, I can't get it when the smart contract is using revert. However, I can get the error reason when the solidity contract use required. Ex....
user avatar
0 votes
0 answers
13 views

Help Please ERROR in ./src/App.js 6:0-46Modulenotfound:Error:Can'tresolve'./wallet/Connector'in'/Users/user/Desktop/esample/react-minting-website/src'

Hi Please i am developing an nft project using web.js , web3React Hook , with Web3 Connector. @web3-react/injected-connector and then try compile my project with npm start i can't figure why i get ...
user avatar
0 votes
2 answers
73 views

[SOLVED]PatrickCollins Solidity Course 2022 - Lesson 7: 11:20:38 -> TypeError: ethers.getContract is not a function

AssertionError: Expected transaction to be reverted with You need to spend more ETH!, but other exception was thrown: Error: Transaction reverted: function returned an unexpected amount of data I was ...
user avatar
0 votes
1 answer
7 views

How can I add an element to the array at an index of my choosing while altering the array size accordingly?

I have an array that looks something like this: uint256[] array = [1,2,3,4,5,6,7,8]; I am familiar with how to add an element to an array using array.push(100); which would make the array look like ...
user avatar
  • 107
0 votes
1 answer
32 views

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray Ethers.js encrypt function error

const jsonKey = new ethers.Wallet(process.env.PRIVATE_KEY); const encrypTkey = jsonKey.encrypt(process.env.PASSWORD); Code is throwing error saying **TypeError [ERR_INVALID_ARG_TYPE]: The "data&...
user avatar
  • 21
0 votes
1 answer
5 views

require("fs-extra") not working even after adding/installing fs-extra (yarn add fs-extra)

I have installed "fs-extra" using yarn add fs-extra and then importing fs-extra const fs = require("fs-extra"); fs.readFileSync("./Abc.bin"); is not working
user avatar
  • 21
0 votes
0 answers
17 views

How to send a "Address" from Javascript to Solidity Contract

Hi i have created frontend and working with web3js. Now what i am trying to do is: Updating the data in the contract. Add the address in the contract (So here in form i am asking the user to put the ...
user avatar
0 votes
2 answers
44 views

Help Please Solidity version pragma statement in these files doesn't match the configured compilers in your config*contracts/hello-world.sol ("0.8.4")

Hi Please am unable to figure out why i get this error while trying to compile my interact.js script using npx hardhat run scripts/interact.js --network ropsten on vs code : Error HH606: The project ...
user avatar
0 votes
0 answers
16 views

TypeError: Cannot read properties of undefined (reading 'toNumber')

I'm receiving type error please help Test.js code const { expect } = require("chai"); const toWei = (num) => ethers.utils.parseEther(num.toString()) const fromWei = (num) => ethers....
user avatar
0 votes
2 answers
18 views

TypeError: transactionResponse.wait is not a function ethers.js

I have a contract object. on top of it I am calling store() function. const transactionResponse = contract.store("4"); const txReceipt = transactionResponse.wait(1); Getting Below Error: ...
user avatar
  • 21
1 vote
2 answers
30 views

window is not defined when used with next.js

I am trying to write a React-next.js app. I have the following file that exports an instance of Web3 by passing in window.ethereum to the constructor. import Web3 from 'web3'; const web3 = new Web3(...
user avatar
0 votes
1 answer
12 views

Not able to use "connect()" method to sign transactions with different account in HARDHAT

I am making a smart contract so that I can send messages and other addresses can also send messages in that contract. So the message, block.timestamp and the sender's address will be stored in an &...
user avatar
0 votes
0 answers
17 views

how to call this sc function throught ether js and define pid amount while calling it

function mintpid(address _to, uint256 _mintAmount, uint256 _pid) public payable { TokenInfo storage tokens = AllowedCrypto[_pid]; IERC20 paytoken; paytoken = tokens.paytoken; ...
user avatar
  • 1
1 vote
2 answers
35 views

Is there a way to retrieve hexadecimal methodID from function ABI?

I am making a simple decompiler but i'm struggling with encoding my functions to signatures. For instance I have function "transfer(address recipient, uint256 amount)" which I want to encode ...
user avatar
  • 11
0 votes
0 answers
31 views

Gas estimation reverts

I am quite new to blockchain programming and am trying to estimate the gas cost of calling a function from a smart contract. I am using Web3 js and the Kovan network through an Infura node. What am I ...
user avatar
1 vote
1 answer
20 views

How to write the javascript test code on whether a smart contract function is successfully executed or not?

I wrote a lottery smart contract and gonna to test an "enter" functionality of the smart contract. The below code is javascript test code for the "enter" function of the smart ...
user avatar
0 votes
2 answers
43 views

console.log not working in scripts/deploy.js and in smart_contract in HardHat

console.log not working in scripts/deploy.js and contracts/WavePortal.sol in Hardhat. When I run the command npx hardhat run scripts/deploy.js it only shows "" Compiled 1 Solidity file ...
user avatar
0 votes
1 answer
14 views

Error: /api/v0/object has been removed, use /api/v0/dag instead

I am using ipfs for image upload in my form it was working fine but from few days back it's giving me the error. the following is my code. uploaddoc: function(){ const reader = new FileReader(); ...
user avatar
0 votes
0 answers
7 views

I am trying to run my project on rinkeby test net and trying to use it as a default provider but whenever i try my project id is missing in rpc url

this is the code. project id is missing after the https://rinkeby.infura.io/v3/. i am new to this technology. i hope anyone to help me out. const sdk =new ThirdwebSDK( new ethers.Wallet( process.env....
user avatar
0 votes
0 answers
18 views

Problem with eth.sendRawTransaction in geth console

Im trying to use the following code with nodejs to create a raw transaction: const ethTx = require('ethereumjs-tx').Transaction; const txParams = { nonce: '0x0', gasPrice: '0x3B9ACA00', ...
user avatar
  • 1
-1 votes
0 answers
10 views

I am trying to build a marketplace and I wanna get all the assets of the suer so I can work with them and make sales etc

As said in the title I wanna build a marketplace. I will need to get all the assets. Yesterday I was visting some marketplaces and they were able to make a signature request that allowed them to get ...
user avatar
  • 1
0 votes
1 answer
36 views

How to get value from key in a map, where the key is an adress?

Im a bit struggling with all the datatypes in solidity so i hope someone can help me out. I created a map where i can store a specific adress + value(number) trough a public function. Now i am writing ...
user avatar
  • 1
0 votes
1 answer
20 views

Ethereum metamask payment on website not working

im trying to integrate a metamask ethereum payment button on my website but nothing happens when the button is pressed, any help with this? This is the script i got window.addEventListener('load', ...
user avatar
0 votes
0 answers
17 views

How to print current Metamask account balance in console.log/HTML

I am trying to print the balance of the current Metamask account in my localhost web app, but in the console log it says Uncaught (in promise) TypeError: Cannot read properties of undefined (...
user avatar
0 votes
1 answer
27 views

error:Expected private key to be an Uint8Array with length 32

var Tx= require('ethereumjs-tx').Transaction const Web3=require('web3') const web3= new Web3('HTTP://127.0.0.1:7545') const account1='0x06e61BDdC2a45A7523C62c0DcC4E15D842BBa9BA' const account2='...
user avatar
0 votes
1 answer
41 views

Gnosis Transaction Failing On Polygon w/ "Transaction Underpriced" error

I've been trying to get a transaction to execute on Polygon but it's been failing with the following error: reason: 'processing response error', code: 'SERVER_ERROR', body: '{"jsonrpc":...
user avatar
  • 11
0 votes
2 answers
80 views

TypeError: Cannot read property 'length' of undefined - While deploying using hardhat

I am getting the following error while trying to deploy a Mock contract on the hardhat development chain. I am following: Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – ...
user avatar
1 vote
1 answer
74 views

Ethers.js signing a message to validate EOA is who they say they are

When you use dApps that have read/write functions that require auth, sometimes the dApp will have you sign a message to prove you are the EOA you claim to be. OpenSea does this when you want to modify ...
user avatar
0 votes
0 answers
16 views

How To Read All Specific Data

I wrote a smart contract that saves data to the blockchain and is able to return read that data when you enter a specific id. The problem is I would also like to save the data by date but when I enter ...
user avatar
0 votes
0 answers
21 views

Requesting code review for simple EIP712 validation scheme

Hello, I am working on a simple EIP712 whitelist member wallet registration/validation scheme. The nutshell goes (sign typed data -> pass to chain -> extract signing address -> compare to ...
user avatar
0 votes
0 answers
20 views

How to integrated javascript /web 3 into wordpress?

hello everyone i use wordpress for website developement and right now i developping a web3 app and i would to know how can i integrated the script to wordpress element (button etc ). Should i develop ...
user avatar
  • 5
0 votes
1 answer
10 views

im trying to call the bid function on my bidding contract from an outside contract but im getting "undeclared identifier" error... please help

Smart contract code: interface IERC721 { function safeTransferFrom( address from, address to, uint tokenId ) external; function transferFrom( address, ...
user avatar
  • 39
0 votes
1 answer
25 views

Unable to deposit into AAVEv3 via web3

I'm attempting to deposit WMATIC on the Polygon chain into AAVEv3, but I'm getting a revert. I'm running a forked version of Polygon mainnet locally with ganache. I'm using the first account provided ...
user avatar
0 votes
0 answers
38 views

Uncaught (in promise) TypeError: myFunction.watch is not a function

I'm trying to develop my first DAPP based on this tutorial (https://livebook.manning.com/book/building-ethereum-dapps/chapter-12/) and I'm encountering some errors in the javascript part. In ...
user avatar
0 votes
0 answers
44 views

Getting "Expected private key to be an Uint8Array with length 32" when running a transfer function on ropsten testnet through my terminal

i am trying to send a transaction but it throws an error. MY CODE: var Tx = require('ethereumjs-tx').Transaction const Web3 = require('web3') const web3 = new Web3('https://ropsten.infura.io/v3/...
user avatar
1 vote
0 answers
22 views

How to estimate gas Price using Ethers.js prior to sending the transaction?

I am trying to estimate gas using ethers. I have tried using await this.signer.getGasPrice() but this doesn't take into account my contract's function and my address.I saw that on ethers's ...
user avatar

1
2 3 4 5
23