Skip to main content
The V5 wallet standard offers many benefits that improve the experience for both users and developers. V5 supports gasless transactions, account delegation and recovery, subscription payments using Jettons and Toncoin, and low-cost multi-transfers. In addition to retaining the previous functionality (V4), the new contract allows you to send up to 255 messages at a time. This article provides only a high-level wallet V5 contract overview. If you want to learn more about how to use its interfaces or develop extensions, check out the wallet V5 API article. Source links:

Persistent memory layout

  • is_signature_allowed: 1-bit flag that restricts or allows access through the signature and stored public key.
  • seqno: 32-bit sequence number.
  • wallet_id: 32-bit wallet ID (equivalent to subwallet_id in previous versions).
  • public_key: 256-bit public key.
  • extensions_dict: dictionary containing extensions (may be empty).
As you can see, the ContractState, compared to previous versions, hasn’t changed much. The main difference is the new is_signature_allowed 1-bit flag, which restricts or allows access through the signature and stored public key. We will describe the importance of this change in later topics.

Message layout

External message body layout

  • wallet_id: 32-bit long wallet ID.
  • valid_until: 32-bit long Unix time integer.
  • msg_seqno: 32-bit long sequence number.
  • inner: InnerRequest containing the actual actions to perform.
  • signature: 512-bit long Ed25519 signature.

Internal message body layout

Learn more about internal message serialization here.

Authentication process

Before we get to the actual payload of our messages — InnerRequest — let’s first look at how version 5 differs from previous versions in the authentication process. The InternalMsgBody combinator describes two ways to access wallet actions through internal messages. The first method is one we are already familiar with from version 4: authentication as a previously registered extension, the address of which is stored in extensions_dict. The second method is authentication through the stored public key and signature, similar to external requests. At first, this might seem like an unnecessary feature, but it actually enables requests to be processed through external services (smart contracts) that are not part of your wallet’s extension infrastructure — a key feature of V5. Gasless transactions rely on this functionality. Any received internal message that doesn’t pass the authentication process will be considered a transfer.

Actions

The first thing that we should notice is InnerRequest, which we have already seen in the authentication process. In contrast to the previous version, both external and internal messages have access to the same functionality, except for changing the signature mode (i.e., the is_signature_allowed flag). We can consider InnerRequest as two lists of actions: the first, OutList, is an optional chain of cell references, each containing a send message request led by the message mode. The second, ActionList, is led by a one-bit flag, has_other_actions, which marks the presence of extended actions, starting from the first cell and continuing as a chain of cell references. We are already familiar with the first two extended actions, action_add_ext and action_delete_ext, followed by the internal address that we want to add or delete from the extensions dictionary. The third, action_set_signature_auth_allowed, restricts or allows authentication through the public key, leaving the only way to interact with the wallet through extensions. This functionality might be extremely important in the case of a lost or compromised private key. Learn more about actions here.

Exit codes

Get methods

  1. int is_signature_allowed() returns stored is_signature_allowed flag.
  2. int seqno() returns current stored seqno.
  3. int get_wallet_id() returns current wallet ID.
  4. int get_public_key() returns current stored public key.
  5. cell get_extensions() returns extensions dictionary.

Gasless transactions

Starting with v5, the wallet smart contract supports owner-signed internal messages (internal_signed), which enables gasless transactions—for example, paying network fees in USDT when transferring USDT. Gasless transactions are supported not at the network protocol level, meaning that to pay fees in USDT it is necessary to rely on some off-chain infrastructure, e.g., like in Tonkeeper. Flow scheme for Tonkeeper gasless transactions looks like this:

Flow details

  1. When sending USDT, the user signs one message containing two outgoing USDT transfers:
    1. USDT transfer to the recipient’s address.
    2. Transfer of a small amount of USDT in favor of the service.
  2. This signed message is sent off-chain by HTTPS to the service backend. The service backend sends it to the TON Blockchain, paying Toncoin for network fees.
The beta version of the gasless backend API is available at tonapi.io/api-v2. If you are developing a wallet app and have feedback about these methods, please share it in @tonapitech chat.