0

I was wondering about the ramifications of having tables declared public. Since EOSIO is a transparent blockchain anyone can read tables of any contract. So having them declared public in a smart contract allows other contracts for easy access of the tables. However, I saw a lot of contracts where tables are declared private and I wonder why.

What is best practice when it comes to table declarations in EOSIO smart contracts?

0

Visibility in C++ source file of contract is not important. All multi-index tables are public and can be read outside of contract. By omitting [[eosio::table]] attribute (not to include table definition in ABI), it hinders easy access, but still accessible in raw data format.

Visibility in source file is useful when you provide your header file to others to let them call actions in your contract from other contract. (eg. inline action) By setting table private, you may want to tell it's not intended to access this table from outside. Even in this case, others can modify provided header file by themselves, and can read multi-index data of your contract from their contract.

You had better consider all tables are public.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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