Skip to content

Instantly share code, notes, and snippets.

@obscuren
Created August 24, 2016 12:49
Show Gist options
  • Save obscuren/9ae87e237673d3401bbdb1d720dce0f5 to your computer and use it in GitHub Desktop.
Save obscuren/9ae87e237673d3401bbdb1d720dce0f5 to your computer and use it in GitHub Desktop.
infoContext := vm.InfoContext{
Origin: common.HexToAddress(exeValues["caller"]),
Parent: common.HexToHash(envValues["previousHash"]),
Coinbase: common.HexToAddress(envValues["currentCoinbase"]),
Number: common.Big(envValues["currentNumber"]),
Time: common.Big(envValues["currentTimestamp"]),
Difficulty: common.Big(envValues["currentDifficulty"]),
GasLimit: common.Big(envValues["currentGasLimit"]),
GasPrice: common.Big(exeValues["gasPrice"]),
}
var initialCall bool
backend := core.Backend{
GetHashFn: func(n uint64) common.Hash {
return common.BytesToHash(crypto.Keccak256([]byte(big.NewInt(int64(n)).String())))
},
State: state,
}
canTransfer := func(address common.Address, amount *big.Int) bool {
if skipTransfer {
if initialCall {
initialCall = false
return true
}
}
return backend.State.GetBalance(from).Cmp(balance) >= 0
}
env := vm.NewEnvironment(core.EVMCallContext{canTransfer}, infoContext, backend, ruleSet, vm.Config{})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment