This is my first solo react project so apologies if I've missed anything glaring. I am trying to find a way to get the {account} and {value} into handlePledge. Obviously you can't use them directly in nested functions. I have tried different things such as passing {account} and {value} as arguments (ie handlePledge({account}, {value})) but no luck.
function App() {
const [account, setAccount] = useState();
const [button, setButton] = useState('Enable Ethereum');
const [value, setValue] = useState(1);
const handlePledge = async (e) => {
e.preventDefault();
const gas = await SixtySixDays.methods.createNewPledge().estimateGas();
const result = await SixtySixDays.methods.createNewPledge().send({
from: #account-goes-here,
gas,
value: #value-goes-here
})
console.log(result);
}
Thank you, any help is greatly appreciated.
handlePledgefunction. What the issue?useState) at the top level in the component, but you can use the state variable (or the set function) anywhere in the function, just normal closure