Skip to main content

On-Chain Storage

To specify that data should be stored on-chain, set the "onchain" property to true. This will deploy or update a smart contract on the blockchain to handle the data storage. It's important to note that ALL data for any new data created on-chain is entirely public.

Example:

"onchain": true

Updating an existing app

When updating an app that uses on-chain storage, you must be careful with field modifications. Since data is stored as bytes on the blockchain, changing a field's type or renaming an existing field can corrupt the stored data. Instead of modifying existing fields:

  1. Create a new field with the desired type/name
  2. Migrate your application logic to use the new field
  3. Keep but deprecate the old field to maintain data integrity

This ensures that existing on-chain data remains accessible while allowing your application to evolve.

Important Notes

  • All fields to be stored on-chain must be defined in the "fields" section
  • Optional fields can be marked with a ? suffix in their type
  • On-chain storage is ideal for data that can be public and requires immutability and transparency, and may be used in performing on-chain actions via a plugin