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
2answers
279 views

Trying to connect front-end application with smart contract

I am creating a simple registration and login forms in React.js and connecting it with smart contract in order to use it to store the data from the front and to the blockchain is there any method or ...
0
votes
2answers
42 views

Call and Save Returned Value from Method in React

I am trying to call a method from my smart contract (myMethod) and save the result (result) as a state (this.state.result) in react. However, my state is not being updated to the result. My code is ...
1
vote
1answer
2k views

How to disconnect MetaMask wallet using Web3modal

I am using metamask with kovan to connect to the wallet import React, { useState, useEffect} from 'react'; import Web3 from "web3"; import Web3Modal from "web3modal"; import Navbar from './components/...
0
votes
1answer
76 views

Accessing array within struct in a mapping using web3.js

I have created a struct patient as follows, and a mapping of uint->patient. struct patient { uint pId; string name; string phone; address payable owner; uint numRecords; uint[]...
1
vote
1answer
203 views

DApp examples containing complete source code

can someone provide me some high quality ethereum dapp codebase examples? This should comprise of not only the smart contract codebase but also the app codebase , complete with the front end UI (...
1
vote
0answers
72 views

Contract not returning error to React Interface

I have a contract which I've tested with Mocha and Remix and is working just fine. The problem is when I'm running it with my React Interface. When I call a function in my solidity contract that ...
2
votes
1answer
219 views

Drizzle cacheSend outputs “cacheSend is not a function” error, but the tx works when using send

I'm using Drizzle and react-hooks in my new open source project, but cacheSend outputs always "cacheSend is not a function" This line of code with send works as expected const stackId = contract....
0
votes
1answer
25 views

Smart contract function not returning expected output

I'm quite new at this and I'm learning both Solidity, Javascript and React to play around with smart contracts. My contract ran well in Remix and in a local test net. I ran a bunch of tests using ...
0
votes
0answers
16 views

How do I get a structure of a mapping inside a structure?

So. I started using too many mappings. Now I'm not sure how to get the information on the front: struct Demand{ uint remuneration; uint delay; uint deadline; string description; ...
0
votes
1answer
20 views

solidity function works perfectly in remix but in react application it is not executing in the same way

in Remix i execute it and it works as i expecting and when i check the value from other function it returns the expecting value function makeadmin(string memory cityN, address adminAdress, string ...
2
votes
0answers
168 views

No “from” address specified in neither the given options, nor the default options [closed]

Uncaught (in promise) Error: No "from" address specified in neither the given options, nor the default options. at Object._executeMethod (index.js?2fac3b5:942) at CampaignNew._callee$ (new.js?...
0
votes
0answers
28 views

Error while unboxing trufle react

gyp ERR! build error gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1 gyp ERR! stack at ChildProcess....
0
votes
1answer
32 views

Web3 call should return different result based on time passed

I am experiencing a weird issue. I am building a DApp where I want the new season of the game to start every 5 minutes (for testing purposes). However, web3 call returns old data, seems that it cached ...
3
votes
1answer
654 views

Refresh page upon MetaMask Confirmation. Web3js & React()

I would like to reload the React Web3 wallet's page upon MetaMask Confirmation. Meaning when the ERC-20 token send transaction is confirmed, the page should reload or state should update to display ...
0
votes
2answers
14 views

Calling Contract Function

I am trying to call a function from my back-end to my front-end. I know that my contract is deploying, however, I don't think my function is not being called correctly. My code is provided below. Does ...
0
votes
2answers
74 views

Deploying a Contract vs. Instantiating a Contract

I apologize for the very basic question but I am a little confused. What is the difference between deploying a contract and instantiating a contract?
0
votes
1answer
23 views

Deploying Contract with React

I am trying to deploy a contract on react. But I can't seem to pull it off :( This is my code: this.myContract.deploy({ data:[big boi bytecode here], arguments: ['name', '...
0
votes
1answer
159 views

Unhandled Rejection (TypeError): this.provider[(intermediate value)(intermediate value)(intermediate value)] is not a function

I am receiving the error: "Unhandled Rejection (TypeError): this.provider[(intermediate value)(intermediate value)(intermediate value)] is not a function". However, I have not used "this.provider" in ...
0
votes
0answers
26 views

Truffle Object Keeps Changing to Undefined When I Try To Play With Data With React

The question is in the title. I have a React Component that displays the appropriate data when I do it in a very specific way, but breaks when I try to play with the data. state = { dataKey: "1",...
0
votes
2answers
29 views

mapp values do not upadte when calling other functions after populating the map

I am using react as my front end to call functions from smart contract . this is the front end where i call the functions. However, after calling the first function which populates the map I then ...
1
vote
1answer
139 views

TypeError: tests is not a function Error in Truffle

I am following an online tutorial, doing almost exactly like the instructor. I have the following error every time I try to run 'truffle test' my truffle-config file: module.exports = { // See &...
1
vote
0answers
27 views

How to use Web3Js to sign a message in a react native mobile app [closed]

I am very new to Ethereum. I have requirement to sign the app using Web3JS in my React native mobile App. I used this link to get web3js working properly. But I am not sure how to connect to wallet ...
1
vote
1answer
178 views

Unable to get metamask account with web3

I have been following a tutorial on creating solidity contracts. I am unable to get the list of account numbers on my metamask wallet when I use my script below. async componentWillMount(){ ...
1
vote
1answer
45 views

Transaction working in remix but not errored from dapp

I have a master contract which deploys instances of other contracts. pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; contract DataEntityContract { DataEntity DE; constructor(...
1
vote
0answers
46 views

What are the differences between Drizzle and the Truffle React box?

Truffle has many "boxes", two of which are: truffle unbox react And: truffle unbox drizzle They both seem to be focused on frontend development. Other than Drizzle being based on a Redux store, ...
3
votes
1answer
295 views

How to mock an ethers provider while testing with jest?

In the real app, I'm using the web3-react hook to inject the provider, etc. How do I best mock that/replicate that in a Jest Typescript environment?
0
votes
1answer
415 views

How to create account using mnemonic words or private key in web3js and call contracts using that account

I have a simple React Project with web3@1.2.4 installed and I want to call a contract's method like this: await maincontract.methods.CurrentMethod("arguments").send({ from: accounts[0]/*my account ...
1
vote
0answers
18 views

Event listener doesn't trigger setState in web3js

I have the following function that does something with a smart contract, and then should manipulate the dapp state when the event has been received. However, it doesn't set the state of the dapp, and ...
1
vote
1answer
155 views

Error: Invalid number of parameters for “Method”. Got 3 expected 2!

I have React app that executes a Smart Contract payable function at some point. The call is below: try { await contract.methods .post( this.state.param1, `${this.state.param2}`, ...
1
vote
1answer
39 views

Watching for events

How come sometimes events show up on block explorers in hex and sometimes to you can see the actual string name of the event in the logs. I ask because my event watchers on my front end only pick up ...
0
votes
1answer
819 views

npm ERR! code ENOENT npm ERR! syscall spawn git

I use the command npx truffle unbox react to develop a dapp but I get these errors below in my console. Can anybody help me? I really don't know how can I solve them.
1
vote
0answers
259 views

Help me fix Error: No “from” address specified in neither the given options, nor the default options. I'm use MetaMask

file web3.js import Web3 from 'web3'; const web3 = new Web3(window.web3.currentProvider); export default web3; file image.js import web3 from './web3'; const address = '...
1
vote
0answers
19 views

Any idea how to add new contracts into drizzle react app using the address?

I have a react app which creates new contracts. lets say A creates B. I have the addresses of the newly created contracts of B. How do i add the newly created contracts of B using its address to ...
0
votes
1answer
207 views

Display matrix in React

I am trying to return a matrix in React that I get from a contract function. This is the function that resonate the matrix: int[][] public publicData; function handleAddData(int[] memory ...
0
votes
1answer
45 views

How do I fix it? To be able to send eth from smartcontract to the address

Frontend class App extends React.Component { state = { address: '', } async componentDidMount() { await window.ethereum.enable() this.w3 = new Web3(window.ethereum) const ...
1
vote
1answer
48 views

How can I add new contracts generated from a factory to my drizzle-react app?

I have a Factory contract which creates new contracts. How do I get the new contract into my drizzle-react web app? I am using to send the transaction to create a new contract but I don't know how ...
0
votes
0answers
37 views

What do I have to do to call this events to be display on the web page?

How do I call showLottery to display on my webpage? Front-End class App extends React.Component { state = { address: '', lottery: '', events: '', } async componentDidMount() { ...
0
votes
0answers
84 views

getPastEvents undefined(please help)

I had asked this question before. I looked carefully at the exchange section, which I advised, and I think there is no problem with the exchange section. At least in my opinion there is no problem and ...
1
vote
1answer
36 views

Creating a contract instance

Is it generally better to define a contract instance once, then pass it through your components like... class Parent extends React.Component{ constructor(props){ super(props); ...
0
votes
1answer
38 views

TypeError: market.FileViewed is not a function while trying to watch event

I want to watch for fileViewed event and it throws TypeError: market.FileViewed is not a function in marketplace.FileViewed{ ^ My solidity contract: pragma solidity ^0.5.0; contract ...
0
votes
1answer
160 views

“drizzle-react-components” import Error for “LoadingContainer”

I am trying to import import { LoadingContainer } from 'drizzle-react-components' Which I succfully installed with npm install drizzle-react-components@1.3.0 It was installed inside the directory ...
1
vote
0answers
20 views

How can I specify a date picker in one of the fields in my ContractForm React component?

I'm using the ContractForm React component available in the drizzle-react-component library. It's super nice and easy to setup and use, but I am dealing with a date in one of the fields (which is ...
1
vote
4answers
1k views

Why web3.eth.getAccounts().then(console.log) return empty array?

It's really weird that I got empty array after I tried to web3.eth.getAccounts().then(console.log);and I also got a warning which is ./node_modules/web3-eth-accounts/src/scrypt.js Critical dependency: ...
0
votes
1answer
67 views

Contract with multiple signing keys

How things work I have a Factory contract, FContract. FContract can be called by a user as many times as they want, creating instances of, let's call it, contractA. Thus, they're able to own as many ...
0
votes
1answer
248 views

Web3-core-helpers error: Uncaught (in promise) Error: Provided address “undefined” is invalid,

When I launch the app with with react.. this error occur when my exchange contract is loaded.. Here is the code i wrote to talk to the blockchain: export const loadBalances = async (dispatch, web3, ...
1
vote
1answer
3k views

gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1

I used the command truffle unbox react to build a dapp. It is just the initial step of my dapp development. However, it sucks. It continually pops up gyp ERR! build error gyp ERR! stack Error: `C:\...
0
votes
0answers
66 views

Payable function not working properly

Hi everyone hope I will be clear enough with the explanation because I couldn't find a proper solution. I am just trying to checkout an item with my buy function but it seems like I am stuck.Here is ...
1
vote
1answer
247 views

Both web3.eth.accounts.create() and web3.eth.personal.newAccount() not working

I'm making a dApp on reactjs. I wanted to create a new account and have done it trying 2 methods this.web3.eth.personal.newAccount() this.web3.eth.accounts.create() I have attached the code below(...
1
vote
1answer
389 views

getAccounts in web3 js undefined

I am working on dapp with web3js 1.0.0.37-beta with reactjs. I got blank in web3.eth.getAccounts. Following is my code App.js import React, {Component} from 'react'; import '../node_modules/...
0
votes
1answer
484 views

Code:const web3 = new Web3(window.web3.currentProvider) Error: window.web3 is undefined

I am going to connect my contract with the website.However,there was something wrong with the web3? I'm not sure. import Web3 from "web3"; const web3 = new Web3(window.web3.currentProvider); const ...