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

Pass encrypt=True to transfer(). The recipient’s public key is fetched from its wallet via the get_public_key get-method; for an undeployed recipient, pass it as recipient_public_key.

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.