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
3k views

JSON RPC call from javascript with axios

I would like to call a geth method via JSON RPC from within a react component. I tried this but I always get the Error: 405 (Method Not Allowed) Here is my code: try { const response = await ...
0
votes
1answer
209 views

How would you generate this transaction hash?

let contract = await instance.mint( accounts, usersInput.url, usersInput.metadata[0], usersInput.metadata[1], usersInput.metadata[2], { ...
0
votes
1answer
247 views

How to sign on ethereum a pdf like on this video? [closed]

How to sign on ethereum a pdf like on this video? I'm asking specifically about what happens at 00:40 where you have a user uploading the file and then it get stored and cryptographic signature is ...
0
votes
1answer
328 views

“The returned value is not a convertible string” (web3js & React front end)

Edit: to be clear, the getMessage() function works fine in remix. It just doesnt seem to work with my front end. I am trying to set up a front end for my contract but when trying to invoke a certain ...
0
votes
2answers
176 views

initialise array of struct inside a new struct

Following up on the question of 2d array of different types: 2d array of different types? How would one go about initializing a new array of structs (Vote) when creating a new struct (Project) ...
0
votes
1answer
563 views

calling function with web3 is not working correctly?

I have a problem like this. I have built a smart contract and have deployed it to the infura network. All other functions are working correctly when interacting with web3 but when I calling one ...
0
votes
2answers
234 views

Invalid number of arguments to Solidity function at Object.InvalidNumberOfSolidityArgs (errors.js:25) at

I am always getting this erros with get calls i am using React, Truffle, metamask and Ganache Uncaught (in promise) Error: Invalid number of arguments to Solidity function at Object....
0
votes
1answer
570 views

Metamask Payment in Reactjs

I'm trying to implement a really basic and simple metamask payment in reactjs. This is what i done, handleClick is triggered by a button: handleClick = () => { let web3 = new Web3(); ...
0
votes
1answer
257 views

Truffle with Drizzle fails with TypeError: str.slice

Using Drizzle ran into a problem. Can anyone help? There are several get functions 1-st works fine both in the truffle console and at the frontend, function without arguments truffle console: input:...
0
votes
1answer
473 views

Metamask issue with payable transactions using Truffle and Web3

Hope everyone's doing well. For the past few days I've been having issues with a payable function which I know is definitely working. How do I know it's working? Ether gets sent successfully on Remix....
0
votes
2answers
206 views

Drizzle component returns BigNumber

I am using the following Drizzle (Truffle) component to call a function from a smart contract: <ContractData contract="Market" method="priceOf" methodArgs={this.props.id}/> The result is a ...
0
votes
1answer
410 views

Calling a Solidity function from React

The contract: pragma solidity ^0.4.19; contract Info { /* some other setters */ function ageOf(uint256 _tokenId) public view returns (uint256 age) { return ages[_tokenId]; } ...
0
votes
1answer
559 views

inject web3 in electron-ethereum-react desktop application

I am trying to make ethereum-electron-react application. when I try to inject web3 it does not get detected. import Web3 from 'web3'; console.log (Web3); this shows an empty object even though ...
0
votes
1answer
304 views

Displaying AccountBalance via Geth and Web3

I am throwing together a sample app. I want to query an address and display its account balance. In the constructor of my React component, I am querying a random address: constructor(props) { ...
0
votes
0answers
7 views

The Graph Compound API

I want to build a small project to simulate app.compound.finance (with just eth token let's say) with The Graph , how can I get supply/borrows balance per users? (my defi app initial setup is done, ...
0
votes
0answers
10 views

Deploying Goose Finance Front end and Connecting it to Smart Contracts

I recently learned the fundamentals of Solidity and had some smart contracts deployed on testnets using truffle. Also, I've done a simple dapp by finishing dapp university tutorials on youtube. ...
0
votes
0answers
9 views

Creating buttons for executing smart contract functions,How to work with smart contract instance in App.js

This is my App.js file which is related to a smart contract. I would like to know how is it possible to get access to the contract and create a button for executing a contract function which needs an ...
0
votes
0answers
8 views

How can I access the methods of an object in a contract using web3?

I am creating a front end, and right now I am trying to appove the token for transfer. I have an object, say token, instantiated in my contract as follows: ERC20 private token = ERC20(...
0
votes
0answers
22 views

web3 loading issues

i am working on expense tracker dapp using redux/toolkit, when i call the addTransaction function, unfortunately transaction is not getting fulfilled but in console it throews error message 'TypeError:...
0
votes
0answers
27 views

How do I manipulate data in multiple contracts and output them

I am trying to manipulate data I retrieve from my contract, and then display it. Currently, I am running into 2 problems: 1- I am unable to manipulate the data correctly. 2- I am unable to display ...
0
votes
0answers
24 views

Drizzle not automatically updating value of balanceOf() of an ERC20 contract

I'm using drizzleReactHooks.DrizzleProvider to get the drizzle provider which is being received properly: <drizzleReactHooks.DrizzleProvider drizzle={drizzle}> <drizzleReactHooks....
0
votes
0answers
52 views

Detect Lock/Unlock actions in MetaMask

I want my dApp to detect Lock/Unlock actions in MetaMask, just like in: Remix=>"Deploy & Run transactions"=>"Injected Web3" ethereum.on('accountsChanged'... - is not ...
0
votes
1answer
28 views

Function calls in React to deployed contracts return nothing

I have a simple lottery contract. When I call functions to it from Remix IDE I get the expected result. However, when I make calls to it from React, I get nothing back (such as from manager() or ...
0
votes
1answer
35 views

ipfs.add TypeError: AbortController constructor: 'new' is required

I am using latest version "ipfs-http-client": "^48.2.2" <form onSubmit={ async (event) => { event.preventDefault() try{ ...
0
votes
0answers
36 views

transaction receipt not working

I use react and web3 to interact with metamask. Until yesterday every thing was fine. but, today some of the transaction results are not returning. I use this code to load web3 let web3 if (window....
0
votes
1answer
40 views

The “from” field has been defined when sending a transaction, but the error still occurs

Problem I am following this tutorial on how to make a donate button on my React app. The tutorial is in HTML, however, so below is my attempt at converting it to ReactJS. Code App.jsx donate = () =>...
0
votes
1answer
27 views

Old contracts data not visible if pushed new contracts?

I created a contract campaign and deployed this contract in infura , then I called some functions of the contract which created the subsequent data(as in list of ongoing campaigns) in blockchain. In ...
0
votes
0answers
317 views

Cannot find module 'fs-promise' Error when importing a smart contract instance

I get this error when I try to open a page in the DApp I'm developing. Error: Cannot find module 'fs-promise' Require stack: - /Users/eimanalwahhabi/Desktop/RecycleChain/node_modules/swarm-js/lib/api-...
0
votes
1answer
94 views

Storing hash on blockchain (hash of image stored on ipfs)

I am creating a dapp using react to store image on ipfs and the corresponding hash on blockchain. The purpose of storing hash on blockchain is timestamping, proof of ownership wtc and i wish to ...
0
votes
1answer
46 views

How to extract signature from web3.eth.sign or web3.personal.sign

In React Typescript (.tsx file), I'm trying to use web3.eth.sign to validate an account. The signature is being generated properly, but I can't seem to get the signature out of the callback function. ...
0
votes
1answer
27 views

Giving me error while trying to pass the string in constructor of a smartcontract

This is my Election smart contract. pragma solidity ^0.4.17; contract Election{ struct candidate{ string name; uint votecount; } struct voter{ bool authorized; ...
0
votes
0answers
18 views

How can I access data of transaction topic?

I need to access the data from topic 2 below (see image): With this code I can render the topic hash, but not the topic data: contract .getPastEvents('allEvents', { fromBlock: START_BLOCK, ...
0
votes
0answers
32 views

Frontend for OpenZeppelin ERC20 token and Crowdsale

does anyone know if there are any resources online for a front-end app.js for a simple ERC20 token for a crowdsale? I am looking to build out a front end that will allow log-in with Metamask and buy ...
0
votes
1answer
159 views

Web3/JS: Unable to read a “public view” function using “.call()” while the call to the other functions (eg payable, etc…) work fine

I am posting a question here that I already posted on stackoverflow before I was aware of this ethereum forum. Not sure about the etiquette when doing this so please tell me if I should delete the ...
0
votes
0answers
315 views

web3-react does not appear to be exposing Ethers.js instance

I've configured the web3-react package in my project (set up with the React Truffle box) but I don't seem to be getting an ethers.js instance in the context. According to the package page, the web3-...
0
votes
0answers
30 views

Localhost3000 not recognizing Metamask walllet

I have run npm start and have connected my metamask wallet via a custom RPC ganache host: 127.0.0.1: 8545 with chainID 0x539 on metamask. The ChainID i am not sure about as when I entered the NewRPC ...
0
votes
1answer
100 views

Why calling to methods from Web3 using call() give errors although set functions with send() work

I'm new to solidity and I'm just testing some examples from tutorials. The problem is that I can't call get functions although I can call set function. I'm using Remix IDE for smart contract, Geth for ...
0
votes
0answers
20 views

How to create a web3 connection in react interface?

I have created a simple login and register interface using react js and want to connected through web3 or any other method with a smart contract to stored the registered user's data on the blockchain ...
0
votes
0answers
68 views

Generating a React UI given a contract ABI

Is there a way to automatically generate a React input form as per a contract address and ABI input by a user? The user inputs a contract address and an ABI. Now, an input form is generated for him as ...
0
votes
0answers
413 views

How to deposit ETH into my contract from React front-end with web3.js, truffle, ganache?

currently, I'm struggling to solve an error that occurs when a user deposits funds into a contract from the react.js interface. ●Environment Solidity Compiler 0.6.0 Blockchain: Ganache 2.4.0 Web3: ...
0
votes
1answer
38 views

Get enum value from smart contract with javascript

This is my contract: enum State { Active, Refunding, Pending, Releasing} function state(uint orderid) public view returns (State) { return State.Releasing; } In one Javascript to ...
0
votes
2answers
163 views

Unhandled Rejection (TypeError): this.web3.eth is undefined

My getWeb3.js file: import Web3 from 'web3' export default async () => { var web3Provider = null; if (typeof window.ethereum !== "undefined") { web3 = new Web3(window....
0
votes
1answer
26 views

What are the required platform to make mobile app that has dapp features?

I recently went over dapp with ethereum block chain but most of the coureses and documentation follows example in webApps. I want to know what are the possible frameworks/library, technology/ ...
0
votes
0answers
60 views

Drizzle react app , how to display functions return values?

I have written an asset transfer contract wherein a function createAsset returns a uint256 assetNo and emit an event (event NewAssetNo(string _message, uint256 _assetno); I am not able to display the ...
0
votes
1answer
270 views

Can we decrypt a message by using private key through Metamask

Say I have a hash of a file which is stored on IPFS.I want to encrypt the hash with public keys of few people. How can I do the encryption of the hash (encrypted hash should be stored on smart ...
0
votes
0answers
24 views

Send from Drizzle useCacheSend hook sends trasactions twice

I'm following the old documentation about hooks and I'm getting a problem at sending transactions: every transaction is sent twice, why? The next is the current core: <form onSubmit={...
0
votes
1answer
487 views

Web3 error handling in React

This is really a two part question. First, the only way I can get the error message thrown by a Smart Contract require statement is to call the function first with a call rather than a send. send does ...
0
votes
0answers
20 views

Performance of Dapps when millions of records to be fetched

I am thinking of Dapp with react js and ethereum. Using IPFS for data storage. Let's assume that blockchain holds millions of hash addresses from IPFS. I need to show those millions of records and ...
0
votes
1answer
300 views

ipfs.add is not working

I am trying to upload my file to IPFS and save its hash to my Ethereum contract but neither ipfs.add nor ipfs.files.add is working for me... I have tried usin for loop i.e. for await (const result of ...
0
votes
0answers
34 views

Adding a web2 Landing Page (homepage) to a drizzle-react based web3 app (dapp)

I'm trying to create an ethereum dapp using create-react-app & drizzle Hooks. My dapp requires the landing page (homepage) to not ask for metamask linking or drizzleProvider injection, and to keep ...