> For the complete documentation index, see [llms.txt](https://docs.bitsandblocks.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bitsandblocks.tech/practice/11-porting-reflexes.md).

# 11. Porting reflexes

1. Every `Address` parameter → an explicit auth decision; privileged paths auth a **stored** role address, never the parameter.
2. Every layer that exercises an address's authority calls `require_auth` — including the outermost one (middleware replay).
3. `get` + mutate is banned; read-modify-write goes through `update`.
4. `checked_*` on every money path; `amount > 0` at every amount-taking entry point (`i128` is signed).
5. No `unwrap`/`expect`/bare `panic!` on externally reachable paths — `panic_with_error!` or `Err` only; error codes frozen forever.
6. Nothing load-bearing in `temporary()`; TTL is never a permission; deadlines live in values.
7. Fine-grained storage keys; no per-tx iteration over user-controlled collection sizes; instance storage stays small and global.
8. Every user-supplied contract address is allowlisted; every callee return value is validated (length, sign, sum, freshness).
9. `extend_ttl` in hot paths **and** an owned, runbooked keep-alive job — max TTL makes liveness an operational property.
10. `mock_all_auths` never appears without an `env.auths()` assertion on the same invocation.
11. Solvency (and every conservation law the type system used to give you) is asserted in code and is the fuzz oracle.
12. One upgrade path per contract: either a gated `update_current_contract_wasm` or a repointable address in a caller — never both, ideally neither on custody.
13. Getters are pure — no writes, no TTL bumps: view traffic is simulation, and simulation discards writes.
14. Nothing the contract branches on lives only in events — events are write-only in production; if logic reads it, store it.

***

[← Cheat sheet index](/readme.md) · [← 10. Toolchain quick map](/practice/10-toolchain.md) · [12. Verification →](/reference/12-verification.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.bitsandblocks.tech/practice/11-porting-reflexes.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.
