Skip to content

Applying transactions that modify SC state with t.Apply #600

Answered by Kourin1996
dankostiuk asked this question in General
Discussion options

You must be logged in to vote

Hello, @dankostiuk.

All validator needs to do same state change. Blockchain calls PreStateCommit of Blockchain with the state transition object after all transactions in a block are processed. You can use this callback to update your state.

For example, staking contract is deployed without transaction at the specific height in the following code:

func (pos *PoSMechanism) preStateCommitHook(rawParams interface{}) error {
params, ok := rawParams.(*preStateCommitHookParams)
if !ok {
return ErrInvalidHookParam
}
// Deploy Staking contract
contractState, err := stakingHelper.PredeployS…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dankostiuk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants