New answers tagged

1

The way to pass the Ether value into the the function was to pass it in as an object. The startCoinFlip function should look like this. Also had to convert the wager with the updatedWager variable a bit. Ethers.js only accepts strings in this case. This actually has to do with the older version of Solidity in this case. Notice this contract is using 0.7.6 as ...


0

It's not possible. The connect/disconnect functionality is entirely in the user's hands due to security and privacy concerns. You can only pretend a disconnect by resetting a provider, chainId and selectedAccount to null and clearing the cache of the provided you previously used. P.S.: I know this is a harsh reality. Upvote this as it's the only correct ...


0

In my case, using truffle, I've solved this way: ...catch((err) => { let message = JSON.parse(err.message.substring(56).trim().replace("'", "")).value.data.data; console.log(message[Object.keys(message)[0]].reason); On this way I can show the message I set on my solidity contract.


0

here is the error: <input onChange={e => setWager(e.target.value)} placeholder="Send your ETH"/> there is no "value" prop. you should have <input value={wager} onChange={e => setWager(e.target.value)} placeholder="Send your ETH"/> You are not passing a valid input, that is why you are getting that error


0

use This Library https://github.com/MikeMcl/bignumber.js/ as like import BigNumber from "bignumber.js"; // or import { BigNumber } from "bignumber.js"; let x = new BigNumber(123.4567); let y = BigNumber('123456.7e-3'); let z = new BigNumber(x); x.isEqualTo(y) && y.isEqualTo(z) && x.isEqualTo(z);


0

You want to trigger an event in your front end that will catch these value and store them in the state until you process them. *REACT* <input type="text" onChange={(e) => console.log(e.target.value)}> This will print out the value in the devtool console anytime the value change. To send your transaction to the network, Your app will need ...


0

We've fixed the problem by setting maxFeePerGas and maxPriorityFeePerGas on null contract.methods.methodName().send({ ... maxPriorityFeePerGas: null, maxFeePerGas: null, }); and for the last part - yes, amount needs to be multiplied on gas limit.


0

I found a solution to my problem! With ipfs-http-client, you need to use ipfs.add as part of an async/await function in order for ipfs.add to actually execute, it seems. Without it being in an async/await function, it didn't do anything at all when getHash() ran. This is how I changed getHash(): async function getHash() { try { const ...


1

The approach I use is keep using React folder structure and add the folders and files Truffle requires. Ensure you have "contracts" folder, "migrations" folder with appropriate migrations.js files, and your truffle-config.js file in root.


1

So turns out both the front end and smart contract represent tokens in wei, so 1 token is 0.000000000000000001. In my front end I changed the 1 to web3.utils.toWei("1", 'ether'); and in my smart contract did 1 * 10 ** 18. This worked perfectly.


Top 50 recent answers are included