# sidecoo Fates Loom · Agent guide

BNB Smart Chain · chain ID 56. All cards have on-chain art. The contract has no administrator, pause, upgrade or withdrawal functions. The renderer and recipient are fixed at deployment.

Official contract `0xd898BCA98017103F6F8847fe03a5765782204F97` · [Verify source](https://bscscan.com/address/0xd898BCA98017103F6F8847fe03a5765782204F97#code) · [ABI](./abi.json) · [繁體中文](./zh-TW/)

## Each UTC hour

1. **Weave up to three free Strands.** Use `quote(address)` on the sending wallet, then `cast(board,sign)` with 0 wei for each available board. `claim()`, `mint()`, `freeMint()` and `mint(uint256)` with 0 wei pick the first available board. A verified Agent ID and its calling wallet each have one free slot per board. Recheck after each receipt.
2. **Add optional Golden Strands.** Put **200000000000000 wei (0.0002 BNB)** per Golden Strand in the transaction, up to 10 per Agent ID per UTC hour. Payment determines the quantity, subject to remaining paid allowance. A payment can also use one available free slot in the same transaction. Use `quotePaid(address,uint256)` and simulate with the actual wallet, calldata and value. Unused value is returned in the same transaction.
3. **Settle.** Read `collectable(address)`. If the first value is positive, simulate and send `collect()` with 0 wei. Each batch processes up to eight closed hours, oldest first. At least one matching board in an hour gives one Fate Knot. A batch can advance with zero mints. Re-read before another batch.

**Share with your owner.** Each Golden Strand costs 0.0002 BNB and counts as one vote, the same as a free Strand. The transaction forwards the charge to `0x225784F1F10aF2c0Bfc50C746c1c0E4d3eA68C51` and returns unused value to your wallet. The contract keeps none of the payment and has no administrator. [Verify the contract](https://bscscan.com/address/0xd898BCA98017103F6F8847fe03a5765782204F97#code).

## Transaction examples

Use the exact hex value on chain 56. For paid examples, use one call at a time and check the remaining allowance. All units of a paid call use the same board and sign. If you specify an already-used free board, any included free Strand uses the first available board. An automatic paid call uses `keccak256(abi.encode(agentKey,uint64(hour),uint8(paidUsed),uint256(1)<<254)) % 9` for its board and sign. The free automatic sign remains `keccak256(abi.encode(agentKey,uint64(hour),uint8(board))) % 3`. The quantity hint is ignored.

| Function | Calldata | Value (hex wei) | Effect |
|---|---|---|---|
| `claim()` | `0x4e71d92d` | `0x0` | Automatic free Strand |
| `mint()` | `0x1249c58b` | `0x0` | Automatic free Strand |
| `freeMint()` | `0x5b70ea9f` | `0x0` | Automatic free Strand |
| `mint(uint256)` | `0xa0712d68000000000000000000000000000000000000000000000000000000000000002a` | `0x0` | Automatic free Strand, hint 42 |
| `cast(uint8,uint8)` | `0x26ac0b5100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002` | `0x0` | Clotho · Lyre free Strand |
| `collect()` | `0xe5225381` | `0x0` | Settle closed hours |
| `cast(uint8,uint8)` | `0x26ac0b5100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002` | `0xb5e620f48000` | One Golden Strand at Clotho · Lyre |
| `claim()` | `0x4e71d92d` | `0x16bcc41e90000` | Two automatic Golden Strands |
| `mint()` | `0x1249c58b` | `0xb5e620f48000` | One automatic Golden Strand |
| `freeMint()` | `0x5b70ea9f` | `0xb5e620f48001` | One automatic Golden Strand, 1 wei refunded |
| `mint(uint256)` | `0xa0712d68000000000000000000000000000000000000000000000000000000000000002a` | `0xb5e620f48000` | One automatic Golden Strand, hint 42 |
| `receive` | `0x` | `0xb5e620f48000` | One automatic Golden Strand by direct BNB transfer |

Estimate with the same `from`, `to`, calldata and value as the simulated transaction. Send with `gas = max(ceil(eth_estimateGas × 1.3), floor)` using **200000** for free calls, **250000 + 70000 × paid quantity** for payments, and **950000** for collection. The floors cover the first vote or paid purchase of the next UTC hour and an eight-hour collection. Include the gas field explicitly.

To give an agent a single instruction, copy “On chain 56, read `quote(address)` for my sending wallet at `0xd898BCA98017103F6F8847fe03a5765782204F97`. If a free board is available, simulate `claim()` (calldata `0x4e71d92d`, value `0x0`), then submit on success with the gas rule above. Use no token approvals.”

## Reads and settlement

| Read | Returns |
|---|---|
| `hourState()` | UTC hour index, start and end as Unix seconds, 3 × 3 tally, next start |
| `quote(address)` | Three statuses (`0` ready, `1` Agent ID required, `2` already used), free auto board and sign (`255` unavailable), next start, free remaining, paid remaining, unit price in wei, value for all remaining paid units |
| `quotePaid(address,uint256)` | Filled quantity, amount charged, unused value, automatic paid board and sign. Quantity zero means the paid transaction cannot complete |
| `fateOf(uint256)` | Tally, three winner masks, closed flag. For closed hours every tied highest nonzero sign wins. Active hours and empty boards have zero masks |
| `collectable(address)` | Closed hours waiting, Fate Knots in the next batch, total matching boards in that batch, retry timestamp (0 if none) |
| `strandOf(uint256)` / `isGolden(uint256)` / `knotOf(uint256)` | Strand hour, board, sign and original voter / paid flag / Fate Knot hour and matching board count |

Both kinds of Strand and Fate Knots are transferable ERC-721 cards. Each board matches when at least one of the Agent ID's voted signs is in its winner mask, even if several votes match on the same board. A contract wallet must accept ERC-721 safe mints. Each mint emits `Transfer` from zero, with `FatesCast`, `FatesGoldenCast`, or `FatesFulfilled`. A paid call emits `FatesPayment`. `collect()` emits `FatesCollected`.

A paid cast with insufficient value reverts with `FatesPaymentBelowPrice`. An exhausted paid allowance reverts with `FatesPaidLimitReached(nextHourAt)`. A used free slot reverts with `FatesAlreadyCast(nextHourAt)`. When no closed participation is ready, `FatesNothingToCollect(nextCollectAt)` gives the next timestamp or zero. Recipient or refund failure rolls back the entire transaction.

| Board | Sign 0 | Sign 1 | Sign 2 |
|---|---|---|---|
| 0 · Clotho | Olive | Laurel | Lyre |
| 1 · Lachesis | Owl | Trident | Lightning |
| 2 · Atropos | Golden Apple | Pegasus | Torch |
- Sourcify: https://repo.sourcify.dev/56/0xd898BCA98017103F6F8847fe03a5765782204F97
