@quantabit/redpacket-sdk
v1.0.2
Published
QuantaBit Red Packet SDK - Normal/lucky draw red packet distribution and claiming
Maintainers
Readme
@quantabit/redpacket-sdk
QuantaBit Red Packet System SDK - Normal/lucky draw red packet distribution and claiming features
📦 Installation
npm install @quantabit/redpacket-sdk
# or
yarn add @quantabit/redpacket-sdk🚀 Quick Start
1. Setup Provider
import { RedPacketProvider } from "@quantabit/redpacket-sdk";
import "@quantabit/redpacket-sdk/styles.css";
function App() {
return (
<RedPacketProvider
apiUrl="https://api.example.com/v1"
token="your-auth-token"
language="en"
onClaim={(result) => console.log("Claim successful:", result)}
>
<YourComponent />
</RedPacketProvider>
);
}2. Using Components
import { RedPacketCard, SendRedPacket } from '@quantabit/redpacket-sdk';
// Red packet card (can open to claim)
<RedPacketCard
redPacket={redPacketData}
onClaimSuccess={(prize) => console.log('Received:', prize)}
showDetail
/>
// Send red packet form
<SendRedPacket
currency="POINTS"
onSuccess={(result) => console.log('Sent successfully:', result)}
onCancel={() => setShowForm(false)}
/>3. Using Hooks
import { useRedPacket } from "@quantabit/redpacket-sdk";
function MyComponent() {
const {
sentList, // Sent red packets
receivedList, // Received red packets
stats, // Statistics
loading,
send, // Send red packet
claim, // Claim red packet
loadSentList, // Load sent records
loadReceivedList, // Load received records
} = useRedPacket();
return <div>...</div>;
}📚 Components
| Component | Description |
| --------------- | ----------------------------------------------------------- |
| RedPacketCard | Red packet card (coin animation, open button, claim result) |
| SendRedPacket | Send red packet form (type, amount, message) |
📖 Type Definitions
import { RedPacketType, RedPacketStatus } from "@quantabit/redpacket-sdk";
// Red packet types
RedPacketType.NORMAL; // Normal (split equally)
RedPacketType.LUCKY; // Lucky draw
RedPacketType.EXCLUSIVE; // Exclusive
RedPacketType.GROUP; // Group
// Red packet status
RedPacketStatus.PENDING; // Pending claim
RedPacketStatus.PARTIAL; // Partially claimed
RedPacketStatus.FINISHED; // Fully claimed
RedPacketStatus.EXPIRED; // Expired📄 License
MIT License
🌐 Brand & Links
- Official Mainnet: QuantaBit Chain
- Developer Platform: Developer Platform
- Open Platform: Open Platform
- Payment Platform: Pay Platform
- Feedback: Feedback
