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
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++;
}