Skip to main content

AITP-04: NEAR Wallet Schema Reference

  • Version: 1.0.0
  • Spec Status: Draft

Schema URL

https://aitp.dev/capabilities/aitp-04-near-wallet/v1.0.0/schema.json

Schema Overview

The AITP-04 NEAR Wallet capability defines a JSON schema that supports several message types for interacting with a NEAR blockchain wallet:

  1. Request Account - Ask for NEAR account information
  2. Account Response - Response with NEAR account information
  3. Request Transaction - Request a transaction to be signed and submitted
  4. Transaction Response - Response with transaction hash
  5. Request Message Signing - Request a message to be signed using NEP-413
  6. Message Signing Response - Response with signed message
  7. Token Notification - Notify about a NEP-141 token to be made visible

Field Descriptions

Request Account Fields

FieldTypeRequiredDescription
$schemastringYesURI reference to the schema
request_accountobjectYesContainer for the account request
request_account.request_idstringYesUnique identifier for this request
request_account.descriptionstringNoExplanation for why account access is needed

Account Response Fields

FieldTypeRequiredDescription
$schemastringYesURI reference to the schema
account_responseobjectYesContainer for the account response
account_response.request_idstringYesReference to the request being responded to
account_response.accountsarrayYesArray of NEAR account IDs

Request Transaction Fields

FieldTypeRequiredDescription
$schemastringYesURI reference to the schema
request_transactionobjectYesContainer for the transaction request
request_transaction.request_idstringYesUnique identifier for this request
request_transaction.descriptionstringNoDescription of what the transaction will do
request_transaction.transactionobjectYesTransaction details
request_transaction.transaction.receiver_idstringYesRecipient account ID
request_transaction.transaction.actionsarrayYesArray of actions to perform
request_transaction.transaction.actions[].typestringYesAction type (CreateAccount, FunctionCall, etc.)
request_transaction.transaction.actions[].paramsobjectYesParameters for the action

Transaction Response Fields

FieldTypeRequiredDescription
$schemastringYesURI reference to the schema
transaction_responseobjectYesContainer for the transaction response
transaction_response.request_idstringYesReference to the request being responded to
transaction_response.transaction_hashstringYesHash of the submitted transaction

Request Message Signing Fields

FieldTypeRequiredDescription
$schemastringYesURI reference to the schema
request_message_signingobjectYesContainer for the message signing request
request_message_signing.request_idstringYesUnique identifier for this request
request_message_signing.descriptionstringNoDescription of why the message needs to be signed
request_message_signing.messageobjectYesMessage to be signed following NEP-413 format
request_message_signing.message.noncestringYesBase64-encoded 32-byte nonce
request_message_signing.message.recipientstringYesIntended recipient of the message
request_message_signing.message.messagestringYesContent of the message to sign
request_message_signing.statestringNoOptional state parameter for callbacks

Message Signing Response Fields

FieldTypeRequiredDescription
$schemastringYesURI reference to the schema
message_signing_responseobjectYesContainer for the message signing response
message_signing_response.request_idstringYesReference to the request being responded to
message_signing_response.account_idstringYesAccount ID that signed the message
message_signing_response.public_keystringYesPublic key used for signing
message_signing_response.signaturestringYesCryptographic signature

Token Notification Fields

FieldTypeRequiredDescription
$schemastringYesURI reference to the schema
token_notificationobjectYesContainer for the token notification
token_notification.notification_idstringYesUnique identifier for this notification
token_notification.token_typestringYesType of token (currently only "nep141" supported)
token_notification.token_contractstringYesContract address of the token

Action Types

For transaction requests, the following action types are supported:

Action TypeDescription
CreateAccountCreate a new NEAR account
DeployContractDeploy a smart contract
FunctionCallCall a function on a smart contract
TransferTransfer NEAR tokens
StakeStake NEAR tokens with a validator
AddKeyAdd an access key to an account
DeleteKeyRemove an access key from an account
DeleteAccountDelete a NEAR account

NEP-413 Message Signing

The message signing request follows the NEP-413 standard for secure message signing. Key features include:

  1. Nonce: A 32-byte random value encoded as Base64 to prevent replay attacks
  2. Recipient: The intended recipient of the signed message
  3. Message: The content to be signed

The wallet will format these components according to the NEP-413 standard before signing.

Token Standards

The token notification supports NEP-141 fungible tokens. When notified about a token, wallets should:

  1. Query the token contract for metadata using the NEP-148 standard
  2. Display the token in the user's wallet interface
  3. Track the user's balance of this token