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.

ContractARC-32
Registry Contract — one per network, creates benches and keeps their directoryregistry.arc32.json
Bench Contract — one instance per salebench.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

MethodDescription
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) → stringRead 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) → RegistryKeyHelper 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.

MethodDescription
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.

MethodDescription
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 / DeleteApplicationUpgrade or delete the registry.

Bench Contract

One instance is deployed per sale by the registry.

Public methods

MethodDescription
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) → uint64Cumulative spend of an account, in purchase asset base units.

Read-only methods

MethodDescription
get_state() → StateFull bench state, including the unit names and decimals of both assets.
get_state_with_meta(application registry_app) → StateWithMetaAs above, plus the metadata (read from the registry) and the caller's cumulative spend.
get_meta(application registry_app) → stringThe bench's metadata, read from the registry.

Privileged methods

See Roles for who may call each.

MethodRoleDescription
withdraw(uint64 amount)owner / fee adminSend proceeds to the owner.
end()owner / fee adminEnd the sale.
delete_boxes(byte[][] box_names)owner / fee adminDelete purchase-tracking boxes after the end.
close()owner / fee adminPay out fees, proceeds and unsold tokens; opt out of assets; refund the ALGO seed to the owner.
withdraw_fees(uint64 amount)fee adminWithdraw accrued platform fees.
lower_fee(uint64 new_fee_bps)fee adminLower 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 a cancellable flag intended to prevent the owner from ending a bench that has an end time before that time. In the currently deployed contract version, setup requires cancellable = 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_100m values, see Pricing.
  • Bench IDs are assigned sequentially by the registry (id_counter).