I am working on a project where blockchain will be used on a supply chain. One can create and transfer assets to another in the same.

Whenever one is creating an asset or transferring any asset, that action is being stored in the smart contract's string array.

And the strings quite big, for eg. "Token Tkn56fg2 is created by vendor with ID 4123" or "Tokens Tkn5rts2, Tkn67htf were transferred from vendor 5612 to vendor 4523" and so on...

All these actions are stored so that every action happened till date can be seen by anyone. In the dashboard section of my frontend, I'm taking this entire string array, and displaying these actions as individual actions taken place till date.

My question is, is this a good practice to store the actions in a string array? Obviously this seems like it is not. But since I'm required to store all the actions till date, and also don't want anyone to make changes to these, I'm avoiding storing these in any other databases. Pardon me if my question did not make sense. Also any suggestions to a different approach would be appreciated. Thank you.

3 Answers 3


Why do you want to save the transactions by yourself? it's not secure and they can be tampered. Transactions are automatically get saved (and validated) into a block in the blockchain, which means it's tamper proof.

if you want to get all transactions in your smart contract a tool like Etherscan can help you look at an address, and transactions from that address via your web browser. If you want to do something programmatically, you will need to use a Web3 library like Web3.js or Web3.py.

For more information visit web3.js documentation for transaction related examples

  • They are not exactly transactions, but just strings defining some actions. No money transfer is taking place. Also an event can help me give a response to the user interface, but will I be able to store and retrieve all such events that also happened in the past? May 3, 2020 at 4:23
  • Anything that can change the smart contract's data is a transaction. If your function or method doesn't change the data, it's not a transaction and its only a "call()". As you may know , transactions must always being called with " .send() " in web3 . all transactions will be stored in a block, which can be retrieved later on. btw I'm not sure what you mean by saying ' events ' . but transactions are always available because it's in the nature of a Blockchain so that not no one can change a transaction without anyone noticing it.
    – Masoud jt
    May 3, 2020 at 5:15

Do you really need those strings in the smart contract? Is there a functionality that use those strings?

Storage and string manipulation are expensive in a smart contract. If you want to track performed actions there are better and cheaper options, like events, or using a mapping with a fixed array size like bytes32.


If the string you want to store represents the occurrence of some event (which is what it looks like in your question) it would probably make sense to emit them as events and read them from the logs rather than save them in the state of the contract. For starters its way cheaper storage mechanism, and if you the event its essentially free storage. (Although I have bene hearing about some potential future changes which may trucncate some of the logs. Not sure of the status of that.);

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.