Last active
August 6, 2021 11:02
-
-
Save percybolmer/6bea3366229793722bca8b74a59a11de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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