__external_call method with the call’s payload as input, decides whether to accept it, and pays for it from its own balance. A refused call never lands and costs nobody anything.
This lets a contract check its own authorization, for example a wallet contract that verifies a passkey or secp256k1 signature inside the payload, without a relayer.
External calls need a node running protocol version 89 (nearcore 2.15) or later. An older node rejects a send at once.
Dry Run
Before sending, run the call as a chunk producer would.viewExternalCall() is a view call of __external_call, at optimistic finality by default:
Uint8Array.
Sending
max_call_size (see Limits) is rejected at once with an InvalidTransactionError carrying TransactionSizeExceeded. As with a signed transaction, externalCall() throws only when the call itself fails: a receipt it starts that fails shows up in outcome.receipts_outcome.
An external call has no hash known before it lands. Each copy that lands gets a unique id from the call hash and the height of the block that includes it. send_tx returns it once a copy is included. With waitUntil: "NONE" the node returns nothing to follow.
To look a copy up later, pass its unique id and the contract:
Timeouts and Finding a Copy
A refused call is dropped, not rejected, sosend_tx waits until it times out. near-kit sends the call once, never retrying it, and throws ExternalCallTimeoutError, with the call hash and the final block height seen before sending. The call may still land. If the node saw a copy land that hadn’t reached the wait level yet, the error also has its uniqueId. A network error on the send is thrown as is: the call may have landed, so look for it with findExternalCall() before sending it again.
findExternalCall() finds the copy. With resend: true it first sends the same call again: a node that saw a copy land returns it at once. Otherwise, or if that fails, it tries one candidate unique id per height:
toHeight, the search stops at the current head. With a toHeight past the head, it waits for new blocks. A copy refused at execution doesn’t count as found: the search goes on, and throws that copy’s ExternalCallRefusedError only if no accepted copy turns up.
A miss is only as certain as the node that answered it. Behind a load balancer, a node a few blocks behind can report a landed copy as unknown. When a miss must be certain before you send the call again, search through a single node.
Uninitialized Universal Accounts
A funded universal (0u...) account has no code until its state init is installed. Until then near.rpc.getAccount() shows state: "uninitialized" and its bootstrap_nonce. The first external call can carry the state init:
stateInit is the raw borsh-encoded UniversalStateInit. findExternalCall() takes it the same way. It isn’t part of the call hash or unique id, and once the account is initialized, chunk producers drop it from later calls, so the landed copy’s transaction.state_init is null.
near.view() takes a state init too, as { stateInit: { universal: bytes } } or a deterministic { stateInit: { code, data } }.
Wire Format
The codec is exported for tools that build or inspect calls themselves:Limits
getProtocolConfig() reports them: