Skip to main content
This example shows how to send a TON transfer with an encrypted comment. The comment is encrypted end-to-end (ECDH) so that only the sender and the intended recipient can read it.

Encrypt and Send

Retrieve the recipient’s public key from their deployed wallet contract with get_public_key_get_method, encrypt the comment with TextCipher.encrypt, and send it as the transfer body.

Decrypt

Use TextCipher.decrypt with the recipient’s private key and the original sender’s address. The encrypted payload (message body with opcode 0x2167DA4B) can be provided as raw bytes, a hex string, a base64 string, or a full body Cell parsed from BoC.
The same example also appears in Encrypted Messages among the other wallet operations.