Trading account contract
The contract every trading account runs: who may call it, what it allows and refuses, and how an account is set up.
Each trading account is a NEAR account of its own, named <16 hex>.trade.unrlzd.near, that the factory trade.unrlzd.near creates for your owner wallet. It runs one shared contract, referenced by its code hash. Three kinds of signature can reach it: your owner wallet, the trading keys in your browser and, if you turn 24/7 orders on, a 24/7 key. The account has no full-access key, so every call it accepts is one of its methods, under the rules the contract checks.
The account and its code
Section titled “The account and its code”The address depends only on the owner’s account name. The account doesn’t store its own copy of the code. It runs a global contract, named by its hash (NEP-591), and code deployed by hash can’t be changed. Verify the contracts shows how to check that hash against the published source.
Owner wallet calls
Section titled “Owner wallet calls”Every owner_* method runs only when the caller is the owner account and exactly 1 yoctoNEAR is attached. A function call key can’t attach a deposit, so the yoctoNEAR proves that a full-access key of the owner signed, which your wallet asks you to confirm. The owner can:
- take funds out;
- add and remove keys;
- raise caps and add withdrawal addresses, both of which take effect one hour later;
- move the account to new code.
An owner whose wallet signs messages rather than NEAR transactions acts through owner_signed, which runs the same owner actions from a payload the owner signed. A signed payload can’t be replayed elsewhere or twice.
Trading-key calls
Section titled “Trading-key calls”The trading key signs your trades without a wallet pop-up. It can trade, place and cancel orders, and send funds to your owner wallet or to an address your owner wallet listed; it can’t send funds anywhere else. The same signed trade, sent twice or to several RPC providers at once, runs once.
Two caps bound what the trading key can move: the largest single trade and the day’s total. A decrease applies at once. Someone who gets hold of a trading key can’t raise the limits it trades under: only your owner wallet can, and only an hour later.
Storage and the reserve
Section titled “Storage and the reserve”A trading account pays for its own storage the way every NEAR account does. The contract also keeps 0.05 NEAR in the account and refuses any outflow that would leave less.
The 24/7 key
Section titled “The 24/7 key”The 24/7 key can only send an order you stored, as stored, with a minimum no lower than yours. It can’t withdraw, change an order or place one.
How an account is set up
Section titled “How an account is set up”Your owner wallet calls create_account on the factory with the trading keys this browser made and, if you want 24/7 orders, a 24/7 key. The account is created, funded and set up in one batch; if any step fails, the whole deposit goes back to your owner wallet. The fee is fixed when the account is created; the account has no method that changes it.
Sources
Last verified 15 October 2026 against R4.