Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/huge-boats-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@oaknetwork/contracts-sdk": patch
---

updated docs
68 changes: 30 additions & 38 deletions packages/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,11 @@ Handles fiat-style payments via a payment gateway. Manages payment creation, con

> **Two treasury variants, one SDK method.** The `paymentTreasury()` method works with both on-chain implementations:
>
>
> | Variant | Description |
> | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
> | **PaymentTreasury** | Standard payment treasury with no time restrictions. Payments can be created, confirmed, and refunded at any time while the treasury is active. |
> | **TimeConstrainedPaymentTreasury** | Time-constrained variant that enforces launch-time and deadline windows on-chain. Payments can only be created within the campaign window (launch → deadline + buffer). Refunds, withdrawals, and fee disbursements are only available after launch. |
>
>
> Both contracts share the same ABI and the same SDK interface. Time enforcement is handled entirely on-chain — simply pass the deployed contract address regardless of which variant was deployed:

```typescript
Expand Down Expand Up @@ -463,39 +461,6 @@ await ir.addItemsBatch(itemIds, items);

---

### Client convenience method

```typescript
const gp = oak.globalParams("0x...");

const [count, fee] = await oak.multicall([
() => gp.getNumberOfListedPlatforms(),
() => gp.getProtocolFeePercent(),
]);
```

### Cross-contract batching

Reads from different entities are batched into one RPC call automatically:

```typescript
const gp = oak.globalParams("0x...");
const ci = oak.campaignInfo("0x...");
const aon = oak.allOrNothingTreasury("0x...");

const [platformCount, goalAmount, raisedAmount] = await oak.multicall([
() => gp.getNumberOfListedPlatforms(),
() => ci.getGoalAmount(),
() => aon.getRaisedAmount(),
]);
```

> Under the hood, the SDK enables viem's `batch.multicall` transport option. All `readContract` calls dispatched within the same tick are automatically aggregated into a single Multicall3 on-chain call — no raw ABI descriptors needed.

> For complete multicall documentation, see: [Multicall](https://oaknetwork.org/docs/contracts-sdk/multicall).

---

## Metrics

Pre-built aggregation functions that combine multiple on-chain reads into meaningful reports. Import from `@oaknetwork/contracts-sdk/metrics`.
Expand Down Expand Up @@ -917,7 +882,6 @@ For complete guidelines on utility functions, please refer to the following link

## Exported Entry Points


| Entry point | Contents |
| ------------------------------------- | ------------------------------------------------------------------------------ |
| `@oaknetwork/contracts-sdk` | Everything — client, types, utils, errors |
Expand All @@ -927,7 +891,6 @@ For complete guidelines on utility functions, please refer to the following link
| `@oaknetwork/contracts-sdk/errors` | Error classes and `parseContractError` only |
| `@oaknetwork/contracts-sdk/metrics` | Platform, campaign, and treasury reporting helpers (not re-exported from root) |


## Multicall

Batch multiple entity read calls into a single RPC round-trip via the on-chain Multicall3 contract. Pass an array of lazy closures — the same entity read methods you'd normally `await` individually.
Expand All @@ -946,6 +909,35 @@ const [platformCount, feePercent, admin] = await multicall([
]);
```

### Client convenience method

```typescript
const gp = oak.globalParams("0x...");

const [count, fee] = await oak.multicall([
() => gp.getNumberOfListedPlatforms(),
() => gp.getProtocolFeePercent(),
]);
```

### Cross-contract batching

Reads from different entities are batched into one RPC call automatically:

```typescript
const gp = oak.globalParams("0x...");
const ci = oak.campaignInfo("0x...");
const aon = oak.allOrNothingTreasury("0x...");

const [platformCount, goalAmount, raisedAmount] = await oak.multicall([
() => gp.getNumberOfListedPlatforms(),
() => ci.getGoalAmount(),
() => aon.getRaisedAmount(),
]);
```

> Under the hood, the SDK enables viem's `batch.multicall` transport option. All `readContract` calls dispatched within the same tick are automatically aggregated into a single Multicall3 on-chain call — no raw ABI descriptors needed.

---

## Local Development & Testing
Expand Down Expand Up @@ -1029,4 +1021,4 @@ See [CLAUDE.md](../../CLAUDE.md) for coding standards including architecture pri
- [Issues](https://github.com/oak-network/sdk/issues)
- [npm](https://www.npmjs.com/package/@oaknetwork/contracts-sdk)

Questions? [Open an issue](https://github.com/oak-network/sdk/issues) or contact **[support@oaknetwork.org](mailto:support@oaknetwork.org)**
Questions? [Open an issue](https://github.com/oak-network/sdk/issues) or contact **[support@oaknetwork.org](mailto:support@oaknetwork.org)**
Loading