Skip to main content

neo_devpack_solidity/runtime/spec/
gas.rs

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