Skip to content
snapshot

On-chain settlement (TON)

The optional economic layer: sharded, non-custodial Tolk contracts on TON. Only paid jobs touch chain — free jobs settle entirely off-chain. Contracts below are deployed and verified on testnet; the on-chain encodings are computed by the real settlement crate.

testnetActon 1.1.0

The settlement rules written as sharded smart contracts on the TON blockchain, so escrow, payouts and penalties are enforced by code instead of a trusted operator. These contracts are deployed and verified on testnet.

Impact: Escrow only releases when the agreed result is presented (HTLC), and stake is slashed automatically — no company can withhold pay or seize funds.

Published to the DuckDB community registry
The duckton extension is officially published — install it straight from the community registry, no build required.
v0.6.1
INSTALL duckton FROM community;
LOAD duckton;

The on-chain 15% platform fee / 5% verifier commission split shown below is enforced by the deployed contracts; this client extension version is 0.6.1.

Active network — Testnet
deployed & verified
Switch network from the header. Addresses, RPC and explorer below reflect the selected mode.
RPC endpoint
https://testnet.toncenter.com/api/v2
funds
play money
settlement guard
enabled
GlobalParams
StakeVault
JobEscrow
RecordAnchor
Contracts
5
sharded · no global hot contract
Verified
0/5
source ↔ published bytecode
HTLC escrow
quorum-hash
release keyed on result hash
Slash split
100%
challenger+redund+burn+treasury
Code upgrade
SETCODE
proven 1→2, address stable
Custody
non-custodial
no platform seizure path
Deployed contracts (testnet)
Live addresses from ton/deployments/testnet.env; code hashes from the compiled artifacts; verification from acton verify logs.
ContractTestnet addressCode hashVerifiedUpgradeOps
StakeVault
§8 · §8.5 · §8.6
timelocked SETCODE7
StakeReceiptWallet
§8.5
no
JobEscrow
§4.2 · §6.2 · §13
no — a live HTLC's guarantees can't be rewritten mid-flight3
RecordAnchor
§7 · §7.2 · §11
authority-gated SETCODE2
GlobalParams
§12 · §12.1
admin-gated SETCODE3
On-chain GlobalParams
The ecosystem-wide economic params, bps-encoded into a TON cell by the real settlement crate.
platform_fee
1500 bps
surcharge
500 bps
participation κ
500 bps
slash · wrong
1500 bps
slash · cheat
10000 bps
slash · downtime
200 bps
slash · equivocation
5000 bps
slash · failed-commit
1000 bps
→ challenger
4000 bps
→ redundancy
3000 bps
→ burn
2000 bps
→ treasury
1000 bps
quorum / n_default
3 / 5
unbonding / challenge
604800s / 86400s
EcoParams cell hash
ranking weights (q/s/p)
6000/3000/2500 bps
EcoParams cell · BoC (base64)
te6cckEBAQEASAAAjAXcAfQB9AXcJxAAyBOID6ALuAfQA+gFF0h26ABejUpRAAZa8xB6QAAACTqAAAFRgAMFCgMDF3ALuAnEA+gAAOpgAAAH0AXf3JY/

Validated on-chain (validateEcoParams): split bps sum to 10000, κ ≤ 1000 bps, unbonding ≥ challenge_window, stake tiers ordered. Editable in place via UpdateParams (admin-only, bumps paramsVersion).

JobEscrow — HTLC release
Per-job, non-custodial. Address derived offline from the compiled code + the real escrow terms.
escrow address (this job)
HTLC lock = quorum result hash
terms cell hash
escrow B
100 TON
paramsVersion bound
1

The address deterministically commits to hash(StateInit{code, data}) where data binds requester + arbiter + B + deadline + ^terms — so each job gets a distinct escrow. Settle is gated on presenting the agreed quorum hash and bounded by B (remainder refunded); refund-on-timeout returns the full balance to the requester. No platform key can seize funds.

0x45534300 TOPUP0x45534302 SETTLE0x45534303 REFUND

Contract reference

storage · opcodes · get-methods · guards

Wire messages (real TL-B cells)
Opcoded message bodies the node actually broadcasts, built by the settlement crate.
EscrowSettle (HTLC release)0x45534302
cell753 bits
StakeDeposit (bond 50 TON)0x534b4b01
cell140 bits
AnchorSubmit (epoch 1 root)0x414e4301
cell644 bits
UpdateParams (set GlobalParams)0x47504101
cell363 bits
Gas baseline (measured, plotly)
Average TVM gas per opcode from the Tolk emulator suite.
loading plot…
In-place code upgrade (SETCODE)
Proven live on testnet — address unchanged, storage preserved.
contract
from → to
GlobalParams (codeVersion 1)GlobalParamsV2 (codeVersion 2)
address stable
true
new getter live
get_surcharge_bps 500

SETCODE swapped code in place — address unchanged, paramsVersion/fee/admin preserved.

StakeVault: timelocked (announce → apply ≥ unbonding window, commit-reveal)
GlobalParams / RecordAnchor: authority-gated, no timelock
JobEscrow: intentionally not upgradable (live HTLC)
Duckton — stake-receipt jetton
TEP-74 receipt minted 1:1 on deposit, transfer-LOCKED while bonded.
name / symbol / decimals
Duckton / DUCKTON / 9
transfer locked
true
master (StakeVault)
holder wallet
balance
0.2 DUCKTON

A slashable accountability bond, not a liquid position — a transferable receipt would let a host sell it and dodge slashing, so outgoing transfers throw RECEIPT_LOCKED for the whole bond lifetime (mint → burn).

Deploy, verify & live proof
Built/tested/deployed with Acton 1.1.0 (Rust TON toolkit · Tolk + @stdlib/@acton). RPC: https://testnet.toncenter.com/api/v2
Deploy
STAKE_BINDING_HASH=0x… acton script scripts/deploy_stake.tolk --net testnet
ANCHOR_BOND_MIN=100000000 acton script scripts/deploy_anchor.tolk --net testnet
ESCROW_AMOUNT=300000000 ESCROW_EXPECTED_HASH=0x… acton script scripts/deploy_escrow.tolk --net testnet
GP_FEE_RECIPIENT=<addr> acton script scripts/deploy_global_params.tolk --net testnet
Verify (source ↔ bytecode)
acton verify GlobalParams --address <addr> --net testnet
acton verify RecordAnchor --address <addr> --net testnet
acton verify JobEscrow --address <addr> --net testnet
Live Rust integration test
cargo test -p p2p-settlement --features ton-live --test testnet_live -- --nocapture
End-to-end testnet scenario — all checks PASS
globalparams_update::PASS::fee_bps=250::addr_stable=true
globalparams_blocklist::PASS::blocked=true::cleared=false
stake_deposit::staked=120000000::eligible=true
jetton::minted=120000000::staked=120000000::locked=true
duckton_metadata::PASS::name=Duckton::symbol=DUCKTON::decimals=9
escrow_settle::settled=true
anchor_submit::epoch=3::prev_epoch=2
inclusion::verified=true
multileaf_inclusion::PASS::epoch=4::included=true::tampered_rejected=true
dispute::skipped

Deployed StakeVault to kQCPKeaiuRjie18t7_epsxuF09rd8XyzS0-xCHXvTeb3-IVU

On-chain encodings (GlobalParams cell, escrow address, message BoCs) computed by p2p_settlementoffline. Addresses, code hashes, verification & gas read from the repo's deployment artifacts & testnet logs. real