Search code examples
nearprotocol

How to store a private message in NEAR?


Are there any built-in mechanisms in NEAR for storing private messages, or does the contract need its own code for encrypting message contents?


Solution

  • does the contract need its own code for encrypting message contents?

    Contract shouldn't be encrypting/decrypting messages, as everything executed on blockchain layer is visible to everyone.

    However you can store already encrypted messages and do encryption/decryption client-side (i.e. in JS). Most convenient way to do this is use the same crypto library as used in nearlib:

    https://tweetnacl.js.org/