Overview
The fuel_ops dimension of a transaction’s resource budget counts weighted
operations: every primitive draws an amount of fuel that reflects how much work it does, and the
transaction aborts when the running total would exceed the fuel_ops cap. This page is the normative
cost reference — which primitives cost more than a flat tick, and how their cost scales with input
size.
Every primitive falls into one cost class. The weights are fixed constants — identical on every target, so a transaction costs the same everywhere it runs.
- flat:
1— the base reduction tick charged for every operation; primitives not listed below are flat. - linear(n):
1 + n / 16, wherenis the input (or, where marked post, the result) byte length. - quadratic(n):
1 + (n / 64)^2. - self-capped: the primitive carries its own hard input cap and is otherwise charged as noted.
Any primitive whose cost grows with its input is listed here; anything unlisted is flat.
Linear
| Primitive | n |
|---|---|
_str |
rendered result (post) |
_str_is_number, _str_to_number |
input string |
_substr, _str_left, _str_right |
input string |
_str_trim_left, _str_trim_right, _str_trim |
input string |
_str_to_lower (ASCII) |
input string |
_str_split |
input string |
_utf8_from_binary, _utf8_to_binary, _utf8_normalize, _utf8_substring, _utf8_to_str, _utf8_from_str, _utf8_to_upper, _utf8_to_lower |
input bytes |
_crypto_keccak256, _crypto_sha256, _crypto_sha256d, _crypto_ripemd160, _crypto_hash160 |
input |
_crypto_hmac_sha256, _crypto_hmac_sha512 |
key + data |
_crypto_secp256k1_sign_recoverable, _crypto_secp256k1_ecrecover, _crypto_secp256k1_verify |
summed inputs (see note 1) |
_ecc_c25519_sign, _ecc_c25519_verify |
message |
_hex_string_to_binary, _hex_string_from_binary |
input |
_string_to_binary, _binary_as_ascii_string |
input |
_is_base58 |
input |
_eth_seed_from_mnemonic, _eth_seed_from_mnemonic_with_passphrase |
mnemonic (+ passphrase) |
_rlp_encode |
encoded result (post) |
_rlp_decode |
input |
_reg_match |
pattern + input |
_to_json, _to_json_or_abort |
rendered result (post) |
_from_json, _from_json_or_abort, _from_json_with_limits |
input string |
_read, _read_or_abort, _read_external, _read_external_or_abort |
input blob |
_write |
serialized result (post) |
_to_json_with_limits |
rendered result (post; caller-supplied JSON limits do not bound a hostile author) |
_code_str |
rendered result (post; sibling of _str) |
_value_hash_tree |
rendered tree (post) |
_value_id, _value_id_custom, _root_hash |
exact bytes streamed into the hash (the walk is not memoized, so every call charges) |
_binary_slice |
slice length |
_print, _e_print |
rendered result per argument (post) |
Quadratic
| Primitive | n |
|---|---|
_str_cut |
input string (worst case len = 1: n tail copies) |
_str_find, _utf8_find |
linear on both operands plus quadratic on the shorter |
_base58_encode, _base58_decode, _base58check_encode, _base58check_decode |
input |
_binary_to_base58, _binary_from_base58, _safe_binary_from_base58 |
input |
Self-capped
These carry their own hard input cap and are otherwise charged flat.
| Primitive | Cap | Charge |
|---|---|---|
_bech32_encode/decode, _bech32m_encode/decode |
128-byte data / 90-char string | flat |
_examine_binary |
2^20 input cap | flat |
| TOTP primitives | key <= 1024 b, digits <= 16 | flat |
_shamir_generate_shares, _shamir_reconstruct_secret |
n, k caps applied by the structural limits | flat |
Deliberately flat
_strlen,_binlen,_count, integer arithmetic, hash/tuple compare, single-index access: O(1)._str_from_number,_number_to_binary,_binary_to_number,_byte_to_hex,_hash_code_to_binary,_binary_to_hash_code: fixed-small inputs (<= 8/32 bytes).- Fixed-size elliptic-curve and Ethereum key derivations (
_eth_public_from_private,_eth_address_from_public,_eth_generate_mnemonic,_eth_generate_mnemonic_from_entropy,_eth_extended_root_key_from_seed,_eth_extract_private_from_extended,_eth_extract_public_from_extended,_eth_extended_public_from_extended_private,_eth_derive_private_key,_eth_derive_public_key,_eth_hardened,_eth_sign,_eth_parse_signature,_eth_validate_and_parse_signature,_eth_compress_public,_eth_decompress_public,_ecc_c25519_create_key): constant-size inputs. - String/value concatenation and other domain-level reductions: covered by the base reduction tick.
Note 1: the charged signature and hashing primitives have a large constant cost that byte-linear charging under-represents. The permissiveness is in the charging model — the fixed per-signature cost is not charged, only its byte term — not in enforcement: a transaction still aborts the instant its running tally exceeds the declared limit. It is deterministic and safe (it charges the same on every target, never divergent).
Note 2 (32-bit targets): length arguments are taken as 64-bit; a value longer than 2^32 cannot
exist on a 32-bit target (and the 2^32 string_bytes ceiling binds everywhere), so the weights agree
across targets.
This table is normative: every primitive with input-proportional cost is listed here, and the code and this table must be kept in step (an automated parity check is pending). A new primitive with input-proportional (or worse) cost adds both its charge and its row here in the same change.