neo_runtime/contract.rs
1// Copyright (c) 2025-2026 R3E Network
2// Licensed under the MIT License
3
4use neo_types::*;
5
6/// Neo N3 contract management operations.
7///
8/// **These are test/example stubs.** In deployed contracts, the `#[neo_contract]`
9/// macro generates Wasm imports that map to NeoVM syscalls
10/// (`System.Contract.Create`, `System.Contract.Update`, `System.Contract.Call`).
11/// The methods here allow compiling and unit-testing contract code off-chain.
12///
13/// - `create()` returns a zero-filled 20-byte hash (placeholder script hash).
14/// - `update()` and `destroy()` succeed immediately with no side effects.
15/// - `call()` always returns `NeoValue::Null`.
16pub struct NeoContractRuntime;
17
18impl NeoContractRuntime {
19 /// Deploy a new contract. Returns a placeholder 20-byte script hash.
20 pub fn create(
21 script: &NeoByteString,
22 manifest: &NeoContractManifest,
23 ) -> NeoResult<NeoByteString> {
24 let _ = (script, manifest);
25 Ok(NeoByteString::new(vec![0u8; 20]))
26 }
27
28 /// Update an existing contract's script and manifest.
29 pub fn update(
30 _script_hash: &NeoByteString,
31 script: &NeoByteString,
32 manifest: &NeoContractManifest,
33 ) -> NeoResult<()> {
34 let _ = (script, manifest);
35 Ok(())
36 }
37
38 /// Destroy a contract.
39 pub fn destroy(script_hash: &NeoByteString) -> NeoResult<()> {
40 let _ = script_hash;
41 Ok(())
42 }
43
44 /// Call another contract's method. Always returns `NeoValue::Null` in stubs.
45 pub fn call(
46 script_hash: &NeoByteString,
47 method: &NeoString,
48 args: &NeoArray<NeoValue>,
49 ) -> NeoResult<NeoValue> {
50 let _ = (script_hash, method, args);
51 Ok(NeoValue::Null)
52 }
53}