Can we add the permission to access the table?
Can we add the permission to access the table?
I know how to declare ,initialize and get,set values in a table .My question is Can we add permission to access the table to a particular user inside our smart contract ?
1 Answer
1
You can not forbid reading the data from a smart contracts table, because it is exposed by the RPC interface or CLI.
What you can do to prevent understanding it by 3rd parties, is encrypt your data like @confused00 said.
If you just want to limit access for adding, modyfing or deleting, you can use the scopes of the multi_index and the require_auth method, which will check for the right signatures. This would look something like this:
require_auth(user);
testIndex1 test1(_self, user); // code, scope
// iterate over first index
for(auto itr = test1.begin(); itr != test1.end() && count!=pLimit;)
// delete element and update iterator reference
itr = test1.erase(itr);
count++;
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
tables are open to read for anyone without even needing a blockchain account. i think the closest you can do is encrypt data in a table with someone's public key so they can read it only if they have the secret key
– confused00
Aug 27 at 12:15