purchase_product
Debit buyer balance and credit merchant for product purchases using dual signatures to authorize transactions on the W3 Ledger.
Instructions
Purchase a product by debiting the sender's DAH balance and crediting the receiver (merchant). Requires dual signatures.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sender_public_key | Yes | Public key of the buyer. | |
| receiver_public_key | Yes | Public key of the merchant receiving payment. | |
| orderDetails | Yes | Order information. | |
| sender_signature | Yes | Buyer's transaction signature. | |
| receiver_signature | Yes | Merchant's co-signature for dual signing. | |
| timestamp | Yes | ISO 8601 timestamp. |
Implementation Reference
- src/tools.ts:422-425 (handler)The execution handler for the 'purchase_product' tool, which makes a POST request to the '/product-purchase' endpoint.
case 'purchase_product': { const res = await client.post('/product-purchase', args); return toResult(res.data, !res.ok); } - src/tools.ts:324-379 (schema)The schema definition for the 'purchase_product' tool, defining the required inputs like public keys, order details, and signatures.
{ name: 'purchase_product', description: 'Purchase a product by debiting the sender\'s DAH balance and crediting ' + 'the receiver (merchant). Requires dual signatures.', inputSchema: { type: 'object', properties: { sender_public_key: { type: 'string', description: 'Public key of the buyer.', }, receiver_public_key: { type: 'string', description: 'Public key of the merchant receiving payment.', }, orderDetails: { type: 'object', description: 'Order information.', properties: { totalAmount: { type: 'number', description: 'Total purchase amount.', minimum: 0.01, }, orderNumber: { type: 'string', description: 'Unique order number.', }, }, required: ['totalAmount', 'orderNumber'], }, sender_signature: { type: 'string', description: 'Buyer\'s transaction signature.', }, receiver_signature: { type: 'string', description: 'Merchant\'s co-signature for dual signing.', }, timestamp: { type: 'string', description: 'ISO 8601 timestamp.', }, }, required: [ 'sender_public_key', 'receiver_public_key', 'orderDetails', 'sender_signature', 'receiver_signature', 'timestamp', ], }, access: 'write', },