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
0answers
4 views

How to write headless Puppeteer/Cypress E2E tests for Dapps

I'm trying to write E2E tests for my Dapp in which I also want to interact with the contracts on local/test chains. I've managed to do this with Metamask but the issue is that I'm not able to run it ...
0
votes
1answer
21 views

Hardhat connecting to localhost contract for tasks

I am working on some hardhat tasks to automate the management of a smart contract. Here's a basic task for granting roles require("@nomiclabs/hardhat-web3"); task("grantrole", &...
0
votes
0answers
5 views

Can you call a variable value with web3.js, without writing the function in solidity?

I have used remix and I can see that whenever I create a public variable, it also creates a function for the variable and when you press it, it shows the variable value but, when I want to call a ...
0
votes
1answer
13 views

Unable to upload images to IPFS using ipfs-http-client

I am having an issue with uploading images to IPFS after having switched to ipfs-http-client from ipfs-api. This is what my page code is like at the moment: import ipfs from "../utils/ipfs"; ...
0
votes
0answers
19 views

I want to learn smart contract development, no coding experience, totally new to coding [closed]

I started learning solidity a week ago, I can understand the concepts but my mind goes blank when the coding part comes into sight. I read a few articles which said I should learn fundamentals of ...
0
votes
1answer
19 views

How can I open an URL in Metamask explorer from a mobile navigator website?

How to open the URL of web3 in the Metamask explorer from a href link in that web3?
0
votes
2answers
31 views

Cant pass large uint in react.js (2**256-1) into solidity approve function

I am trying to call a simple approve() to allow my contract to spend my tokens. Trying to make the amount argument = (2**256 - 1) however I am getting the below error message every time. Unhandled ...
0
votes
0answers
9 views

What is meant by new BigNumber() not a base 16 number: 0x[object Promise] Code: BigNumber Error?

I am working on a dapp solution that has this following function in smart contract: function addFood(string memory _name, uint _price, bool _available) public onlyOwner { foods[numberOfFoods].name ...
0
votes
0answers
17 views

About IPFS client add() function

I am digging into ipfs field in order to start a NFT project so that I am working with frontend with ipfs-http-client npm package (npm i ipfs-http-client). My simple test code is like below: const { ...
0
votes
0answers
43 views

How can i export this animation in a svg to upload it as NFT?

I created an animation with p5js and i want to export it as an SVG, so i can upload it. But i don't know how to do that. Can u help me please? I would like to get something like this: https://ipfs.io/...
0
votes
0answers
12 views

How can I input data from frontend to smart contract?

Hello I am new to smart contracts. I am trying to set data from a frontend into a smart contract and retrieve it after. When I am sending the data from the frontend into the smart contract and return ...
0
votes
1answer
84 views

How to store a javascript animation as NFT

I have a generative "art" animation made with the JavaScript p5js library and I would like to upload the output of this perpetual infinite animation on pinata or another ipfs service and ...
0
votes
0answers
9 views

How to extract function from dependent packages and save them locally?

I am writing a small tool in javascript to store something(as for privKey) into ehtereum contract storage area. For security, I want to strip off all dependent packages and extract the functional ...
0
votes
1answer
24 views

ERC-721 testing with JS - ReferenceError: use is not defined [closed]

I am following this tutorial: https://youtu.be/YPbgjPPC1d0 Got stuck at 34:47. This is the code I have written: const Color = artifacts.require('./Color.sol') require('chai') use(require('chai-as-...
0
votes
1answer
20 views

Getting specific values from Web3js getPastEvents

I would like to know how to pull the account value from returnValues: Result {} of this web3.eth.Contract This code logs to the console just fine, but I have scoured documentation on objects and on ...
0
votes
1answer
36 views

MetaMask API - How to detect if token already registered?

I'd like to prevent a user from entering my dapp until they have registered my token with MetaMask. I accomplish this using the code below, which is executed the moment the user is about to enter the ...
0
votes
1answer
63 views

how to get struct data from contract by web3?

I tried to get the data of the struct by its mapping string, but I got undefined in innerhtml and get following result in the html console log: however I can search the data from the Remix ABI, ...
0
votes
1answer
88 views

Unhandled Rejection (TypeError): param.map is not a function

Using Web3to execute transactions, and getting the following error: Unhandled Rejection (TypeError): param.map is not a function Uncaught (in promise) TypeError: param.map is not a function at ...
0
votes
1answer
33 views

How to get first 4 bytes of function signature

I need to get the first 4 bytes of several function signatures, to determine what method I need to use to decode a database of transactions that contain input data. How can I do this in javascript? ...
0
votes
0answers
21 views

uncaught error in js: Invalid number of arguments to Solidity function

I'm the new to web3. I wanna create the system that when I input the string, then I can get the data of the string I saved before. but when I click the button and I want the result displayed, it didn'...
0
votes
1answer
25 views

Number of players is not showing when somebody join on the website

I deployed the contract on BSC testnet and I created the interface: https://melon-lottery-beta-testnet.vercel.app/ (you need metamask to see it). If somebody try to reach the website he see this ...
0
votes
1answer
128 views

Error when trying to divide value after calling getAmountsOut from uniswap router 02

I am having a lot of problems implement a swap via metamask using the uniswap router 02. I am able to call the getAmountsOut function but get an error when trying to do the following: const ...
0
votes
1answer
32 views

Ethers.js transfer event filters

In my dapp I'm building I want to update the contracts' balance of an ERC20 token automatically using the transfer event from the token contract. I have created the contract object using: const ...
0
votes
1answer
37 views

Dealing with "Uncaught (in promise) Error: Provided address [object Promise] is invalid, the capitalization checksum test failed"

I'm, trying to connect a front-end to my smart contract but whenever I call the function from the UI I get this error: Uncaught (in promise) Error: Provided address [object Promise] is invalid, the ...
1
vote
1answer
138 views

Is there any reason why Brave Browser seemingly injects some ethereum related script in the <head> tag sometimes?

Recently, while inspecting the html of a random website, I noticed this weird script at the bottom the <head> tag. I've unminified it for better readability. I opened the same site on another ...
0
votes
0answers
11 views

How to chain calls to Solidity functions to update Javascript/jQuery input

I use Truffle to create a Javascript/jQuery file app.js that is set up to call Solidity functions. I also have a file index.html that contains the HTML for the app. I have a smart contract in Solidity ...
0
votes
1answer
56 views

How to Parse the Data Returned by a Solidity Function

I have the following solidity code, to get the data that has been mapped to an address, function showOrg(address org) external view returns(uint identifier, string memory organization_name, bool ...
0
votes
0answers
20 views

How to capture error using Web3 Callbacks Promises Events

I'm trying to understand how errors are handled by Web3's Callback Promises Events. Below is the PromiEvents definition as given on https://web3js.readthedocs.io/en/v1.4.0/callbacks-promises-events....
0
votes
1answer
101 views

How to connect Dapp to Metamask and interact with smart contract deployed on Ropsten via Remix

I deployed a smart contract via remix to the ropsten testnet and now I want to interact with it via website(dapp). I am creating a auction dapp. The user has to input the amount of ETH he want's to ...
0
votes
0answers
33 views

IPFS is not a constructor

I am using IPFS to upload images however it's not working In the console window it's giving me the following error in Jquery.PersistPlugin.js I am not sure where is this file and how to solve this ...
0
votes
1answer
118 views

Send transaction throw bsc with web3

i'm trying to send a transaction via bsc using WalletConnect and web3 This is the connection code const provider = new WalletConnectProvider({ rpc: { 1: "https://bsc-dataseed.binance....
0
votes
0answers
13 views

Javascript mutates ABI objects

I'm trying to import a contract ABI to my app but when I try to import it using import or require method, JavaScript mutates objects. Please check out this screenshots This is normal ABI log in the ...
0
votes
1answer
33 views

How to deploy after changing network Id in Ganache GUI (Truffle)

I am trying to interact with a simple solidity contract using MetaMask. I can run truffle migrate and run the front-end with no trouble but when I try to interact I get the error: Unhandled Rejection (...
0
votes
0answers
11 views

Unable to get campaign.json and campaignFactory.json

const path = require('path'); const solc = require('solc'); const fs = require('fs-extra'); const buildPath = path.resolve(__dirname, 'build'); fs.removeSync(buildPath); const campaignPath = path....
0
votes
0answers
15 views

AssertionError returns user balance

Smart contract issue I get on windows terminal: checking balances 1) returns user balance Events emitted during test: --------------------------- Token.Transfer( from: <...
0
votes
1answer
90 views

Ethers js deploy contract with balance, payable constructor

I have a smart contract with a payable constructor. I'm trying to figure out the syntax with ethers js how I can deploy the smart contract and send an initial balance with the deployment. const ...
0
votes
3answers
11 views

Is there a must use framework to design dapps that works well with Truffle?

I am trying to develop a dapp that works on a web browser that will also contain a website made in a popular UI framework (let's say angular) rather than building a html/css manually. Right now I'm ...
0
votes
0answers
45 views

How to make transaction via MetaMask, not Web3js?

I am trying the example given here and making it like the below: const transactionParameters = { nonce: '0x00', // ignored by MetaMask gasPrice: '0x09184e72a000', // ...
1
vote
0answers
22 views

Important Question regarding Github repository. Need kind Help!

I am facing some errors during the installation of dependencies. whenever I run npm install the dependencies start downloading however after a few seconds it gives the following error shown in ...
0
votes
1answer
321 views

Calling a method from local hardhat deployment

I'm trying to interact with contracts that are deployed in the local hardhat env through web3 I'm unable to get back the data from the contract, here's the info I have: var list = await contract....
1
vote
0answers
20 views

Webpack can't deal with web3.js

My web app uses web3.js v. 1.4.0 and for module bundling I make use of Webpack v. 5.45.0. // index.js (the entry point of my app) import * as Web3 from 'web3'; An attempt to launch webpack results in ...
1
vote
1answer
31 views

Web3 returning Promise instead of value? [closed]

I have a simple async/await function get the total supply of my contract. It returns a promise, however. async function supply() { const supply = await contract.methods.totalSupply().call() ...
0
votes
1answer
215 views

How to create a dapp that verifies NFT ownership?

I'm trying to create a simple react app that will allow the user to enter a token ID and Ethereum address, then it will confirm if that address has it. Do I need Solidity to do this? I'm aware of ...
0
votes
0answers
13 views

How to read view function with no transaction? And what is wrong with my code?

I know I am doing something wrong here but cannot for the life of me see what the issue is. Everything I see in the docs points me to assume I'm doing this all right. I'm definitely doing something ...
0
votes
0answers
94 views

MetaMask - RPC Error: Error: [ethjs-query] while formatting outputs from RPC

I am very new to Ethereum smart contract solidity programming. Currently, I have been facing this issue when I try to pass a variable from my Node.js servlet to the smart contract I deployed using ...
0
votes
1answer
27 views

Metamask retrieve next transaction nonce

I am testing a smart contract that requires a nonce for every single method I invoke. My idea was to use the Metasmask transaction nonce of the connected account, but I do not know how to extract the ...
0
votes
0answers
89 views

How to send transaction from metamask to another metamask account using smart contract method

I have two accounts in metamask imported from ganache and well conected , when I called the function buy, web3 always used my default account in the metamask, I want to send transaction from my ...
0
votes
1answer
100 views

Failed transaction uses up all the gas instead of a small part needed to revert the execution

On BSC, usually when your transaction to a contract fails such a tx uses about 30k gas when you do it through a wallet. But when a transaction made with an ethers.js script fails, it uses all the gas ...
1
vote
1answer
29 views

Moralis.Cloud.beforeSave not triggered when adding tables through a sync job (plugin)

I ran into this a while back and it was doing my head in. Could it be that a ‘Moralis.Cloud.beforeSave’ in Cloud Functions is not triggered when adding tables through a sync job (plugin)? When I run ...
0
votes
1answer
280 views

Uniswap/PancakeSwap function swapExactTokensForETH produce error

I have code to call pancakeswap/uniswap router function to swap token. In my code, I have no problem calling swapExactETHforTokens when swapping WBNB to BUSD in BSC. my problem came when I tried ...

1
2 3 4 5
18