import { OumlaSdkApiClient, OumlaSdkApiEnvironment } from '@oumla/sdk';
const client = new OumlaSdkApiClient({
environment: OumlaSdkApiEnvironment.Sandbox,
apiKey: 'your-api-key'
});
async function tokenizationWorkflow() {
// Create collection
const collection = await client.tokenization.createCollection({
addressId: 'address-id',
type: 'NON_FUNGIBLE_TOKEN',
clientShare: process.env.CLIENT_SHARE!,
network: 'ETHEREUM',
displayName: 'My NFT Collection',
createParams: {
initializeParams: [
{ name: '_name', type: 'string', value: 'My NFT Collection' },
{ name: '_symbol', type: 'string', value: 'MNFT' },
{ name: 'defaultAdmin', type: 'address', value: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb' },
{ name: 'minter', type: 'address', value: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb' },
{ name: 'pauser', type: 'address', value: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb' }
]
}
});
// Check workflow status
let status;
do {
status = await client.temporal.getWorkflowStatus(collection.data.workflowId!);
await new Promise(resolve => setTimeout(resolve, 2000));
} while (status.data.status === 'RUNNING');
if (status.data.status === 'COMPLETED') {
// Get collection ID from workflow result (implementation-specific)
const collectionId = 'collection-id'; // Retrieved from workflow result
// Mint token
const mintResult = await client.tokenization.mintToken(collectionId, {
addressId: 'address-id',
clientShare: process.env.CLIENT_SHARE!,
to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
metadata: {
name: 'My First NFT',
image: 'https://example.com/image.png'
}
});
console.log('Token minted:', mintResult.data.mint?.workflowId);
}
}