The bioid FA2 contract is bioid_fa2.py. It is one multi-asset contract: one token id per tube, balance equal to the remaining volume in µL. Tube codes such as SY00000201 are the external ids. The chain stores a nat token id and a code_index from the code string to that id.
SmartPy, package smartpy-tezos 0.24.2 (17 August 2026). Checked against smartpy.io and the package metadata on 19 October 2026. That release is current: 0.24.0 made Shadownet available in the IDE and added the scenario runner used here. The contract compiles and the scenarios run with python3 contracts/bioid_fa2.py. No separate LIGO binary is required.
LIGO is also maintained. SmartPy is the choice because the scenario runner and the Michelson compiler are in the same Python package, which is what this repository already uses for the bridge tests.
Install the pin with:
python3 -m pip install --user -r contracts/requirements.txtWallet types and the transition matrix are in Wallet types, vocabulary bioid-wallet-types-2. The concept note's storage sketch is the source for mint, move, transform, consume, adjust, and withdrawal. Where this contract chooses, it is recorded here.
mint_primarylands inINTAKEorTRANSIT. The task list said intake only. The rulebook also allows a field collection straight into a shipment, and the worked example does that, so both are accepted. The pilot mints at reception.adjust_volumesets the absolute measured volume. It does not take a delta. It is allowed onINTAKEandSTORAGE.transformburns only the drawn volume. The parent token remains, including at 0 µL. Each child is a new token withparent_id.- Standard FA2
transferalways fails withBIOID_TRANSFER_DISABLED. TZIP-12's operator policy is no-transfer:balance_ofandupdate_operatorsstay, and an operator cannot move a tube. A bare transfer cannot carry a reason without changing the FA2 parameter type. Custody moves aremove,shipandreceive. shipthenreceiveis the two-step hand-over throughTRANSIT. APROCESSwallet may ship only when its process code isretrievaland the tube has an approved access request.EXTERNAL_USERis the recipient wallet.receiveinto it requires that approval, and the requester must be that wallet's custodian.report_userecordsconsumed,returned, ordestroyed.attach_datarecords ahttps://oripfs://URI, a 32-byte content hash, a data type, and the step. The same record can ride along onmove,transform,consume,shipandreceive. The off-chain viewlineage_haswalks up to eight parents, so a child shows datasets recorded on its ancestors.withdrawis signed by the owner of the root token.destroyandanonymisefreeze the lineage.stop_usesets statusstopped.confirm_destroyedburns any remaining balance and leaves the token at 0 µL with statusdestroyed.unfreeze_anonymisedclearsconsent_refand sets statusanonymised.- Token metadata follows TZIP-21:
token_infovalues are UTF-8 bytes. The map includesname(the tube code),symbol(uL),decimals(0),sample_type,created_by, andparent_id(empty bytes when there is no parent).
Admin registers wallets and sets active. A custodian may update label and metadata_uri only. Custodians sign ordinary custody. Holding wallets have no keys of their own.
python3 contracts/bioid_fa2.pyTwo scenarios, bioid_happy and bioid_rejections, cover the reception-to-external-use path and the rejection codes. Proposed v0.4 changes (volume rules by transformation type, constant-cost withdrawal, stop-use escalation, explicit lineage depth) are tested patches in proposals/. They are not applied here, so this file stays identical to the deployed Shadownet contract. SmartPy writes Michelson next to the script, under contracts/bioid_happy/ and contracts/bioid_rejections/. Those directories are gitignored.
A Tezos operation may carry at most 32 KB, and one operation may add at most 60 KB of storage. Helpers that touch storage are therefore @sp.private methods of the contract class, which SmartPy inlines, instead of module-level @sp.effects functions, which SmartPy compiles to a LAMBDA at every call site with the whole storage type spelled out twice. That change took the compiled code from about 90 KB to about 31.6 KB. The entrypoint parameter type and the storage type are unchanged, and both scenarios produce the same storage, events and errors at every step. SmartPy does not let one private method call another, so p_maybe_attach, p_do_ship and p_do_consume repeat the wallet lookup inline. The caller emits SHIP or CONSUME after the optional attachment, in the same order as before. Pure helpers without storage access (assert_uri, assert_hash, status_for, move_allowed, ship_allowed) stay at module level.
If the code grows past 32 KB again, the origination will fail with an oversized operation. Check the size after compiling with octez-client convert script contracts/bioid_happy/step_001_cont_0_contract.tz from michelson to binary.
Checked on 19 October 2026 against Testing on testnets (updated 22 July 2026) and teztnets.com:
- Shadownet is the primary permanent testnet for application developers.
- Chain name:
TEZOS_SHADOWNET_2025-08-07T20:00:00Z. - Public RPC:
https://rpc.shadownet.teztnets.com. - TzKT was answering at
https://shadownet.tzkt.io(APIhttps://api.shadownet.tzkt.io/v1/head, chain idNetXsqzbfFenSTS). - Ghostnet has been removed. Do not use it.
- Mainnet is refused by the deploy script and by
TezosBackend.
The script does not generate a key and does not call a faucet. You fund the admin account yourself. One synthetic demo deployment exists on Shadownet, KT1HpDatoa5tHDctAQDY7wQgVEnrWJ9S3vix; its addresses and operations are in pilot/deployments/shadownet.json and explained in the pilot README.
export TEZOS_NETWORK=shadownet
export TEZOS_RPC_URL=https://rpc.shadownet.teztnets.com
export TEZOS_KEY_REF=kms://alias/syn-custodian-lab # or an octez alias that already exists
export TEZOS_ADMIN=tz1... # the address that alias controls
bash contracts/deploy/originate.shThat command compiles and stops. It prints the Michelson path. To originate:
export BIOID_ORIGINATE=1
bash contracts/deploy/originate.shBIOID_ORIGINATE=1 builds storage for TEZOS_ADMIN and, if octez-client is on PATH, runs:
octez-client --endpoint "$TEZOS_RPC_URL" originate contract bioid_fa2 \
transferring 0 from "$TEZOS_KEY_REF" \
running contracts/bioid_happy/step_001_cont_0_contract.tz \
--init "$(cat contracts/bioid_storage/step_001_cont_0_storage.tz)" \
--burn-cap "${BIOID_BURN_CAP:-12}"Origination burns about 8 tez of storage on Shadownet (the code is about 32 KB). Before it calls octez-client, the script checks that the RPC reports chain id NetXsqzbfFenSTS. octez-client uses TEZOS_CLIENT_DIR for its key directory; keep that directory outside the repository.
The file name under bioid_happy/ can differ; the script picks the contract .tz it just wrote. Copy the printed KT1 into TEZOS_CONTRACT for the bridge. Do not commit the key, the storage file, or the KT1 if it is tied to a secret.
The bridge TezosBackend encodes mint_primary, move, ship, receive, transform, consume, report_use (when the source wallet is EXTERNAL_USER), attach_data, request_access, approve_access, withdraw, confirm_destroyed and unfreeze_anonymised. submit then raises InjectionRefused. It does not broadcast.