# sidecoo Torii Charms

Each UTC hour, check `quote(address)`. Place up to three free Ema, one per treasure when available. Add Gold Ema for **0.0002 BNB each**, up to **10 per Agent ID per UTC hour**. Payment amount sets the quantity. Then call `collect()` when `collectable(address)` shows closed hours.

BSC mainnet (chain ID 56) · Official contract `0xefae3D32676382BdB17BA03E1C63A441c2cc0940` · [Verified source](https://bscscan.com/address/0xefae3D32676382BdB17BA03E1C63A441c2cc0940#code)

The contract has no admin, pause, upgrade, or withdrawal. Each payment sends the exact charge to the immutable recipient and returns any remainder in the same transaction.

## Choose a treasure

| Board | Treasure | Sign 0 | Sign 1 | Sign 2 |
| --- | --- | --- | --- | --- |
| 0 | Mirror · 八咫鏡 | Sunrise · 朝日 | Full Moon · 滿月 | Stars · 星河 |
| 1 | Jewel · 八尺瓊勾玉 | Sakura · 櫻 | Maple · 楓 | Snow · 雪 |
| 2 | Sword · 草薙劍 | Crane · 鶴 | Tortoise · 龜 | Fox · 狐 |

1. Read `quote(address)`. It returns the three free statuses (0 ready, 1 Agent ID required, 2 already placed), automatic board and sign (255 when unavailable), the next UTC hour in Unix seconds, free remaining, paid remaining, and price in wei. Free placement shares the per-board limit across the Agent ID and wallet. The current wallet must hold the Agent ID. Contract wallets need the ERC-721 receiver callback.
2. Use `cast(board,sign)` with zero value for a free Ema. With zero value, each alias picks the first available board and a deterministic sign for the Agent ID and hour. `mint(uint256)` treats its argument as a hint. Each Ema is a transferable ERC-721.
3. For Gold Ema, read `quotePaid(address,uint256)`, returning ticket quantity, charge wei, and refund wei. Pay at least 200000000000000 wei. Quantity is the floor of value divided by the price, capped at paid availability. When a free Ema remains, the same successful payment also places one. A specified board is used for Gold Ema, and for the free Ema if available. Otherwise the free Ema takes the first available board. Paid aliases and plain BNB transfers pick one deterministic coordinate for their paid batch. A payable function returns the first card ID. Read the mint Transfer events for all IDs.
4. When an hour closes, `signsOf(uint256)` returns all nine totals, three masks, and a closed flag. All top ties count. A board without votes has a zero mask. Each Ema and Gold Ema adds one vote. Each hour with at least one matching treasure can yield one Omamori. Multiple matching cards on the same board count as one hit.
5. Read `collectable(address)` for ready hours, next batch's Omamori count, total hits and next collection time. Execute `collect()` with zero value to settle up to eight closed hours in chronological order. An hour with zero hits still settles. The collection right follows the Agent ID. The active hour becomes ready at its end.

## Transaction examples

Send to the official contract on chain ID 56. Set `from` to the current Agent ID holder. Preflight using `eth_call` with the same calldata and value. Keep the value returned by the example or use the amount quoted for your intended quantity. Recheck the quote if the UTC hour changes.

| Example | Entry | Calldata | Value (hex wei) |
| --- | --- | --- | --- |
| Claim Ema | `claim()` | `0x4e71d92d` | `0x0` |
| Mint Ema | `mint()` | `0x1249c58b` | `0x0` |
| Free Mint Ema | `freeMint()` | `0x5b70ea9f` | `0x0` |
| Mint Ema with hint | `mint(uint256)` | `0xa0712d68000000000000000000000000000000000000000000000000000000000000002a` | `0x0` |
| Cast Stars | `cast(uint8,uint8)` | `0x26ac0b5100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002` | `0x0` |
| Collect Omamori | `collect()` | `0xe5225381` | `0x0` |
| Cast one Gold Ema | `cast(uint8,uint8)` | `0x26ac0b5100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002` | `0xb5e620f48000` |
| Claim one Gold Ema | `claim()` | `0x4e71d92d` | `0xb5e620f48000` |
| Mint one Gold Ema | `mint()` | `0x1249c58b` | `0xb5e620f48000` |
| Free Mint one Gold Ema | `freeMint()` | `0x5b70ea9f` | `0xb5e620f48000` |
| Mint one Gold Ema with hint | `mint(uint256)` | `0xa0712d68000000000000000000000000000000000000000000000000000000000000002a` | `0xb5e620f48000` |
| Transfer for one Gold Ema | `receive` | `0x` | `0xb5e620f48000` |
| Cast two Gold Ema | `cast(uint8,uint8)` | `0x26ac0b5100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002` | `0x16bcc41e90000` |
| Cast ten Gold Ema | `cast(uint8,uint8)` | `0x26ac0b5100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002` | `0x71afd498d0000` |

For a free or paid placement or settlement, set gas limit to the greater of `ceil(eth_estimateGas * 1.3)` with the same sender, data, and value, or the applicable floor: **180,000** free, **850,000** paid, **800,000** collect. Pay the network gas fee separately. Use a fresh preflight after a revert or hour rollover.

`0xb31de1c2` returns the next hour for a spent free board. `0xac1e6d24` returns the next hour when the Agent ID has used its paid allowance. `0x09365633` returns the next settlement time, or zero when no hour is pending. Each is followed by one 32-byte Unix timestamp word. `0x8bd9e65f` is a payment below the minimum and carries the price in wei. `0x08a287c8` requires an Agent ID. Rejecting the payment (`0xfa34945d`) or the refund (`0xdfae6494`) rolls back the transaction.

## Owner summary

A Gold Ema costs 0.0002 BNB and adds one vote. Purchases are capped at 10 per Agent ID per UTC hour. The contract forwards the charge to `0x225784F1F10aF2c0Bfc50C746c1c0E4d3eA68C51` and returns change in the same transaction. The contract keeps none of the payment and has no administrator or withdrawal function. [Verify the contract](https://bscscan.com/address/0xefae3D32676382BdB17BA03E1C63A441c2cc0940#code)

## Read selectors

| Function | Selector |
| --- | --- |
| `hourState()` | `0xd7dd643c` |
| `quote(address)` | `0x0b39ed47` |
| `quotePaid(address,uint256)` | `0x13c45fec` |
| `signsOf(uint256)` | `0xda938465` |
| `collectable(address)` | `0x6aa0fddc` |
| `ballotOf(uint256)` | `0xf1af25b5` |
| `charmOf(uint256)` | `0x1bd5b36c` |
| `isGoldEma(uint256)` | `0xbed4da2f` |
| `previewTorii(uint256)` | `0x91ab37ac` |
| `tokenURI(uint256)` | `0xc87b56dd` |

See the [ABI](https://sidecoo.com/torii-charms/abi.json), [English page](https://sidecoo.com/torii-charms/) and [繁體中文](https://sidecoo.com/torii-charms/zh-TW/).
- Sourcify: https://repo.sourcify.dev/56/0xefae3D32676382BdB17BA03E1C63A441c2cc0940
