execute_intents.
This page covers how intents are structured, wrapped into signed payloads, and the available intent types you can submit.
- For cryptographic signing details, see Signing Intents.
- To test intents before submitting, see Simulating Intents.
Ordering and atomicity
Multiple intents can be submitted toexecute_intents in a list, where they execute in the order provided.
Example of potential ordering issues:
- Intent 1: Perform a storage deposit on
usdc.near - Intent 2: Withdraw native NEAR to
usdc.near
usdc.near contract requires a storage deposit before tokens can be deposited. While Intent 1 executes first, there’s no guarantee the storage deposit call will complete before Intent 2’s withdrawal call is made.
Intent structure
Intents are submitted as JSON objects in a payload. Here’s an example Transfer intent for wNEAR tokens from Alice to Bob:The intent does not mention Alice because the signer of the intent defines which account performs the transfer.
Payload structure
The intent is wrapped in a payload with these required fields:| Field | Description |
|---|---|
signer_id | Signer account ID. |
verifying_contract | Contract address receiving the intents. |
deadline | Timestamp in ISO 8601 format. |
nonce | 256-bit unique value (see below). |
intents | Array of intents to execute. |
Nonce structure
The nonce is a 256-bit (32-byte) value encoded as base64. It must be unique per intent to prevent replay attacks. Structure:[4-byte salt][28-byte unique data]
- Salt (first 4 bytes): Must match the current contract salt (retrieve via
simulate_intents) - Unique data (remaining 28 bytes): Can be random or sequential, as long as it’s never reused for the same account
The salt rotates periodically. Always fetch the current salt before constructing intents. See the nonce documentation for implementation details.
Signed intent format
To create a valid, signed intent for theexecute_intents function, wrap the payload in a message string and sign it. See Signing Intents for supported signature types (NEP-413, ERC-191, WebAuthn, and more). Note that the message is the same JSON serialized as a one-liner with escaped quotes:
recipient field prevents replay attacks on other copies of the Verifier.
All signed examples on this page use the same test key (
ed25519:C3jX...). In production, each signer uses their own key pair.Available intent types
The following intents can be submitted to the Verifier contract.Rust
PascalCase names are converted to snake_case in JSON. For example, TokenDiff becomes token_diff.add_public_key
Adds a public key to an account in the Verifier contract. The added key’s private key can sign intents on behalf of this account, including adding new keys. Public keys can also be added via transactions.| Parameter | Description |
|---|---|
public_key | The public key to add to the account (e.g., ed25519:...). |
Full signed intent example
Full signed intent example
The
message field contains the intent JSON above, serialized as a single line with escaped quotes.remove_public_key
Removes a public key from an account. Can also be done via transactions.| Parameter | Description |
|---|---|
public_key | The public key to remove from the account. |
Full signed intent example
Full signed intent example
The
message field contains the intent JSON above, serialized as a single line with escaped quotes.transfer
Transfers tokens from the signer to a specified account within the Verifier contract. Transfers can also be done via direct blockchain transactions.| Parameter | Description |
|---|---|
receiver_id | The account to receive the tokens. |
tokens | Map of token IDs to amounts in Multi Token format. |
memo | Optional memo for the transfer. |
Full signed intent example
Full signed intent example
The
message field contains the intent JSON above, serialized as a single line with escaped quotes.Withdrawal intents
These intents move tokens from the Verifier contract to an arbitrary address:- FtWithdraw - Fungible tokens
- NftWithdraw - Non-fungible tokens
- MtWithdraw - Multi tokens
- NativeWithdraw - Native NEAR
| Parameter | Description |
|---|---|
token | The token contract to withdraw (e.g., usdc.near). No prefix for this field. |
receiver_id | The NEAR account that will receive the withdrawn tokens. |
amount | The amount in the token’s smallest unit. |
memo | Optional memo for the withdrawal. |
msg | Optional message to pass to ft_transfer_call. If omitted, ft_transfer is used instead. See Withdrawals for refund behavior. |
storage_deposit | Optional wNEAR amount to pay for storage deposit on the token contract for the receiver. Will not be refunded on failure. |
usdc.near contract under Bob’s account—they have exited the Verifier:
Full signed intent example
Full signed intent example
The
message field contains the intent JSON above, serialized as a single line with escaped quotes.storage_deposit
Makes an NEP-145storage_deposit call for an account_id on a contract_id. The amount is subtracted from the user’s NEP-141 wNEAR balance and will not be refunded.
| Parameter | Description |
|---|---|
contract_id | The contract to make the storage deposit on (e.g., usdc.near). |
account_id | The account to deposit storage for. |
amount | The wNEAR amount in yoctoNEAR. Subtracted from the signer’s wNEAR balance and will not be refunded. |
usdc.near contract. The NEAR token specified will be taken from alice.near’s account and paid to bob.near in the usdc.near contract:
Full signed intent example
Full signed intent example
The
message field contains the intent JSON above, serialized as a single line with escaped quotes.token_diff
The user declares willingness to have a set of changes applied to their tokens. For example, a trade of 100 token A for 200 token B can be represented as{"A": -100, "B": 200}. The Verifier resolves matching diffs into transfers between parties.
| Parameter | Description |
|---|---|
diff | Map of token IDs to signed amount strings. Negative values indicate tokens given, positive values indicate tokens received. |
memo | Optional memo for the trade. |
referral | Optional account ID for referral tracking. |
- Alice's intent
- Bob's intent
Full signed intent example
Full signed intent example
The
message field contains the intent JSON above, serialized as a single line with escaped quotes.