Skip to main content

neo_runtime/
context.rs

1// Copyright (c) 2025-2026 R3E Network
2// Licensed under the MIT License
3
4use neo_syscalls::NeoVMSyscall;
5use neo_types::*;
6
7/// Lightweight view of the runtime context.
8#[derive(Default)]
9pub struct NeoRuntimeContext;
10
11impl NeoRuntimeContext {
12    pub fn new() -> Self {
13        Self
14    }
15
16    pub fn trigger(&self) -> NeoResult<NeoInteger> {
17        NeoVMSyscall::get_trigger()
18    }
19
20    pub fn gas_left(&self) -> NeoResult<NeoInteger> {
21        NeoVMSyscall::get_gas_left()
22    }
23
24    pub fn invocation_counter(&self) -> NeoResult<NeoInteger> {
25        NeoVMSyscall::get_invocation_counter()
26    }
27
28    pub fn calling_script_hash(&self) -> NeoResult<NeoByteString> {
29        NeoVMSyscall::get_calling_script_hash()
30    }
31
32    pub fn entry_script_hash(&self) -> NeoResult<NeoByteString> {
33        NeoVMSyscall::get_entry_script_hash()
34    }
35
36    pub fn executing_script_hash(&self) -> NeoResult<NeoByteString> {
37        NeoVMSyscall::get_executing_script_hash()
38    }
39}