Skip to main content

neo_runtime/
runtime.rs

1// Copyright (c) 2025-2026 R3E Network
2// Licensed under the MIT License
3
4use neo_syscalls::NeoVMSyscall;
5use neo_types::*;
6
7use crate::NeoStorage;
8
9/// Direct wrappers for the canonical System.Runtime syscalls.
10pub struct NeoRuntime;
11
12impl NeoRuntime {
13    pub fn get_time() -> NeoResult<NeoInteger> {
14        NeoVMSyscall::get_time()
15    }
16
17    pub fn get_time_i64() -> NeoResult<i64> {
18        NeoVMSyscall::get_time_i64()
19    }
20
21    pub fn check_witness(account: &NeoByteString) -> NeoResult<NeoBoolean> {
22        NeoVMSyscall::check_witness(account)
23    }
24
25    pub fn check_witness_bytes(account: &[u8]) -> NeoResult<NeoBoolean> {
26        NeoVMSyscall::check_witness_bytes(account)
27    }
28
29    pub fn check_witness_i64(account: i64) -> NeoResult<NeoBoolean> {
30        NeoVMSyscall::check_witness_i64(account)
31    }
32
33    pub fn notify(event: &NeoString, state: &NeoArray<NeoValue>) -> NeoResult<()> {
34        NeoVMSyscall::notify(event, state)
35    }
36
37    pub fn notify_event(event: &str) -> NeoResult<()> {
38        NeoVMSyscall::notify_event(event)
39    }
40
41    pub fn log(message: &NeoString) -> NeoResult<()> {
42        NeoVMSyscall::log(message)
43    }
44
45    pub fn platform() -> NeoResult<NeoString> {
46        NeoVMSyscall::platform()
47    }
48
49    pub fn get_trigger() -> NeoResult<NeoInteger> {
50        NeoVMSyscall::get_trigger()
51    }
52
53    pub fn get_invocation_counter() -> NeoResult<NeoInteger> {
54        NeoVMSyscall::get_invocation_counter()
55    }
56
57    pub fn get_random() -> NeoResult<NeoInteger> {
58        NeoVMSyscall::get_random()
59    }
60
61    pub fn get_network() -> NeoResult<NeoInteger> {
62        NeoVMSyscall::get_network()
63    }
64
65    pub fn get_address_version() -> NeoResult<NeoInteger> {
66        NeoVMSyscall::get_address_version()
67    }
68
69    pub fn get_gas_left() -> NeoResult<NeoInteger> {
70        NeoVMSyscall::get_gas_left()
71    }
72
73    pub fn get_calling_script_hash() -> NeoResult<NeoByteString> {
74        NeoVMSyscall::get_calling_script_hash()
75    }
76
77    pub fn get_calling_script_hash_i64() -> NeoResult<i64> {
78        NeoVMSyscall::get_calling_script_hash_i64()
79    }
80
81    pub fn get_entry_script_hash() -> NeoResult<NeoByteString> {
82        NeoVMSyscall::get_entry_script_hash()
83    }
84
85    pub fn get_entry_script_hash_i64() -> NeoResult<i64> {
86        NeoVMSyscall::get_entry_script_hash_i64()
87    }
88
89    pub fn get_executing_script_hash() -> NeoResult<NeoByteString> {
90        NeoVMSyscall::get_executing_script_hash()
91    }
92
93    pub fn get_executing_script_hash_i64() -> NeoResult<i64> {
94        NeoVMSyscall::get_executing_script_hash_i64()
95    }
96
97    pub fn get_notifications(script_hash: Option<&NeoByteString>) -> NeoResult<NeoArray<NeoValue>> {
98        NeoVMSyscall::get_notifications(script_hash)
99    }
100
101    pub fn get_script_container() -> NeoResult<NeoArray<NeoValue>> {
102        NeoVMSyscall::get_script_container()
103    }
104
105    pub fn get_storage_context() -> NeoResult<NeoStorageContext> {
106        NeoStorage::get_context()
107    }
108
109    /// Burn the specified amount of GAS from the calling contract.
110    pub fn burn_gas(gas: &NeoInteger) -> NeoResult<()> {
111        NeoVMSyscall::burn_gas(gas)
112    }
113
114    /// Get the signers of the current transaction.
115    pub fn current_signers() -> NeoResult<NeoArray<NeoValue>> {
116        NeoVMSyscall::current_signers()
117    }
118
119    /// Load and execute a script dynamically.
120    pub fn load_script(
121        script: &NeoByteString,
122        call_flags: &NeoInteger,
123        args: &NeoArray<NeoValue>,
124    ) -> NeoResult<()> {
125        NeoVMSyscall::load_script(script, call_flags, args)
126    }
127}