The minimum surface
Xmarket calls exactly five functions on a collection contract to settle trades and route royalties. Implement these and your contract is marketplace-compatible:
For the full standard (transfers, approvals, events, view returns), see XNS-1.
How a trade settles
- The seller approves Xmarket as an operator on the token (
approveorset_operator) - The seller lists via
list_nft(contract, token_id, price) - A buyer calls
buy_nft(listing_id)with OCT attached - Xmarket reads
owner_of, checksis_approved_or_owner, readsroyalty_of+creator_of, then callstransfer_fromand credits proceeds
royalty_of at settlement, then clamped to a 10% ceiling by Xmarket. A contract reporting 50% still pays out 10%. The cap is enforced by the marketplace, not by trusting the collection.
Good practices
- Bounds-check
token_idin every view function and revert on nonexistent tokens. Xmarket and indexers rely on this. - Emit
Transferredon every ownership change, including mints (from = 0on mint), so indexers can follow ownership without rescanning. - Keep proceeds pull-based. Octra’s AML reverts earlier
transfer()calls if a latercall()in the same function fails, so pushing funds during settlement is fragile. Credit a balance and let recipients claim.
Reference implementations
Xcollection and XpectrumGenesis both implement XNS-1 in AML and are formally verified. Use them as a reference for the exact event shapes and view return formats. See Contracts.