Questions tagged [react]

React (also known as React.js or ReactJS) is a JavaScript library for building user interfaces. It uses a declarative paradigm and aims to be both efficient and flexible.

Filter by
Sorted by
Tagged with
0
votes
1answer
17 views

setState in not calling after event triggered in ethers.js

I have a little portfolio dApp that mints NFTs. After a successful mint, I want the UI to display the tokenId of the minted NFT. I'm minting successfully and the event is being triggered - {tokenId} ...
0
votes
0answers
12 views

How to make static React site and put it to IPFS

I am using site build with Create React App and it all works fine when I run it on server. What I would like is to put it to IPFS and for that it needs to be a "generated static website" (no ...
0
votes
0answers
31 views

React - web3.js - Unable to read revert reason

Working on a web3 project with React and a contract that's deployed on the Rinkeby Testnet. I am intentionally sending requests that won't succeed to try and determine how capture the revert messages ...
0
votes
0answers
21 views

How to sign with owner address and verify signature comes from owner?

I’m trying to sign an address with my address as the owner of a contract to send that signature in a method of my contract. Then have my contract to verify that the signature comes from my address. ...
0
votes
0answers
24 views

Reject tx on component re-render

I am making a webapp using react and ethers.js that works with metamask. If I call MyContract.MyFunc(xyz, function(error, result){ }); user will see a metamask popup. My code will get a response only ...
1
vote
1answer
50 views

Sending Ethereum to a function without parameters using Ethersjs

I'm trying to call a function with no parameters and send Ether to it. I'm using React, Hardhat, and Ethersjs. The smart contract looks like this. pragma solidity ^0.7.6; contract EtherCoinFlip { ...
1
vote
0answers
113 views

How to disconnect metamask wallet from a dapp using web3?

I tried connecting metamask wallet with web3.js, and it got succeeded. const handleClick = async () => { try { // Get network provider and web3 instance. const web3 = await GetWeb3()...
0
votes
0answers
22 views

Ethers.js web3 - Convert token value into Eth

I am using ethersjs on my react webapp to get the number of one ERC-20 token and others informations after a metamask connection. I would like also to convert that tokens balance userBalance into its ...
1
vote
1answer
144 views

Can't send Ether to smart contract using Ethers.js

I'm using Ethers.js Hardhat, & React. Whenever I try to send Ethereum to the smart contract, I get an error. I've tried using etherjs's ether.util to convert it but still get errors. The error ...
0
votes
1answer
13 views

How do I take input from an UI and place it into a migrations folder for contract deployment?

Essentially I am in the process of designing an app that allows users to deploy a simple ERC721 smart contract to the web. I am struggling however to find a solution to retrieving user-inputted data ...
0
votes
0answers
40 views

How to display the NFT of my project on React?

I made a project where people can mint my NFT and now I would like to create a webpage on react where the users can see the NFTs that they had minted. Basically, I would like to take the address of ...
0
votes
0answers
28 views

Hook error using Truffle React box (transforming the App.js from Class component to Functional component)

not an expert Solidity/React user here. I got Truffle React box and I am making a website. My example is very easy. I have this Nav element: import React from 'react'; import Nav from './...
0
votes
1answer
17 views

I made the front end first

I'm creating my first app with truffle but I made the front end first... I wanted to replace the client folder with my existing react app but I noticed the App.js file has numerous functions that I ...
0
votes
1answer
34 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
1answer
26 views

In React.js, How can I get return data from smart contract method including event and emit?

I have smart contract server function and that function including emit and event. event TokenMinted( address indexed _recipient, uint256 indexed _tokenId ); function ...
0
votes
1answer
14 views

Trouble sending correct amount of a token with web3

i'm trying to transfer a value of 1 of my erc20 token to my contract. In my front end I am using: tokenContract.methods.approve(contract_addr, 1).send({from: accounts[0]}); In my smart contract I am ...
0
votes
0answers
60 views

How to send tether token in ether wallet using web3

I am gonna send tether token from my wallet address to other wallet address using web3. const Web3 = require('web3'); const web3 = new Web3('https://mainnet.infura.io/v3/projectId'); web3....
0
votes
1answer
17 views

how can i invoke function each 5 minutes using react?

how can i invoke pickVoters() each 5 minutes using react? import React, { Component } from "react"; class Pick extends Component { static async getInitialProps(props) { const { address } = ...
0
votes
0answers
17 views

MetaMask not showing ERC-20 amount in Transaction - Only showing ETH gas fee

Im experimenting with sending my custom ERC-20 token with MetaMask to my contract. Im using react.js for a simple front end. I press a button which creates a transaction from my metamask account for a ...
0
votes
2answers
68 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
1answer
15 views

is there any way to test etherum application using real addresses by Metamask?

I have Ethereum app written using react + web3 and my contract code written using solidity. can I test the app using real addresses [I used Rinkbey network] and my wallet Metamask .
0
votes
1answer
13 views

How to increase the number of test accounts using injected Web3 with Metamask?

I have encountered a problem where I need a large number of accounts. How can I increase the number of accounts from only 1 with injected web3. Remix and Metamask only give 1 account. I require more ...
0
votes
0answers
16 views

hardhat-react resolves to the wrong context for 2 contract instances coming from the same contract

I am using hardhat-deploy (0.7.11) and @symfoni/hardhat-react (0.3.0), trying to deploy 2 separate instances of the same contract in my deploy script like this. module.exports = async ({ ...
0
votes
1answer
45 views

How do I get the latest balance of a token in my wallet after a transaction in ethers?

I'm very new to developing dApps with Ethers JS and recently created a uniswap clone. But I would like to ask if there is any way to update the balance after a transaction is successfully transferred? ...
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
194 views

Enormous suggested fees on metamask after the EIP-1559

We have to react based app that is responsible for connecting with the NFT contract and calling the "mint" function. To call the function, the contract will ask for 0.06ETH, and the amount ...
0
votes
1answer
16 views

How do I set the value of storeData from the React frontend?

Here's my solidity contract: // SPDX-License-Identifier: MIT pragma solidity >=0.4.21 <0.7.0; contract SimpleStorage { uint storedData; function set(uint x) public { storedData = x; }...
0
votes
0answers
6 views

How do I pass an argument to this solidity function from react?

I'm trying to use a form to submit the data, but every time I try to run the code it throws an error. pragma solidity >=0.4.21 <0.7.0; contract SimpleStorage { uint storedData; function ...
1
vote
2answers
49 views

how can i fetch a data from file to function using solidity contract?

imagine that I have a list of voters data and I want to send a file to the function addVotersList to add all the voters by one click rather than sending the data one by one for each voter this is the ...
1
vote
2answers
43 views

Infinite loop using react Drizzle component

This might be the best place to ask this. I'm having an infinite loop issue when fetching my NFT's json URI. My main issue was being able to display my NFT's name on the screen but now i'm getting an ...
0
votes
2answers
40 views

How do I get react to interact with this solidity contract?

Let's say I have this solidity code: uint256 public num; function setNum(uint256 _num) public { num= _num; } How would I create a react form that passes a value to the smart contract and ...
0
votes
1answer
40 views

Call 2 functions from 2 seperate contracts in one transaction

Pretty standard question here I think but as a newbie I am having trouble getting my head around this in a clear way. I am experimenting with a simple forward auction using a couple of contracts and a ...
0
votes
0answers
74 views

Web3Modal "Provider not set or invalid" error when connecting with other providers

Web3Modal is a library that allows you to conveniently connect to different wallets. I can connect using MetaMask on desktop just fine, but when trying anything else (eg, using WalletConnect to ...
0
votes
1answer
236 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
3answers
34 views

Best way to automatically update balances displayed in front end

Im trying to figure out the best way to automatically update balances in front end upon receiving and sending tokens. Ive tried creating an instance of a token in my react app, then creating an event ...
0
votes
1answer
79 views

Connect local React frontend to contract on testnet (e.g Kovan)

I am new to this community and I had a question, in my opinion I think basic, but I have not found much information, see if you can help me. I have been developing smart contracts, both in Remix and ...
0
votes
0answers
16 views

'web3' is not defined no-undef even after importing

I imported web3 but why this annoying error is occurring please help me... i imported like this import Web3 from 'web3' and the error is occurring here this.web3Provider = web3.currentProvider
0
votes
1answer
196 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
105 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
30 views

Reactjs tutorial [closed]

I am following the following tutorial: Reactjs example When I run "npm start" as written in the tutorial, a window pops up and I am getting following error message: ./src/index.js Attempted ...
0
votes
0answers
28 views

How to wait for MetaMask to inject window.ethereum before firing functions?

Im building a practice dapp to get experience under my belt, its a UI for Chainlink functions. I have a useEffect hook that updates the displayed address, eth balance, and text on the login button, it ...
0
votes
0answers
43 views

Error with Truffle React (the contract doesn't have address)

Someone knows something about this error with Truffle React box? Must be my Metamask wallet address but it is already in my truffle-config file. I leave the App.js file here (I didn't make it. It's ...
1
vote
0answers
200 views

[ Web3.js on BSC ]: Returned error: unknown account

Here's the error: index.js:1 Error: Returned error: unknown account I'm getting this error while running this method: nftMintingContract.methods.mint(account, cid).send({from: account}) The ...
0
votes
1answer
32 views

Web3 - handling separation between read-only calls and send requests?

I want to create a simple front-end for my DApp. The DApp fetches values about the smart contract to display on the site. If the reader wants to interact (eg. buy) with the smart contract, I have a '...
0
votes
1answer
435 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
12 views

Is it possible to open metamask's signature request on a different window?

I'm trying to open metamask on a different window popup not the in the same window, is there a way to do it?
0
votes
0answers
13 views

Is it possible to trigger several times "metamask" connection to different wallets?

I'm trying to trigger metamask popup to connect new wallets even if I already connected one by clicking a "Add another wallet" button. I have days trying to replicate the behavior you see in ...
1
vote
1answer
136 views

Can't get info with web3: web3.eth.getAccounts returns undefined

I'm trying to connect to the blockchain via web3 and metamask and the web3.eth.getAccounts() method is returning undefined, however window.ethereum.request({ method: 'eth_requestAccounts' }) returns ...
1
vote
1answer
166 views

How to keep MetaMask connection to the UI persistent with Web3-react?

I am working with web3-react and I cannot figure out how to keep the connection to the MetaMask wallet persistent upon browser refreshes. This is the code: // define the injectedConnectors const ...
0
votes
0answers
62 views

Error in react js:_this2.props.mint is not a function

I am calling a function from my contract in app.js and then I bind it to my dashboard component in order to access it from the TokenDashboard component. The problem is that when i try to access the ...

1
2 3 4 5
7