cashscript_py.contract module
Contract API.
Provides loading and interaction with CashScript-contract artifacts, including constructor validation/encoding, address generation, and ABI-based unlockers.
- class Contract(artifact: dict[str, Any], constructor_args: list[bool | int | str | bytes], provider: NetworkProvider, address_type: LockingBytecodeType = LockingBytecodeType.P2SH32)[source]
Bases:
objectHigh-level interface to a CashScript contract.
A Contract is constructed from a compiled cashc JSON artifact and constructor arguments. It exposes ABI functions via the unlock mapping and provides helper methods for querying UTXOs and balances.
- name
The contract name from the artifact.
- address
The contract address (token-unaware).
- token_address
The contract address (token-aware).
- bytecode
Contract redeem script bytecode (hex).
- bytesize
Size of the redeem script in bytes.
- opcount
Count of non-push opcodes in the redeem script.
- provider
Network provider used for blockchain operations.
- address_type
Locking bytecode type (e.g., P2SH32).
- unlock
Mapping of function name to unlocker factory.