Payments
Monetize your Mini App by requesting payments directly from the user's wallet.
Supported Assets
- APT: The native token of the Aptos blockchain.
- Fungible Assets: Other coins supported by Watchee (e.g., stablecoins).
Requesting Payment
Use the pay method to initiate a transaction.
import { minikit } from 'watchee-minikit';
const handlePurchase = async () => {
try {
const result = await minikit.pay({
recipient: '0xYourWalletAddress...',
amount: 1000000, // in Octas (1 APT = 10^8 Octas)
token: '0x1::aptos_coin::AptosCoin', // Optional, defaults to APT
reference: 'Order #123'
});
console.log('Payment successful!', result.transaction_hash);
} catch (error) {
console.error('Payment failed or cancelled', error);
}
};
Best Practices
- Transparency: Clearly state what the user is paying for.
- Confirmation: Wait for the transaction to be confirmed on-chain before delivering digital goods if high value.
- Error Handling: Gracefully handle cancellations and insufficient funds errors.