const result = await client.store(
{
collection: 'posts',
data: [{ title: 'Hello', content: 'World' }]
},
// Payment callback - invoked when server returns 402
async (quote) => {
console.log('Payment required:', quote.totalCostTia, 'TIA');
console.log('Pay to:', quote.brokerAddress);
console.log('Quote expires:', new Date(quote.expiresAt * 1000));
// Execute payment via wallet
const txHash = await wallet.sendTokens(
quote.brokerAddress,
quote.totalCostTia
);
return {
txHash: txHash,
network: 'mocha-4' // or 'celestia' for mainnet
};
},
true // waitForConfirmation
);