> For the complete documentation index, see [llms.txt](https://docs.bloxchain.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bloxchain.app/developers/sdk-core-patterns.md).

# SDK core patterns

Common integration patterns for **@bloxchain/sdk** with governed Account contracts.

## Read state

* Use `PublicClient` to call view functions on SecureOwnable, RuntimeRBAC, GuardController wrappers.
* Query `TxRecord` status and open operations via EngineBlox helpers.
* Pin ABIs from `@bloxchain/contracts` to your Protocol release.

See [API reference](/protocol/api-reference.md).

## Write transactions (time-lock path)

Typical sequence:

1. **Request** — create `PENDING` record (wallet with request permission).
2. **Wait** — until `releaseTime` if policy requires timelock.
3. **Approve** — authorized wallet moves toward `EXECUTING`.
4. **Execute** — guarded call completes → `COMPLETED` or `FAILED`.

Always wait for transaction receipts before assuming state changed.

## Meta-transactions

1. Build EIP-712 typed data per protocol domain.
2. Approver signs off-chain (`walletClient.signTypedData` or hardware signer).
3. Broadcaster submits via SDK meta-tx helpers with correct nonce.

See [Meta-transactions](/protocol/meta-transactions.md).

Platform UI flow: [Meta-transactions](/platform-bloxchain.app/overview/approve-and-sign.md)

## Errors

* Parse custom errors from `SharedValidation` and component libraries when possible.
* On `FAILED` TxRecords, read revert data from the execution transaction.
* Do not retry blindly—confirm policy, allowlists, and role assignment.

## Retries

* Safe to retry **reads** and **simulations**.
* For **writes**, re-simulate after failures; avoid duplicate requests that create multiple `PENDING` records unless intended.
* Respect timelock: approving before `releaseTime` will revert.

## Version alignment

`@bloxchain/sdk`, `@bloxchain/contracts`, and deployed bytecode must match the same Protocol release. See [Releases and compatibility](/resources/releases.md).

## Next steps

* [Examples](/developers/sdk-examples.md)
* [Best practices](/protocol/best-practices.md)
* [Core concepts](/introduction/protocol-basics.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.bloxchain.app/developers/sdk-core-patterns.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
