neo_solidity/runtime/spec/
gas.rs

1/// Syscall gas cost table based on Neo N3 fee schedule.
2/// Note: Some syscalls use approximate costs; see Neo N3 documentation for exact values.
3pub fn syscall_gas_table() -> std::collections::HashMap<[u8; 4], u64> {
4    use std::collections::HashMap;
5    let mut m = HashMap::new();
6    for (_, spec) in SYSCALLS.iter() {
7        let gas = match spec.name {
8            // Storage
9            "System.Storage.GetContext"
10            | "System.Storage.GetReadOnlyContext"
11            | "System.Storage.AsReadOnly" => 1,
12            "System.Storage.Get" => 100,
13            "System.Storage.Put" => 1_000,
14            "System.Storage.Delete" => 100,
15            "System.Storage.Find" => 100,
16            "System.Storage.Local.Get" => 100,
17            "System.Storage.Local.Put" => 1_000,
18            "System.Storage.Local.Delete" => 100,
19            "System.Storage.Local.Find" => 100,
20            // Iterators
21            "System.Iterator.Next" | "System.Iterator.Value" => 1,
22            // Runtime
23            "System.Runtime.Platform"
24            | "System.Runtime.GetTrigger"
25            | "System.Runtime.GetScriptContainer"
26            | "System.Runtime.GetNetwork"
27            | "System.Runtime.GetAddressVersion"
28            | "System.Runtime.GetTime"
29            | "System.Runtime.GasLeft"
30            | "System.Runtime.GetInvocationCounter"
31            | "System.Runtime.GetCallingScriptHash"
32            | "System.Runtime.GetEntryScriptHash"
33            | "System.Runtime.GetExecutingScriptHash"
34            | "System.Runtime.GetNotifications"
35            | "System.Runtime.BurnGas"
36            | "System.Runtime.CurrentSigners"
37            | "System.Runtime.LoadScript" => 1,
38            "System.Runtime.CheckWitness" => 200,
39            "System.Runtime.Log" | "System.Runtime.Notify" => 1,
40            "System.Runtime.GetRandom" => 50,
41            // Crypto
42            "System.Crypto.CheckSig" | "System.Crypto.CheckMultisig" => 1_000,
43            // Contract / native calls
44            "System.Contract.Call" | "System.Contract.GetCallFlags" => 10,
45            "System.Contract.CreateStandardAccount" | "System.Contract.CreateMultisigAccount" => {
46                10
47            }
48            _ => 1,
49        };
50        m.insert(spec.id, gas);
51    }
52    m
53}