Runtime function reference
The admitted callable surface, including arguments, return values, capabilities, and failure conditions.
State functions
Import state from hybrid. Keys must be non-empty strings, must not start with an underscore, and must fit the 128-byte UTF-8 limit. These calls operate on the supplied contract state, not an arbitrary database or wallet.
| Signature | Returns and behavior | Required capability |
|---|---|---|
| state.get(key) | Deep-copied current value; None if absent. Invalid keys or missing capability fail execution. | private:read |
| state.get_decimal(key) | Decimal conversion of the value; absent value becomes Decimal("0"). Conversion can fail. | private:read |
| state.put(key, value) | None; updates the transactional overlay. State size and key limits apply. | private:write |
Event emission
Import event from hybrid. Patterns are exact names or trailing-* prefix matches, not general regular expressions. Event count and total canonical byte limits apply. Emitting an event does not authorize a downstream payment or external side effect.
| Signature | Returns | Conditions |
|---|---|---|
| event.emit(event_type, data) | None | Type is a non-empty string of at most 160 characters; data is a dictionary. The event type must match a declared event capability. |
Decimals and hashes
For example, sha256("hello") commits to the JSON string including its quotation marks. Do not compare it with a raw UTF-8 file hash.
| Signature | Behavior |
|---|---|
| Decimal(value) | Import from hybrid.decimal. Constructs a bounded decimal through a textual representation. Prefer a decimal string. Invalid or out-of-range values fail. |
| sha256(value) | Import from hybrid.crypto. Returns sha256: followed by the lowercase hex digest of canonical JSON bytes. It is not a raw-file-byte hash. |
Built-in functions
Unlisted Python functions are not admitted. Invalid arity or argument types can fail at runtime even when source validation succeeds.
| Function | Accepted use |
|---|---|
| abs(number) | Integer or Decimal, excluding booleans. |
| bool(value) | HybridScript truth value: None, false, zero, and empty collections/text are false. |
| int(value) | One integer or integer string; booleans excluded, signed 256-bit result. |
| len(value) | One string, list, tuple, or dictionary. |
| min / max | Non-empty numeric positional values or one numeric list/tuple; booleans excluded. |
| range(stop), range(start, stop), range(start, stop, step) | Integer arguments, excluding booleans; bounded by the loop-iteration limit. |
| str(value) | Scalar conversion only. Boolean output is "true" / "false" and None becomes "null". |