Author: Christopher Perceptions Powered by: NoCodeClarity v2
sBay is a decentralized marketplace that allows users to buy and sell digital goods using STX tokens. The platform charges a configurable fee on every sale, which is automatically transferred to the platform owner. It is designed for transparency, security, and operates fully on the Stacks blockchain using Clarity smart contracts.
- platform-owner: The principal of the contract owner.
- platform-fee: Configurable fee represented in basis points (default 100 = 1%).
- ERR_UNAUTHORIZED (u100): Error when an unauthorized user attempts an action.
- ERR_NOT_FOUND (u101): Error when the listing is not found.
- ERR_INVALID_STATUS (u102): Error when trying to interact with a listing in an invalid status.
- ERR_EXPIRED (u103): Error when trying to purchase an expired listing.
- ERR_INSUFFICIENT_FUNDS (u104): Error when the buyer does not provide enough STX.
- ERR_INVALID_FEE (u105): Error when trying to set an invalid platform fee.
- next-listing-id: A unique, auto-incrementing ID for each listing.
- platform-balance: The total balance of platform fees collected.
- platform-fee: The current platform fee in basis points.
- listings: Stores listing details including seller, price, token type, status, expiry, and buyer.
-
list-item
- Creates a new listing for a digital good.
- Parameters:
price
(uint): The sale price of the item.token
(principal): The token used for payment (currently only STX).expiry
(uint): Optional expiry block height for the listing.
- Returns: The ID of the newly created listing.
-
buy-item
- Allows a user to purchase an item.
- Parameters:
listing-id
(uint): The ID of the listing to purchase.
- Returns: Success (
ok true
) or an error if the purchase fails.
-
cancel-listing
- Allows a seller to cancel their listing.
- Parameters:
listing-id
(uint): The ID of the listing to cancel.
- Returns: Success (
ok true
) or an error if the cancellation fails.
-
withdraw-fees
- Allows the platform owner to withdraw the collected platform fees.
- Returns: The withdrawn amount or an error if the user is unauthorized.
-
update-platform-fee
- Allows the platform owner to update the platform fee.
- Parameters:
new-fee
(uint): The new fee in basis points.
- Returns: Success (
ok true
) or an error if the update fails.
-
get-listing
- Retrieves the details of a specific listing.
- Parameters:
listing-id
(uint): The ID of the listing to retrieve.
- Returns: The listing details or
none
if the listing does not exist.
-
get-platform-balance
- Retrieves the current platform balance.
- Returns: The current platform balance.
-
get-platform-fee
- Retrieves the current platform fee.
- Returns: The current platform fee in basis points.
- Ensure that the platform owner's principal is correctly set to enable withdrawal operations.
- Listings may expire if the seller sets a block height expiration, automatically preventing the item from being sold after that point.
- Platform fees are automatically deducted from each sale and stored in the contract.
- The contract includes a trait definition for potential integration with SIP-009 compliant NFTs.
- This contract is generated by NoCodeClarity v2 and has NOT undergone a formal audit. Use at your own risk.
- The platform fee is configurable by the platform owner, allowing for flexible fee adjustments.
- All transactions are executed on-chain, ensuring transparency and security.
- Users should be aware of the current platform fee before listing or purchasing items.
- MIT