Lab results
The lab sections below were run in our own sandbox; the last section is a read of mainnet. The error strings are what the node returned, copied verbatim from docs/NEAR-FACTS.md. Anything not listed here is not assumed.
Setup and scope
| Item | Value |
|---|---|
| Sandbox | near-sandbox 0.4.0 |
| Node | nearcore 2.14.0 |
| Protocol version | protocol 88 |
| Topology | single-shard, root account sandbox (parent.test.near becomes parent.sandbox) |
Older model. The access-key rows were tested with gas keys on sub-accounts. The product now uses classic function-call keys on a contract account. The permission semantics are expected to carry over, but tests T5 to T9 are owed before relying on them. Testnet may also behave differently from the lab.
What is impossible
| Impossible | Why |
|---|---|
| A contract reading another account's code_hash, state or access keys | No host function exists. near-sys offers own-account storage, promises, crypto, validators. |
| A contract calling RPC | The runtime provides no such path. |
| A cross-contract call reading raw state | It can invoke methods only. |
| Guaranteeing the target's code at execution time by checking beforehand | TOCTOU window of at least 3 blocks. |
| Trusting a target to report its own code identity | Malicious code can return a false value. |
What a function-call key can and cannot do
| Action | Result | Exact error | On chain |
|---|---|---|---|
| Transfer NEAR | rejected | RequiresFullAccess | no |
| AddKey on itself | rejected | RequiresFullAccess | no |
| DeployContract on itself | rejected | RequiresFullAccess | no |
| FunctionCall to another contract | rejected | ReceiverMismatch { ak_receiver: gate.sandbox } | no |
| FunctionCall to a method outside the list | rejected | MethodNameMismatch { method_name: "other" } | no |
| Parent AddKey, Deploy or DeleteAccount on a sub-account | rejected | ActorNoPermission { actor_id: parent.sandbox } | yes |
| FunctionCall with a 1 yocto deposit | rejected | DepositWithFunctionCall | no |
The first five rows are rejected by the node at validation, so their transaction hashes never reach the chain and cannot be looked up in an explorer. Only the parent case leaves an on-chain trace. Evidence is a re-runnable script that prints the RPC errors.
A restricted key cannot attach a deposit at all, and NEP-141 requires exactly 1 yoctoNEAR for ft_transfer and ft_transfer_call. With deposit 0 the contract panics: Requires attached deposit of exactly 1 yoctoNEAR. So an agent structurally cannot move NEP-141 tokens itself, and a vault holding pre-funded assets is the only possible architecture.
Immutability needs three checks
- 1code referenced by hash (not local, not global-by-account)
- 2no full-access keys on the account
- 3the WASM import section contains no deploy, use-global-contract, add-full-access-key, add-full-access-gas-key or delete-account host functions
Absence is sound: a contract cannot call a host function it does not import. Presence is weaker. Measured on 7 November 2026 with near-sdk 5.30.1 (release, LTO, no wasm-opt) on a one-method contract:
| How it adds one function-call key | promise_batch_action imports |
|---|---|
| Promise::new(...).add_access_key_allowance(...) | 17, including deploy, delete-account, add-full-access-key, add-full-access-gas-key and use-global-contract |
| env::promise_batch_action_add_key_allowance_with_function_call(...) | 1: promise_batch_action_add_key_with_function_call |
So the vault must use the low-level functions, and many ordinary near-sdk contracts carry these imports with no upgrade route. Open: a contract able to delete its own account frees the name, and a parent can recreate a sub-account with other code. Lab test T9 must confirm the behaviour.
The TOCTOU window
| v2 deploy lands at | version() returns |
|---|---|
| G | v2 |
| G+1 | v2 |
| G+2 | v2 (the local DeployContract receipt runs first in the same block) |
| G+3 | v1 |
| self-upgrade via promise, sent at G | v2 |
The window is at least 3 blocks after the gate transaction, plus the delay between the observer's check and submission. This is a lower bound. Multi-shard is untested. The gate can refuse the next transaction to a changed target; it cannot stop one already in flight.
Global contracts: where monitors go blind
| Field | Before | After |
|---|---|---|
| view_account.code_hash | 1111…1111 (zero hash) | 1111…1111, unchanged |
| view_account.global_contract_account_id | owner.sandbox | unchanged |
| view_code.hash | 73ETF… (v1) | J2gKR… (v2), changed |
| version() | v1 | v2 |
New code is active 3 blocks after the owner's deploy. A trigger keyed on view_account.code_hash never sees this change. Watch view_code (the resolved hash) or DeployGlobalContract on the owner. An account with no contract of its own also reports a zero code_hash, so a zero hash does not mean no code. By hash, an account that still has a full-access key can re-point it with UseGlobalContract (tested: v2 to v1 succeeded).
current_contract_code() is self-introspection only
| Account state | Returns |
|---|---|
| Local deploy | local:<code hash> |
| Global by hash | global_hash:<hash> |
| Global by account | global_account:<owner id> (never a hash) |
After the owner redeploys v2 on the by-account path, version() returns v2 and view_code changes, but this function still returns the account id. It must not be used to verify a target: the method wrapping it is written by the target, and malicious code can lie.
Gas keys (NEP-611)
Aruna does not use gas keys. Agents are function-call keys on the vault with a classic allowance. The lab results are kept because the facts remain true. Gas key funds are one-way: an agent without a full key can never withdraw them.
Show the gas key results
| Scenario | Result |
|---|---|
| AddKey with balance > 0 | rejected: AddGasKeyWithNonZeroBalance (balance cannot be set at AddKey) |
| Batch [CreateAccount, Transfer, AddKey(balance 0), TransferToGasKey] | accepted |
| Factory contract via promise batch | accepted |
| Parent TransferToGasKey afterwards | accepted |
| Unrelated account TransferToGasKey | accepted (top-up is permissionless) |
| Third-party contract promise_batch_action_transfer_to_gas_key | accepted |
| DelegateV2 with the agent as sender | rejected: RemovedProtocolFeature { protocol_feature: "DelegateV2", version: 88 } |
| Withdrawal by the parent | rejected: ActorNoPermission |
| Withdrawal by the agent's gas key | rejected: RequiresFullAccess |
| Gas key exhausted | rejected: NotEnoughGasKeyBalance { balance: "1", cost: "30919103596387000000000" } |
Mainnet measurement
| Class | Accounts | Share | Calls received | Share of calls |
|---|---|---|---|---|
| immutable_verified | 54 | 5.4% | 255,258 | 0.4% |
| local_upgradeable | 819 | 82.1% | 61,518,588 | 98.8% |
| global_by_account | 3 | 0.3% | 10,822 | 0.0% |
| unknown | 121 | 12.1% | 461,304 | 0.7% |
98.8% of the calls went to local_upgradeable contracts. 44.2% went to contracts where a full-access key exists, so its holder can replace the code at any moment. 54.6% went to contracts with no full-access key whose code still imports a deploy, full-access-key or delete-account host function: an upgrade path cannot be ruled out, though it may have no reachable route.
| Basis | Class | Accounts | Share | Share of calls |
|---|---|---|---|---|
| no_detected_path | immutable_verified | 54 | 5.4% | 0.4% |
| full_access_key | local_upgradeable | 197 | 19.8% | 44.2% |
| upgrade_imports | local_upgradeable | 617 | 61.9% | 54.6% |
| own_code | local_upgradeable | 5 | 0.5% | 0.0% |
| global_owner | global_by_account | 3 | 0.3% | 0.0% |
| undetermined | unknown | 121 | 12.1% | 0.7% |
The invisible class exists on mainnet and is rare here. 3 of 997 accounts (0.3%) are global_by_account: 0x4e4542dd.c.aurora, 0x4e4542bc.c.aurora, npoint.noamarket.near. A monitor keyed on view_account.code_hash sees the zero hash for them and misses a redeploy by the publisher. The finding is about monitoring correctness, not frequency. Accounts outside this list were not measured.
3 accounts could not be classified because the read failed (embr.playember_reserve.near, near, contract.dollaaa.near); a failed read is never counted as unknown. Source: measurement/results/2026-11-10, blocks 223,796,370 to 223,797,070. Method and limits: measurement/REPORT.md. Reproduce: pnpm measure, then node apps/web/scripts/sync-measurement.mjs measurement/results/2026-11-10.