encryptForNEARViewing()
SIP Protocol API Reference v0.7.4
SIP Protocol API Reference / encryptForNEARViewing
Function: encryptForNEARViewing()
Section titled “Function: encryptForNEARViewing()”encryptForNEARViewing(
data,viewingKey):NEAREncryptedPayload
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:18794
Encrypt transaction data for viewing key holders
Uses XChaCha20-Poly1305 authenticated encryption with a random nonce. The encryption key is derived from the viewing private key using HKDF.
Parameters
Section titled “Parameters”Transaction data to encrypt
viewingKey
Section titled “viewingKey”The viewing key for encryption
Returns
Section titled “Returns”Encrypted payload with nonce and key hash
Example
Section titled “Example”const encrypted = encryptForNEARViewing({ sender: 'alice.near', recipient: stealthAccountId, amount: '1000000000000000000000000', // 1 NEAR tokenContract: null, // native NEAR decimals: 24, timestamp: Date.now(),}, viewingKey)
// Store encrypted.ciphertext on-chain or off-chain