I am a beginner in Solana Development and I recently learned that data in Solana blockchain can be stored inside accounts. Instead of this is it possible to store the data directly in a block instead of the account? For example, if I have a string, can I directly store it on a block as a transaction or some other way? If yes can you please tell me how? If not, then can you please tell me how can I make the account data immutable?

I will be really very grateful if you can help me out with this

2 Answers 2


While the accepted answer indicates No, it depends on your use case:

You actually can store data on chain vis-a-vis the transaction you submit. When you submit a transaction the entire content of the transaction is stored on the chain. You could then fetch that transaction, parse out the bits you want and you will have your data.

  • But we will have to create a custom transaction and program right? Or are there native solana programs to do this? Also are there any resources where I can learn this? Commented Feb 5, 2023 at 14:20
  • Actually I want to store file IDs on the chain Commented Feb 5, 2023 at 14:26
  • 1
    That is what i said. Transactions are stored. But so wants to store data directly like a database
    – Yilmaz
    Commented Feb 7, 2023 at 13:29
  • @Yilmaz So is it possible to encode a string or a file ID into a transaction and store it on blockchain? Commented Feb 8, 2023 at 11:23
  • @RounakNaik take a look at the Solana Program Library "Memo" github.com/solana-labs/solana-program-library/tree/master/memo
    – Frank C.
    Commented Feb 8, 2023 at 11:39

Shortly No

Transactions are stored in the block. Transactions are called public ledger and a ledger means a record of a business's financial transactions.

From here

If the program needs to store state between transactions, it does so using accounts. Accounts are similar to files in operating systems such as Linux in that they may hold arbitrary data that persists beyond the lifetime of a program. Also like a file, an account includes metadata that tells the runtime who is allowed to access the data and how.

Unlike a file, the account includes metadata for the lifetime of the file. That lifetime is expressed by a number of fractional native tokens called lamports. Accounts are held in validator memory and pay "rent" to stay there. Each validator periodically scans all accounts and collects rent. Any account that drops to zero lamports is purged. Accounts can also be marked rent-exempt if they contain a sufficient number of lamports.

there are two types of accounts in solana: Executable and non-executable. Non-executable contracts store data or state of logic in your contract and htis has an owner. Owner can mutate the state. when you create an account, you assign an owner and later when your contract needs to access to that account, your contract checks if it is the owner or not owner

Executable accounts are immutable. Smart contracts in Solana are executable accounts, therefore once you deploy it you cannot mutate it

solana account fields:

enter image description here

  • Thank You, also one more doubt, you mentioned about owners of the accounts, so is that the wallet address with which the account was created? Commented Feb 5, 2023 at 5:48
  • yes. in the future when you interact with the Solana in javascript, you will see that many api functions willl require owner argument. You will be creating a publickey to assign it as an owner.
    – Yilmaz
    Commented Feb 5, 2023 at 5:58
  • there is more on accounts, I just posted enough to answer your question
    – Yilmaz
    Commented Feb 5, 2023 at 6:02
  • So the public key is the solana address of the system or the program which creates the token? Commented Feb 5, 2023 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.