# sidecoo Pattern Loom

The ERC-721 contract has no admin, pause, upgrade or withdrawal function. Unit price, registry, payment recipient and purchase limits are fixed. Artwork and metadata are stored on-chain.

- Network: BNB Smart Chain mainnet, chain ID `56`
- Sole contract: `0xd186A142E477fe26786Cc68AE13Fd5466d1A645A`
- Verified source: [BscScan](https://bscscan.com/address/0xd186A142E477fe26786Cc68AE13Fd5466d1A645A#code)
- Sourcify: https://repo.sourcify.dev/56/0xd186A142E477fe26786Cc68AE13Fd5466d1A645A
- Official site: [Pattern Loom](https://sidecoo.com/pattern-loom/)
- Fixed payment recipient: `0x225784F1F10aF2c0Bfc50C746c1c0E4d3eA68C51`
- Agent ID registry: `0x60B9262456dE011F7d15a54CdD8c48bAaa8B022F`

## Claim or collect

1. Use the user's own sending address. Check chain ID, exact destination and verified source. Call `quote(sender, valueWei)` with the intended value.
2. For a swatch, send value `0` only when `status == 0` and `freeEligible == true`. One free swatch is available per verified Agent ID per UTC day while that ID's daily entitlement remains. Stop and report the status if the zero-value quote is ineligible.
3. For weaves, `quoteAmount(quantity)` returns the nominal value for 1–10. Each weave costs `220000000000000 wei` (0.00022 BNB). Any wallet may buy. Direct BNB transfers with empty calldata settle like `mint()`. A nonzero value, including on `freeMint()`, buys as many whole weaves as the payment, remaining wallet allowance and daily stock cover. The contract also issues a swatch if the verified Agent ID still has today's entitlement. It forwards the sale price to the fixed recipient and returns unused BNB to the sending wallet in the same transaction. There are 250 paid weaves per UTC day and at most 10 per paying wallet each day. UTC resets at 08:00 Taipei time. The day of inclusion determines the edition.
4. Simulate with `eth_call` using the exact sender, destination, calldata and value. For a function call, compare the returned items with the quote. A successful direct transfer simulation returns `0x`. Use the quote for expected items and check the purchase and swatch events in the receipt. Estimate gas for the same transaction. Show the network, contract, fixed recipient, items, value, sale amount, change, estimated gas and permission changes (none). Ask the user to confirm before sending, including when value is zero. No approval, permit, signing message or additional transfer is required.
5. If the quote or simulation changes before sending, refresh the preview and get confirmation again. Report a successful receipt and confirm NFT IDs using the contract's ERC-721 `Transfer` events from the zero address to the sender. Use `status == 1` for a successful transaction receipt. See [permissions](https://sidecoo.com/permissions/#pattern-loom) and [rules and risk information](https://sidecoo.com/rules/).

For a direct BNB transfer, use your own wallet and the gas limit from `eth_estimateGas`. A 21,000-gas transfer or exchange withdrawal will fail.

## Exact calldata and value

These examples assume an eligible Agent ID with today's swatch entitlement and sufficient paid stock and wallet allowance. Each example starts from that state.

| Example | Calldata | Value (wei) | Swatches | Weaves | Sale (wei) | Change (wei) |
| --- | --- | --- | --- | --- | --- | --- |
| Swatch | `0x1249c58b` | `0` | 1 | 0 | `0` | `0` |
| One-weave | `0x1249c58b` | `220000000000000` | 1 | 1 | `220000000000000` | `0` |
| Two-weaves | `0xa0712d680000000000000000000000000000000000000000000000000000000000000002` | `500000000000000` | 1 | 2 | `440000000000000` | `60000000000000` |
| Direct-transfer | `0x` | `500000000000000` | 1 | 2 | `440000000000000` | `60000000000000` |

The first two calls use `mint()`. The third uses `mint(2)` with 0.0005 BNB and returns 0.00006 BNB. The quantity argument is a hint. A paid order still works with zero swatches when today's swatch is already issued or Agent ID eligibility cannot be verified.

Direct transfer example / 直接轉帳範例

For a direct BNB transfer, use your own wallet and the gas limit from `eth_estimateGas`. A 21,000-gas transfer or exchange withdrawal will fail.

直接轉 BNB 時請用自己的錢包，gas 上限依 `eth_estimateGas`。只給 21,000 gas 的轉帳與交易所提領會失敗。

- `to` = `0xd186A142E477fe26786Cc68AE13Fd5466d1A645A`
- `value` = `500000000000000` wei (0.0005 BNB)
- `data` = `0x` (empty / 留空)

直接轉 BNB 到合約與呼叫 `mint()` 一樣，都依付款金額與剩餘額度成交，多付金額同筆退回。庫存與錢包額度足夠時，此範例取得兩張織圖並退回 0.00006 BNB。

直接轉 BNB 時請用自己的錢包，gas 上限依 `eth_estimateGas`。只給 21,000 gas 的轉帳與交易所提領會失敗。

## ABI

Product ABI in human-readable form. The [complete ABI in JSON](https://sidecoo.com/pattern-loom/abi.json) uses the `abi` field and includes ERC-165, ERC-721 and ERC-721 Metadata.

```text
receive() external payable
function mint() payable returns (uint256 swatchTokenId, uint256 weaveQuantity)
function mint(uint256 requestedQuantity) payable returns (uint256 swatchTokenId, uint256 weaveQuantity)
function claim() payable returns (uint256 swatchTokenId, uint256 weaveQuantity)
function freeMint() payable returns (uint256 swatchTokenId, uint256 weaveQuantity)
function quoteAmount(uint256 quantity) pure returns (uint256 valueWei)
function quote(address wallet, uint256 valueWei) view returns (uint256 day, bool freeEligible, uint256 weaveQuantity, uint256 paidWei, uint256 refundedWei, uint8 status)
function currentDay() view returns (uint256)
function agentIdRegistry() view returns (address)
function paymentRecipient() view returns (address)
function unitPriceWei() view returns (uint256)
function freeAgentDailyLimit() view returns (uint256)
function paidDailyStock() view returns (uint256)
function paidWalletDailyLimit() view returns (uint256)
function paidStockRemaining() view returns (uint256)
function paidWalletRemaining(address wallet) view returns (uint256)
function swatchesIssuedToday() view returns (uint256)
function previewArt(uint256 day, bool weave, uint256 serial) pure returns (string)
function website() view returns (string)
event PatternLoomSwatchIssued(address indexed collector, uint256 indexed day, uint256 indexed tokenId)
event PatternLoomWeavePurchased(address indexed collector, uint256 indexed day, uint256 quantity, uint256 paidWei, uint256 refundedWei)
error PatternLoomAgentIdRequired()
error PatternLoomSwatchAlreadyIssued(uint256 day)
error PatternLoomPaymentTooSmall(uint256 suppliedWei, uint256 requiredWei)
error PatternLoomWalletLimitReached(uint256 day)
error PatternLoomWeaveSoldOut(uint256 day)
error PatternLoomInvalidQuoteQuantity(uint256 quantity)
error PatternLoomPaymentFailed()
error PatternLoomRefundFailed()
error PatternLoomInvalidPreview()
error PatternLoomInvalidDeployment()
```

Quote statuses are `0 Ready`, `1 AgentIdRequired`, `2 SwatchAlreadyIssued`, `3 PaymentTooSmall`, `4 WalletLimitReached` and `5 WeaveSoldOut`. A failed paid quote retains the free entitlement and returns zero weaves, proceeds and change. A swatch can still be claimed separately if eligible. Sold-out and wallet-limit statuses reset at the next UTC day. Receiver, payment or refund failure and calls with unrecognized calldata revert atomically.

## Copy into an agent

> On BNB Smart Chain (56), verify the sole Pattern Loom contract `0xd186A142E477fe26786Cc68AE13Fd5466d1A645A`. From my address, quote `220000000000000` wei and simulate `mint()` (calldata `0x1249c58b`) with that value. Preview the weave, any available daily swatch, contract, fixed recipient, charge, change, gas and any permission changes. Wait for my confirmation before sending. For my daily swatch only, quote and simulate the same calldata at value 0 and stop if the quote is ineligible.
