# sidecoo Lucky Packet

> No administrator, pause, or upgrade path. A creator can reclaim their own unclaimed principal after expiry. Successful entrants receive their share directly. A lucky prize pays the draw winner or returns to the creator if the draw expires.

- Opening-fee recipient: [`0x225784F1F10aF2c0Bfc50C746c1c0E4d3eA68C51`](https://bscscan.com/address/0x225784F1F10aF2c0Bfc50C746c1c0E4d3eA68C51)
- Network: BNB Smart Chain, chain ID 56
- Sole contract: `0x0e33C64a56F58bBCd61f42b9993C252aE87b9635`
- Verified source: https://bscscan.com/address/0x0e33C64a56F58bBCd61f42b9993C252aE87b9635#code
- Sourcify: https://repo.sourcify.dev/56/0x0e33C64a56F58bBCd61f42b9993C252aE87b9635
- Page: https://sidecoo.com/lucky-packet/

## Claim sidecoo lucky packet #N for me

1. Use the connected wallet address. Read `canClaim(id, account)` with `eth_call` and calldata `0x29a2e8e6` + the packet ID + the address, each left-padded to 64 hex digits. The first returned word is a boolean. If false, explain the reason and send nothing.
2. Read `quote(id, account)` (`0x13b0be33` plus the same words) for the current lower and upper bounds in wei. An even split returns two identical values. A lucky split can change with other claims before execution. Preview exactly one zero-value claim from the eligible wallet. Use `eth_estimateGas` from this wallet for this transaction. A claim by packet number typically uses under 250,000 gas. The wallet pays network gas.
3. Send after the user confirms the preview. No asset approval, permit, or separate message signature is needed. A wallet transaction authorizes the claim. Report the receipt hash and the `Claimed` event amount, or read `claimedOf(id, account)` (`0xfab65d16` plus the two words) for wei actually paid to that address.

| Reason | Meaning |
| --- | --- |
| 0 | Eligible |
| 1 | Packet does not exist |
| 2 | Packet has expired |
| 3 | Every share was claimed |
| 4 | The wallet or its Agent ID created the packet |
| 5 | This Agent ID already claimed this packet |
| 6 | No verified Agent ID |
| 7 | Claiming has yet to start |
| 8 | First-time claimants only |
| 9 | Asset balance requirement was not met |

For automatic discovery, call `claimable(address)` (`0x402914f5` + padded address). It scans the latest 200 packet numbers, skips packets with an asset requirement, and returns eligible IDs in ascending order. Use `canClaim(id, account)` and `claim(id)` for gated or older packets. Use `packetCount()` to discover packet numbers. For multiple named claims, preflight each and use a separate zero-value transaction per ID. Recheck reads after each successful claim because it can affect first-time eligibility.

| Entry | Ready-made calldata | Value (wei) |
| --- | --- | --- |
| claim(uint256) | `0x379607f50000000000000000000000000000000000000000000000000000000000000001` | `0` |
| claim() | `0x4e71d92d` | `0` |
| mint() | `0x1249c58b` | `0` |
| freeMint() | `0x5b70ea9f` | `0` |

The named example claims packet #1. Replace the last 32 bytes with the requested ID. A zero-argument alias chooses the first eligible packet in the discovery window. If eligibility changes before inclusion, reread `canClaim` and report the result.

## Create a packet

Any wallet can create a packet. Call `create((uint16,uint8,uint256,uint64,uint64,bool,address,uint256))` with the gross BNB as transaction value (minimum 0.001 BNB). The fields, in order, are `shares`, `mode`, `luckyPrize`, `expiry`, `startAt`, `newOnly`, `gateToken`, `gateMin`.

- Choose 1–2,000 shares and mode 0 (equal) or 1 (lucky). Set `expiry` to a Unix timestamp between 10 minutes and seven days after inclusion. `startAt` is 0 for immediate claims or a future Unix timestamp up to 48 hours ahead and before expiry.
- Use wei for gross funding and the optional lucky prize. Service fee is 3% of gross, rounded down to wei and paid at creation. Principal equals gross less the fee and optional lucky prize. The fixed share, or the lucky split's minimum of 20% of the starting average, must be at least 0.000005 BNB. The last recipient gets the principal remainder. Lucky split uses `keccak256(abi.encode(blockhash(block.number - 1), id, agentKey, claimIndex))` to choose within the quoted bounds.
- `newOnly` requires an Agent ID with zero prior claims on this contract. An asset gate reads the wallet's `balanceOf` at claim time. Use a nonzero token address and positive minimum in its raw units together, or zero for both.
- Preview the exact payable call, showing the service fee, principal, prize, timing and eligibility. Send after one wallet confirmation and read the ID from `Created`. A direct BNB transfer reverts.

## Settlement

- A full packet with a prize schedules the draw automatically. After a partial packet expires, anyone can call `settle(id)` if at least one eligible Agent ID claimed and a prize was set. The target block is 20 blocks after scheduling. Anyone can call `draw(id)` after the target block. The target is fixed. If the hash is unavailable within 8,191 blocks of the target, retry later. After 8,191 blocks (about 61 minutes), `draw(id)` marks an undrawn prize expired and emits `LuckyExpired`.
- The designated wallet claims the prize via `claimLucky(id)`, with transaction value 0. Read the winner and amount from `LuckyDrawn`.
- Only the creator can call `refund(id)`, with value 0. After packet expiry it returns unclaimed principal and any prize from a packet with zero claims. An expired draw prize is also refundable once, including when principal was refunded earlier. The 3% service fee is charged at creation.

- ABI (entries in `abi`): https://sidecoo.com/lucky-packet/abi.json
