import { SpaceportSDK } from '@spaceport/sdk'
async function productManagementExamples() {
// Initialize SDK with a wallet and API key
const sdk = SpaceportSDK.createWithAccount(account, {
chain: 'devnet',
apiKey: process.env.SDK_API_KEY,
})
// Get current user
const currentUser = await sdk.users.getCurrentUser()
// Generate delegated attestation signatures for product creation
const delegatedAttestationParams = await sdk.products.generateDelegatedAttestationSignatures(2) // For 2 products
// Create products from agreement assets
const productResult = await sdk.products.create({
robloxAssetId: '123456789', // Roblox asset ID
agreementId: 'e5a654c3-a5c9-4651-9c93-d0e947154a1a', // Agreement ID from your database
productDetails: [
{
assetId: 'asset-uuid-1', // Asset ID from the agreement
title: 'My Awesome Product',
description: 'A product created from a signed agreement',
},
{
assetId: 'asset-uuid-2', // Another asset ID from the agreement
title: 'Another Great Product',
description: 'Second product from the same agreement',
},
],
delegatedAttestationParams, // Signatures generated above
})
console.log('Product creation result:', productResult)
if (productResult.success) {
console.log('🎉 Products created successfully!')
}
}