Can we add the permission to access the table?
Clash Royale CLAN TAG#URR8PPP
up vote
7
down vote
favorite
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 ?
smart-contract permissions eosio-code table
add a comment |Â
up vote
7
down vote
favorite
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 ?
smart-contract permissions eosio-code table
1
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
add a comment |Â
up vote
7
down vote
favorite
up vote
7
down vote
favorite
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 ?
smart-contract permissions eosio-code 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 ?
smart-contract permissions eosio-code table
asked Aug 27 at 11:06
Nirdesh Kumar Choudhary
42510
42510
1
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
add a comment |Â
1
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
1
1
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
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
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
6
down vote
accepted
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++;
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
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++;
add a comment |Â
up vote
6
down vote
accepted
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++;
add a comment |Â
up vote
6
down vote
accepted
up vote
6
down vote
accepted
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++;
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++;
answered Aug 27 at 12:31


TeeAttack42♦
1,482224
1,482224
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2feosio.stackexchange.com%2fquestions%2f2149%2fcan-we-add-the-permission-to-access-the-table%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
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