Documentation ¶
Overview ¶
Package runtime provides various service functions related to execution environment. It has similar function to Runtime class in .net framwork for Neo.
Index ¶
- Constants
- func BurnGas(gas int)
- func CheckWitness(hashOrKey []byte) bool
- func GasLeft() int
- func GetCallingScriptHash() interop.Hash160
- func GetEntryScriptHash() interop.Hash160
- func GetExecutingScriptHash() interop.Hash160
- func GetInvocationCounter() int
- func GetNetwork() int
- func GetNotifications(h interop.Hash160) [][]interface{}
- func GetRandom() int
- func GetScriptContainer() *ledger.Transaction
- func GetTime() int
- func GetTrigger() byte
- func Log(message string)
- func Notify(name string, args ...interface{})
- func Platform() []byte
Constants ¶
const ( OnPersist byte = 0x01 PostPersist byte = 0x02 Application byte = 0x40 Verification byte = 0x20 )
Trigger values to compare with GetTrigger result.
Variables ¶
This section is empty.
Functions ¶
func BurnGas ¶ added in v0.95.0
func BurnGas(gas int)
BurnGas burns provided amount of GAS. It uses `System.Runtime.BurnGas` syscall.
func CheckWitness ¶
CheckWitness verifies if the given script hash (160-bit BE value in a 20 byte slice) or key (compressed serialized 33-byte form) is one of the signers of this invocation. It uses `System.Runtime.CheckWitness` syscall.
func GasLeft ¶ added in v0.90.0
func GasLeft() int
GasLeft returns the amount of gas available for the current execution. This function uses `System.Runtime.GasLeft` syscall.
func GetCallingScriptHash ¶ added in v0.90.0
GetCallingScriptHash returns script hash (160 bit in BE form represented as 20-byte slice) of the contract that started the execution of the currently running context (caller of current contract or function), so it's one level above the GetExecutingScriptHash in the call stack. It uses `System.Runtime.GetCallingScriptHash` syscall.
func GetEntryScriptHash ¶ added in v0.90.0
GetEntryScriptHash returns script hash (160 bit in BE form represented as 20-byte slice) of the contract that initially started current execution (this is a script that is contained in a transaction returned by GetScriptContainer) execution from the start. This function uses `System.Runtime.GetEntryScriptHash` syscall.
func GetExecutingScriptHash ¶ added in v0.90.0
GetExecutingScriptHash returns script hash (160 bit in BE form represented as 20-byte slice) of the contract that is currently being executed. Any AppCall can change the value returned by this function if it calls a different contract. This function uses `System.Runtime.GetExecutingScriptHash` syscall.
func GetInvocationCounter ¶ added in v0.90.0
func GetInvocationCounter() int
GetInvocationCounter returns how many times current contract was invoked during current tx execution. This function uses `System.Runtime.GetInvocationCounter` syscall.
func GetNetwork ¶ added in v0.96.0
func GetNetwork() int
GetNetwork returns network magic number. This function uses `System.Runtime.GetNetwork` syscall.
func GetNotifications ¶ added in v0.90.0
GetNotifications returns notifications emitted by contract h. 'nil' literal means no filtering. It returns slice consisting of following elements: [ scripthash of notification's contract , emitted item ]. This function uses `System.Runtime.GetNotifications` syscall.
func GetRandom ¶ added in v0.96.0
func GetRandom() int
GetRandom returns pseudo-random number which depends on block nonce and tx hash. Each invocation will return a different number. This function uses `System.Runtime.GetRandom` syscall.
func GetScriptContainer ¶ added in v0.90.0
func GetScriptContainer() *ledger.Transaction
GetScriptContainer returns the transaction that initially triggered current execution context. It never changes in a single execution, no matter how deep this execution goes. This function uses `System.Runtime.GetScriptContainer` syscall.
func GetTime ¶
func GetTime() int
GetTime returns the timestamp of the most recent block. Note that when running script in test mode this would be the last accepted (persisted) block in the chain, but when running as a part of the new block the time returned is the time of this (currently being processed) block. This function uses `System.Runtime.GetTime` syscall.
func GetTrigger ¶
func GetTrigger() byte
GetTrigger returns the smart contract invocation trigger which can be either verification or application. It can be used to differentiate running contract as a part of verification process from running it as a regular application. Some interop functions (especially ones that change the state in any way) are not available when running with verification trigger. This function uses `System.Runtime.GetTrigger` syscall.
func Log ¶
func Log(message string)
Log instructs VM to log the given message. It's mostly used for debugging purposes as these messages are not saved anywhere normally and usually are only visible in the VM logs. This function uses `System.Runtime.Log` syscall.
func Notify ¶
func Notify(name string, args ...interface{})
Notify sends a notification (collecting all arguments in an array) to the executing environment. Unlike Log it can accept any data along with the event name and resulting notification is saved in application log. It's intended to be used as a part of contract's API to external systems, these events can be monitored from outside and act upon accordingly. This function uses `System.Runtime.Notify` syscall.
Types ¶
This section is empty.