CompiledContract (Class)¶
A compiled SilverScript contract: the locking script plus the metadata needed to build unlocking (signature) scripts for its entrypoints.
abi
property
¶
abi: list[EntryAbi]
The contract ABI: one entry per callable entrypoint, ordered alphabetically by name.
The same order a ContractArtifact reports, so an entrypoint keeps the
same position either way. To reach one entry, prefer entry(name) over
indexing.
state_span
property
¶
(offset, len): byte offset and length of the contract state within
the script.
The same two numbers, under the same name, as the artifact's
compiled.state_span in artifact_json().
template_hash
property
¶
The canonical length-bound template hash: a 32-byte digest over the
script's template parts (the prefix before and suffix after the state
region). Matches the SilverScript templateHash(prefix, suffix) builtin,
so contracts can commit to this value and later reconstruct it on-chain.
__repr__
¶
The detailed string representation.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The CompiledContract as a repr string.
TYPE:
|
artifact_json
¶
Serialize the contract's portable ABI artifact as JSON.
The artifact is built once by compile and is what build_sig_script
encodes against. For the same source and constructor arguments this is
identical to what the upstream silverc compiler writes, so artifacts
are interchangeable between the two.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The portable artifact as pretty-printed JSON. Pass it to
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
SilverScriptError
|
If the artifact cannot be serialized. |
build_sig_script
¶
Build the signature (unlocking) script for an entrypoint.
| PARAMETER | DESCRIPTION |
|---|---|
function_name
|
The entrypoint to call.
TYPE:
|
args
|
Native Python values (int, bool, str, bytes, list/tuple, or dict) matching the entrypoint's ABI input types. Omit or pass None for an entrypoint that takes no arguments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
The signature (unlocking) script.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
SilverScriptError
|
If the entrypoint is unknown or an argument is invalid (wrong type, out of range, or too deeply nested). |
build_sig_script_for_covenant_decl
¶
build_sig_script_for_covenant_decl(function_name: str, args: Optional[Any] = None, *, is_leader: bool = False) -> bytes
Build the signature (unlocking) script for a covenant declaration entrypoint.
| PARAMETER | DESCRIPTION |
|---|---|
function_name
|
The covenant entrypoint to call.
TYPE:
|
args
|
Native Python values matching the ABI input types of the
entry this call resolves to — the declaration's leader entry,
or the contract's shared delegate entry when
TYPE:
|
is_leader
|
Select the leader path for covenants that distinguish a leader from delegates (default: False).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
The signature (unlocking) script.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
SilverScriptError
|
If the entrypoint is unknown or an argument is invalid (wrong type, out of range, or too deeply nested). |
entry
¶
entry(name: str) -> EntryAbi
Look up one entrypoint's ABI by name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The entrypoint name, as it appears in
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EntryAbi
|
The entrypoint's ABI.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
SilverScriptError
|
If the contract declares no such entrypoint. The
message matches the one |