Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active August 6, 2021 11:02
Show Gist options
  • Save percybolmer/6bea3366229793722bca8b74a59a11de to your computer and use it in GitHub Desktop.
Save percybolmer/6bea3366229793722bca8b74a59a11de to your computer and use it in GitHub Desktop.
// stake will trigger a stake on the users behalf
function stake() {
// When we trigger Transactions we should use send instead of call
// We should also calculate the GAS cost so we can apply the correct amount of gas
devToken.methods.stake(1000).estimateGas({from: accounts[0]})
.then((gas) => {
// We now have the gas amount, we can now send the transaction
devToken.methods.stake(1000).send({
from: accounts[0],
gas: gas
});
// Fake update of account by changing stake, Trigger a reload when transaction is done later
setAccountBalance(accountBalance-1000);
}).catch((error) => {
throw new Error(error);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment