Model Marketplace Contracts

Panda turns any panda.ml model into a monetizable, on-chain asset. Three contracts cover the spectrum from pay-per-call inference to fully tokenized models traded on an exchange.

ContractMonetization model
PaidModelCharge a flat fee per prediction; the creator withdraws revenue.
TokenizedModelIssue a bonding-curve token; holders get free inference plus revenue dividends.
ModelExchangeAn order-book DEX where tokenized-model tokens trade against PANDA.

All three are deployable from the playground (Model Marketplace category), each with an in-editor tutorial. For the economic overview and decision guide, see Model Marketplace; for the paid-inference rationale, see Paid Inference; for tokenization, see Tokenized Models.


PaidModel

A creator deploys a trained model, sets a price per call, users pay to call predict(), and the creator withdraws accumulated earnings. Usage is tracked on-chain.

State highlights

model_dict, model_name, is_trained, creator, price_per_call, creator_balance, total_revenue, total_calls, user_calls, user_spent.

Methods

MethodKindDescription
deploy(model_name, price_per_call, description)constructorSets the creator, name, and price. Emits PaidModelDeployed.
train(x, y)callCreator trains a LogisticRegression on-chain. Emits ModelTrained.
upload_model(model_dict)callCreator uploads a pre-trained model (must contain __panda_ml_model__). Emits ModelUploaded.
predict(x, payment)callRequires payment >= price_per_call; runs inference, credits the creator, tracks per-user usage. Emits InferencePaid. Returns predictions.
withdraw(amount)callCreator withdraws earnings (0 = all). Emits Withdrawal.
set_price(new_price)callCreator updates the price. Emits PriceChanged.
get_price()queryCurrent price per call.
get_stats()queryName, creator, trained flag, price, total calls/revenue, creator balance, unique users.
get_user_stats(user)querycall_count and total_spent for a user.
get_model_info()queryMetadata (name, description, model type, creator, price) without weights.

Marketplace / rent surface — read by the panda.model.Model SDK proxy (see SDK Types):

MethodKindDescription
metadata()queryModel metadata in the shape the Model.meta proxy reads (kind, name, price, accuracy, creator).
fund(amount)callAdd prepaid inference credits to the model's balance (Model.funds.fund). Emits ModelFunded.
get_balance()queryCurrent prepaid credit balance (Model.funds.balance).
pay_rent(amount)callTop up the model's rent reserve by amount blocks (Model.rent.pay). Emits RentPaid.
rent_status(current_block=-1)queryblocks_remaining / status. Pass current_block for an accurate reading (@query gets no ctx); omit to compute against the last active block. Read by Model.rent.due.

TokenizedModel

Combines on-chain inference with a tradeable PRC-20 token backed by a quadratic bonding curve. Token holders get free inference and a pro-rata share of inference revenue. 60% of supply is minted to the creator; 40% is sold via the curve.

Bonding curve: price = base_price * (sold / total) ** 2 (integer math, multiply-before-divide).

Methods

MethodKindDescription
deploy(model_name, model_dict, token_name, token_symbol, total_supply, base_price, inference_fee, description)constructorValidates the model, mints 60% to the creator, reserves 40% for the curve. Emits ModelTokenized.
buy(amount, payment)callBuys tokens from the curve at the current price. Emits TokensBought.
sell_tokens(amount)callSells tokens back to the curve. Emits TokensSold.
predict(x, payment)callFree for holders; non-holders pay inference_fee. Emits Inference.
claim_dividends()callClaims your pro-rata share of accumulated revenue. Emits DividendClaimed.
train(new_model_dict)callCreator replaces the model. Emits ModelUpdated.
propose_update / vote_update / execute_updatecallToken-weighted governance to update the model.
get_price()queryCurrent bonding-curve price.
get_holdings(owner)queryToken balance for an owner.
get_stats()querySupply, curve state, revenue, inference count, price.

The playground template exposes a focused subset (buy, predict, claim_dividends, get_price, get_holdings, get_stats) so the mechanics are easy to follow. The full contract adds sell_tokens, OHLC history, and governance.


ModelExchange

An order-book DEX for tokenized-model tokens. Models must be listed before trading. Orders are matched by price-time priority, and matched trades update OHLC candles (100-block epochs) and volume stats. The exchange does not custody tokens — it records and matches orders.

Methods

MethodKindDescription
deploy()constructorSets the owner.
list_model_token(model_contract, token_symbol, token_name, description)callRegisters a model for trading. Returns the listing id. Emits ModelListed.
place_order(listing_id, side, price, amount)callPlaces a buy/sell order and attempts a match. Emits OrderPlaced (and Trade on a match). Returns the order id.
cancel_order(order_id)callCancels your open order. Emits OrderCancelled.
get_listing(listing_id)queryListing metadata.
get_all_models()queryEvery listed model.
get_orderbook(listing_id)queryOpen buys and sells.
get_trending(top_k)queryListings ranked by cumulative volume.

The competition-to-marketplace flywheel

These contracts compose: a model proven in a data-science competition can be deployed as a PaidModel, upgraded to a TokenizedModel to raise capital and share revenue, and its token listed on the ModelExchange for price discovery. See Model Marketplace for the full flywheel.


Try it