Can we add the permission to access the table?

The name of the pictureThe name of the pictureThe name of the pictureClash 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 ?







share|improve this question
















  • 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














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 ?







share|improve this question
















  • 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












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 ?







share|improve this question












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 ?









share|improve this question











share|improve this question




share|improve this question










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












  • 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










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






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "696"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























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






    share|improve this answer
























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






      share|improve this answer






















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






        share|improve this 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++;







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 27 at 12:31









        TeeAttack42♦

        1,482224




        1,482224



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery