GUIDELINE 04
Know what data is safe to store
Assume blockchain and asset data can become durable and widely readable. Store only what the application truly needs.
Classify before writing
- Public: ownership, public profiles, hashes, public contract state.
- Private but shareable: encrypt for explicit recipients before storage.
- Local secret: passwords, private keys, mnemonics, session credentials. Never put these on-chain.
- Regulated or deletion-sensitive: keep off-chain unless your legal and retention design explicitly supports it.
Minimize permanent data
- Store a digest when verification is enough.
- Do not place personal data in transaction parameters merely because the contract ignores it.
- Validate type, length, and encoding in both client and contract.
- Define ownership, readers, retention, and deletion before launch.
Allowlist public fields
function publicProfile(form) {
const displayName = form.displayName.trim();
if (displayName.length < 1 || displayName.length > 60) {
throw new Error("Display name must contain between 1 and 60 characters");
}
return {
version: 1,
display_name: displayName,
avatar_hash: form.avatarHash
};
}
// Never spread an entire form or wallet object into transaction data.
const parameters = JSON.stringify({ function: "update_profile", profile: publicProfile(form) });Bottom line
If publishing a field would surprise its owner, do not write it in plaintext to a transaction, wallet object, contract, SQL table, or asset.