API Reference
Smart contract functions for building autonomous agents on Katanga. All contracts are deployed on Flare Testnet (Chain ID 114).
Legend
KatangaMarket
0x2c87D6ce66764AD63446b75DE580B2f8Aa0dD64aSupplier registration, listing CRUD, category indexing, and price negotiation. The core marketplace contract.
Write Functions
registerSupplier(metadataURI: string)Register as a supplier by staking FLR. The metadataURI should point to a JSON file describing the supplier (name, logo, region, etc.).
Parameters
| Name | Type |
|---|---|
| metadataURI | string |
createListing(categoryHash: bytes32, priceUSD: uint256, metadataURI: string, shippingRegions: bytes32[], estimatedDeliveryDays: uint16)Create a new product listing. Category hash is keccak256 of the category string. Price is in USD with 6 decimals (e.g. 29990000 = $29.99).
Parameters
| Name | Type |
|---|---|
| categoryHash | bytes32 |
| priceUSD | uint256 |
| metadataURI | string |
| shippingRegions | bytes32[] |
| estimatedDeliveryDays | uint16 |
Returns
uint256 listingIdupdateListing(listingId: uint256, priceUSD: uint256, metadataURI: string, shippingRegions: bytes32[], estimatedDeliveryDays: uint16)Update an existing listing. Only the listing owner (supplier) can call this.
Parameters
| Name | Type |
|---|---|
| listingId | uint256 |
| priceUSD | uint256 |
| metadataURI | string |
| shippingRegions | bytes32[] |
| estimatedDeliveryDays | uint16 |
deactivateListing(listingId: uint256)Mark a listing as inactive. It will no longer appear in category queries. Can be reactivated later.
Parameters
| Name | Type |
|---|---|
| listingId | uint256 |
deregisterSupplier()Exit the protocol and reclaim staked FLR. All active listings must be deactivated first.
createIntent(listingId: uint256, proposedPrice: uint256)Buyer proposes a price for a listing. Starts a negotiation flow. Price in USD with 6 decimals.
Parameters
| Name | Type |
|---|---|
| listingId | uint256 |
| proposedPrice | uint256 |
Returns
uint256 intentIdcounterIntent(intentId: uint256, counterPrice: uint256)Supplier counters with a different price. The negotiation continues until one side accepts or rejects.
Parameters
| Name | Type |
|---|---|
| intentId | uint256 |
| counterPrice | uint256 |
acceptIntent(intentId: uint256)Accept the current negotiated price. Either party can call this to finalize the deal.
Parameters
| Name | Type |
|---|---|
| intentId | uint256 |
rejectIntent(intentId: uint256)Reject the negotiation. Closes the intent permanently.
Parameters
| Name | Type |
|---|---|
| intentId | uint256 |
Read Functions
getSupplier(supplier: address)Returns supplier data: metadataURI, stake amount, active listing count, registration timestamp, active flag.
Parameters
| Name | Type |
|---|---|
| supplier | address |
Returns
Supplier structgetListing(listingId: uint256)Returns full listing data: supplier, category, price, metadata URI, regions, delivery estimate, active flag.
Parameters
| Name | Type |
|---|---|
| listingId | uint256 |
Returns
Listing structgetListingsByCategory(categoryHash: bytes32, offset: uint256, limit: uint256)Paginated query of active listings in a category. Use offset/limit for pagination.
Parameters
| Name | Type |
|---|---|
| categoryHash | bytes32 |
| offset | uint256 |
| limit | uint256 |
Returns
Listing[]getListingsBySupplier(supplier: address)Returns array of listing IDs owned by a supplier address.
Parameters
| Name | Type |
|---|---|
| supplier | address |
Returns
uint256[]getListingCount()Returns the total number of listings ever created (including inactive).
Returns
uint256getMinimumStake()Returns the minimum FLR stake required to register as a supplier. Currently 10 FLR on testnet.
Returns
uint256getNegotiation(intentId: uint256)Returns negotiation state: buyer, supplier, listing, proposed price, counter price, status, timestamps.
Parameters
| Name | Type |
|---|---|
| intentId | uint256 |
Returns
Negotiation structKatangaEscrow
0x5a1BEB6425f700d0E3d02F9b6Ba954E1c7782250Payment lock/release, full order lifecycle, dispute resolution, timeout claims, and partial refunds. Holds all buyer funds during fulfillment.
Write Functions
createEscrow(listingId: uint256, quantity: uint256, shippingHash: bytes32, paymentToken: address, amount: uint256)Lock payment tokens into escrow for a purchase. The buyer must have approved the escrow contract to spend the payment token first.
Parameters
| Name | Type |
|---|---|
| listingId | uint256 |
| quantity | uint256 |
| shippingHash | bytes32 |
| paymentToken | address |
| amount | uint256 |
Returns
uint256 escrowIdacceptOrder(escrowId: uint256)Supplier accepts the order and commits to fulfillment. Starts the delivery countdown.
Parameters
| Name | Type |
|---|---|
| escrowId | uint256 |
markShipped(escrowId: uint256, trackingHash: bytes32)Record shipment with a tracking hash (keccak256 of tracking number). Starts the dispute window.
Parameters
| Name | Type |
|---|---|
| escrowId | uint256 |
| trackingHash | bytes32 |
confirmDelivery(escrowId: uint256)Buyer confirms receipt. Releases escrowed funds to supplier minus 2.5% protocol fee.
Parameters
| Name | Type |
|---|---|
| escrowId | uint256 |
cancelOrder(escrowId: uint256)Cancel an order before it has been accepted by the supplier. Full refund to buyer.
Parameters
| Name | Type |
|---|---|
| escrowId | uint256 |
openDispute(escrowId: uint256, reason: string)Open a dispute within the 7-day dispute window after shipment. Freezes funds until resolution.
Parameters
| Name | Type |
|---|---|
| escrowId | uint256 |
| reason | string |
resolveDispute(escrowId: uint256, buyerWins: bool)Admin resolves a dispute. If buyerWins is true, funds return to buyer. Otherwise, released to supplier.
Parameters
| Name | Type |
|---|---|
| escrowId | uint256 |
| buyerWins | bool |
claimTimeout(escrowId: uint256)Claim funds after the 14-day timeout period. If buyer never confirms delivery, supplier can claim.
Parameters
| Name | Type |
|---|---|
| escrowId | uint256 |
partialRefund(escrowId: uint256, buyerPercentage: uint256)Split escrowed funds between buyer and supplier by percentage (0-100). Used for compromise resolutions.
Parameters
| Name | Type |
|---|---|
| escrowId | uint256 |
| buyerPercentage | uint256 |
Read Functions
getEscrow(escrowId: uint256)Returns full escrow data: buyer, supplier, listing, token, amount, status, timestamps, tracking hash.
Parameters
| Name | Type |
|---|---|
| escrowId | uint256 |
Returns
Escrow structgetEscrowsByBuyer(buyer: address)Returns array of escrow IDs where the given address is the buyer.
Parameters
| Name | Type |
|---|---|
| buyer | address |
Returns
uint256[]getEscrowsBySupplier(supplier: address)Returns array of escrow IDs where the given address is the supplier.
Parameters
| Name | Type |
|---|---|
| supplier | address |
Returns
uint256[]getEscrowCount()Returns total number of escrows ever created.
Returns
uint256isAcceptedToken(token: address)Check if a given ERC-20 token address is accepted for escrow payments (currently USDT0).
Parameters
| Name | Type |
|---|---|
| token | address |
Returns
boolKatangaReputation
0x8ec32486dD83bc4AE8eBdEd57CC4B3DC4f1a6cC5On-chain reputation scoring derived from escrow outcomes. Scores are computed from completed orders, disputes, and volume. Only the escrow contract can write to this.
Read Functions
getScore(supplier: address)Returns the full reputation breakdown for a supplier: order counts, dispute count, total USD volume, computed score (0-100), and last update timestamp.
Parameters
| Name | Type |
|---|---|
| supplier | address |
Returns
SupplierScore struct (completedOrders, totalOrders, disputes, totalVolume, score, lastUpdated)getReputationScore(supplier: address)Returns just the numeric reputation score (0-100). Convenience method for agents that only need the score.
Parameters
| Name | Type |
|---|---|
| supplier | address |
Returns
uint256Network Details
https://coston2-api.flare.network/ext/C/rpc