Contract ABI
Bench is made up of two on-chain smart contracts. Their application specifications are published here in ARC-32 format. Use these specs to generate typed clients or to decode application calls, events and state.
| Contract | ARC-32 |
|---|---|
| Registry Contract — one per network, creates benches and keeps their directory | registry.arc32.json |
| Bench Contract — one instance per sale | bench.arc32.json |
For a ready-made TypeScript client generated from these specs, see the Typescript SDK.
Failed assertions log a short ERR:... message before rejecting, e.g. ERR:QUOTA (purchase limit exceeded), ERR:OVERSELL (not enough tokens left), ERR:NOT STARTED, ERR:ENDED, ERR:UNAUTH.
Registry Contract
Structs used below: RegistryKey = (uint32,uint32,uint32,uint64,uint64,uint64,uint64) and State (the bench state tuple returned by get_state), see Storage.
Public methods
| Method | Description |
|---|---|
optin(asset) | Opt the registry into the asset for sale. Must be immediately followed by the asset transfer and the create call in the same group. |
create(account owner_addr, uint64 time_start, uint64 time_end, asset selling_asset, uint64 selling_amount, asset purchase_asset, uint64 purchase_price_per_100m, uint64 purchase_limit, uint64 cancellable, string meta) → (uint64,uint64) | Create a bench. Returns (bench_id, app_id) and emits Created(uint64,uint64). See Creating a Bench. |
set_meta(RegistryKey registry_key, string meta) | Update a bench's metadata. Caller must be the bench owner. |
get_meta(RegistryKey registry_key) → string | Read a bench's metadata. |
get_registry_key(uint32 id, uint64 purchase_asset_id, uint64 purchase_price_per_100m, uint64 selling_asset_id, uint64 selling_amount, uint32 time_start, uint32 time_end) → RegistryKey | Helper to build a RegistryKey. |
noop() | No-op, used to attach additional resource references to a group. |
Read-only methods
Intended for simulate calls. The log_* variants log one ABI-encoded value per key (an empty log for unknown keys), which allows batching many benches per call.
| Method | Description |
|---|---|
get_app_ids(RegistryKey[] box_names) → uint64[] | Bench app IDs for the given keys. |
get_bench_states(RegistryKey[] box_names) → State[] | Bench states for the given keys. |
log_bench_states(RegistryKey[] box_names) | Log the State of each bench. |
log_bench_states_with_meta(RegistryKey[] box_names) | Log the StateWithMeta of each bench (state, metadata, and the caller's cumulative spend). |
log_bench_meta(RegistryKey[] box_names) | Log the metadata of each bench. |
Privileged methods
Registry admin only, see Roles.
| Method | Description |
|---|---|
change_admin_1(account new_admin) / change_admin_2() | Two-step admin handover. |
change_fee_addr(account new_fee_addr) | Change the fee admin address. |
change_default_fee_bps(uint64 new_default_fee_bps) | Change the platform fee for new benches. |
change_setup_fee(uint64 new_setup_fee) | Change the setup fee for new benches. |
change_abel_app_id(uint64 new_abel_app_id) | Change the asset labeling contract. |
change_allowlist_labels(string[] new_allowlist_labels) | Change the allowlist labels. |
change_banlist_labels(string[] new_banlist_labels) | Change the banlist labels. |
set_id_counter(uint64 new_id_counter) | Increase the bench ID counter. |
cleanup(account owner, uint32 id, uint32 time_start, uint32 time_end, asset selling_asset, uint64 selling_amount, asset purchase_asset, uint64 purchase_price_per_100m) | Remove a closed bench (zero balance) from the directory. |
Bare UpdateApplication / DeleteApplication | Upgrade or delete the registry. |
Bench Contract
One instance is deployed per sale by the registry.
Public methods
| Method | Description |
|---|---|
buy() | Buy tokens. Preceded in the group by the payment (and by the box MBR payment on the first purchase from a bench with a purchase limit). See Buying. |
get_account_buy_total(address account) → uint64 | Cumulative spend of an account, in purchase asset base units. |
Read-only methods
| Method | Description |
|---|---|
get_state() → State | Full bench state, including the unit names and decimals of both assets. |
get_state_with_meta(application registry_app) → StateWithMeta | As above, plus the metadata (read from the registry) and the caller's cumulative spend. |
get_meta(application registry_app) → string | The bench's metadata, read from the registry. |
Privileged methods
See Roles for who may call each.
| Method | Role | Description |
|---|---|---|
withdraw(uint64 amount) | owner / fee admin | Send proceeds to the owner. |
end() | owner / fee admin | End the sale. |
delete_boxes(byte[][] box_names) | owner / fee admin | Delete purchase-tracking boxes after the end. |
close() | owner / fee admin | Pay out fees, proceeds and unsold tokens; opt out of assets; refund the ALGO seed to the owner. |
withdraw_fees(uint64 amount) | fee admin | Withdraw accrued platform fees. |
lower_fee(uint64 new_fee_bps) | fee admin | Lower the platform fee of this bench. |
optin(asset) / optin2(asset,asset2) | registry (creator) | Opt the bench into its assets, at creation. |
setup(...) | registry (creator) | Configure the bench, once, at creation. |
Notes
cancellable: the bench contract has acancellableflag intended to prevent the owner from ending a bench that has an end time before that time. In the currently deployed contract version,setuprequirescancellable = 1, so every bench created by the current registry can be ended early by its owner. The frontend and SDK always create cancellable benches.- All amounts are in base units. Prices are
purchase_price_per_100mvalues, see Pricing. - Bench IDs are assigned sequentially by the registry (
id_counter).