Skip to content

encryptForNEARViewing()

SIP Protocol API Reference v0.7.4


SIP Protocol API Reference / 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.

NEARTransactionData

Transaction data to encrypt

NEARViewingKey

The viewing key for encryption

NEAREncryptedPayload

Encrypted payload with nonce and key hash

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