Skip to content
Fossa

Model markets

Canonical model accounts, books, and market discovery.

Create a model market

Send instruction 18 with [market, model(w), terms(ws), capacity(ws), provider(s), payer(ws), system_program, provider_profile, model_metadata(w)]. Append admin(s) as the tenth account when the provider is not the market administrator. The administrator must authorize creation; when the provider is that administrator, its existing signature satisfies both roles. Profile approval is still required. This gate protects the permanent model identifier and book-size choice.

The payload is model_id:[u8;32], limit:u32, document_sha256:[u8;32], then URI bytes: offsets 0, 32, 36, and 68. The model ID is an opaque 32-byte identifier. Derive the model PDA from [b"model", market, model_id] and its metadata PDA from [b"model_metadata", model].

Precreate separate, program-owned terms and capacity accounts with zeroed headers. Their exact sizes are 48 + limit × 120 and 48 + limit × 32 bytes. Both accounts must sign; limit must be between 1 and 4096.

Initialization creates the 144-byte model and 396-byte metadata accounts atomically. The model binds its ID to those canonical books permanently. The creating provider becomes the immutable metadata authority, including when a separate administrator authorizes creation. Other approved providers can append offers subject to the offer-registration rules.

Read model markets

Read model accounts through Solana account queries; no read instruction or transaction is required. For getProgramAccounts, filter the program's accounts by dataSize:144, discriminator MODELV20 at offset 0, and the market public key at offset 8. An individual model can be addressed directly through its PDA and read with getAccountInfo. Encode memcmp filter bytes in the RPC's required encoding.

Decode the market at bytes 8..40, model ID at 40..72, terms book at 72..104, capacity book at 104..136, slot limit at 136 as u32, and bump at 140 as u8. Verify the account owner, exact length, discriminator, market, and derived address before using its book bindings.

The metadata account uses discriminator MMETAV20. Its model key occupies 40..72, authority 72..104, document hash 104..136, URI length 136..138, and URI bytes start at 140. Provider profiles use PROV0V20, with authority at 40, hash at 72, URI length at 104, approval at 106, and URI at 108. URI lengths exclude the unused zero-filled tail.