CCengine
Docs/Guides
Guide / Credits

Credits

Read prices and scores, buy and sell Credits, swap pile Credits, and sweep listings.

Read a Credit

Core.bidOf(uint256 id) → uint256

Current ETH bid for this Credit, including its score and the live rate.

Core.spendState() → (bucket, budget, spent)

ETH purchase budget and amount spent in the current bucket. A positive bid does not guarantee this bucket can buy.

CreditScoreLens.creditScore(uint256 creditId) → uint256

Credit score in ten-thousandths of a point, including for burned Credits.

Buy Credits

01

Check creditSaleOn and choose IDs from Core.pilePage. Read ControllerV1.creditPrice for each ID, then simulate the purchase with enough ETH for the total.

02

The Controller refunds excess ETH. A Credit sale emits Core.CreditSold. The return lock follows that Credit through transfers and blocks its return to any Core intake door until it expires.

ControllerV1.buyCredit(uint256 id) payable

Buy one held Credit while the Credit sale is enabled. Its price declines over the sale window.

ControllerV1.buyCredits(uint256[] ids) payable

Buy multiple pile Credits in one call. Each is priced and sold in order.

Sell Credits

01

Approve the Core to transfer each Credit. Read bidOf, then simulate the sell call against the latest block.

02

Use minOut to bound the ETH payment.

03

The return lock, reserve, and spend cap may prevent a quoted sale from executing.

04

The ETH bid's climb pauses when the booked pot cannot fund the last fill rate for 100 points plus the artist royalty.

Core.sellForEth(uint256[] ids, uint256 minOut)

Sell one or more Credits for ETH. The caller receives the bid; the artist royalty is paid on top.

Swap a Credit

01

Choose an outId from Core.pilePage and an inId you own with an equal or higher score. Approve the Core for the incoming Credit and, if swapFeeCc is nonzero, the CC fee.

02

Simulate Core.swapCredit(inId, outId). The incoming Credit takes the outgoing Credit's pile position, cost, and sale-window timestamp; the outgoing Credit goes to the caller.

Core.swapCredit(uint256 inId, uint256 outId)

Exchange an eligible owned Credit for a pile Credit and burn the configured CC fee.

Sweep a listing

01

Core.buyListing can purchase a Credit through an allowlisted adapter when the listing price and caller payment fit the bid and spend budget. Use the adapter's quote and params format for that venue.

02

Simulate the call against the current listing and bid before submitting it.

Core.buyListing(address adapter, uint256 id, bytes params)

Buy an eligible venue listing through an approved adapter.

Credit events

01

Use CreditBought, CreditSold, CreditSwapped, and ListingBought for Credit activity. Pair each log with its transaction and block.