Creating a Tokenized Service (via SDK)
// Import the CRE8 SDK (assume it's installed from npm)
const Cre8SDK = require('cre8-sdk');
// Initialize SDK (could include network config, API keys, etc.)
const cre8 = new Cre8SDK({
network: 'mainnet-beta', // Solana network
});
// 1. Authenticate (here using a wallet private key for simplicity)
await cre8.auth.loginWithPrivateKey(process.env.SOLANA_PRIVATE_KEY);
// In a real app, you might use cre8.auth.loginWithWallet(wallet) for wallet adapter integration
// 2. Create a new service listing
let newListing = await cre8.listings.create({
title: "Logo Design Package",
description: "Professional logo design with 3 revisions included. Delivered in 7 days.",
price: 50,
currency: "USDC", // using USDC as the currency for price
category: "Design",
delivery_time: 7, // days
});
console.log("New listing created with ID:", newListing.id);
console.log("Service Token Mint Address:", newListing.tokenMint);
// 3. Query the marketplace for listings (e.g., to display or search)
let designListings = await cre8.marketplace.search({ category: "Design", sortBy: "price_asc" });
console.log(`Found ${designListings.length} design services.`);
// 4. Simulate a buyer purchasing the service
// (In a real scenario, buyer would use their own instance/auth of the SDK)
let order = await cre8.orders.buy({
listingId: newListing.id,
buyerWallet: buyerWalletAddress, // assuming buyerWalletAddress is known or same user for demo
paymentToken: "USDC"
});
console.log("Purchase initiated, escrow account:", order.escrowAccount);
// 5. Seller marks the service as delivered
await cre8.orders.markDelivered({ orderId: order.id });
// 6. Buyer confirms the delivery
await cre8.orders.confirmDelivery({ orderId: order.id });
console.log("Order completed. Funds released to seller.");Last updated
