How to maintain history of changes in mapping?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












I have a mapping variable in my solidity code which maps address to name. I want to maintain the history/log of every change that happens in this mapping. What is the best possible solution to it?










share|improve this question

























    up vote
    1
    down vote

    favorite
    1












    I have a mapping variable in my solidity code which maps address to name. I want to maintain the history/log of every change that happens in this mapping. What is the best possible solution to it?










    share|improve this question























      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      I have a mapping variable in my solidity code which maps address to name. I want to maintain the history/log of every change that happens in this mapping. What is the best possible solution to it?










      share|improve this question













      I have a mapping variable in my solidity code which maps address to name. I want to maintain the history/log of every change that happens in this mapping. What is the best possible solution to it?







      solidity contract-development mapping logs history






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      Gagan

      687




      687




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          Define a change event like



          event MyMapChange(address _addr, string _newName);


          and then, on each change, emit one like this:



          emit MyMapChange(myAddr, myNewName);


          Events get stored on the blockchain and can be queried, i.e. you can request request history, and also you can subscribe to new events, and even filter them by field values. To enable field filtering, you need to add indexed keyword to no more than 3 of the fields defined in your event, like this:



          event MyMapChange(address indexed _addr, string _newName);


          Check this related question and answers: How can I view event logs for an ethereum contract?






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "642"
            ;
            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%2fethereum.stackexchange.com%2fquestions%2f59351%2fhow-to-maintain-history-of-changes-in-mapping%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
            2
            down vote













            Define a change event like



            event MyMapChange(address _addr, string _newName);


            and then, on each change, emit one like this:



            emit MyMapChange(myAddr, myNewName);


            Events get stored on the blockchain and can be queried, i.e. you can request request history, and also you can subscribe to new events, and even filter them by field values. To enable field filtering, you need to add indexed keyword to no more than 3 of the fields defined in your event, like this:



            event MyMapChange(address indexed _addr, string _newName);


            Check this related question and answers: How can I view event logs for an ethereum contract?






            share|improve this answer
























              up vote
              2
              down vote













              Define a change event like



              event MyMapChange(address _addr, string _newName);


              and then, on each change, emit one like this:



              emit MyMapChange(myAddr, myNewName);


              Events get stored on the blockchain and can be queried, i.e. you can request request history, and also you can subscribe to new events, and even filter them by field values. To enable field filtering, you need to add indexed keyword to no more than 3 of the fields defined in your event, like this:



              event MyMapChange(address indexed _addr, string _newName);


              Check this related question and answers: How can I view event logs for an ethereum contract?






              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote









                Define a change event like



                event MyMapChange(address _addr, string _newName);


                and then, on each change, emit one like this:



                emit MyMapChange(myAddr, myNewName);


                Events get stored on the blockchain and can be queried, i.e. you can request request history, and also you can subscribe to new events, and even filter them by field values. To enable field filtering, you need to add indexed keyword to no more than 3 of the fields defined in your event, like this:



                event MyMapChange(address indexed _addr, string _newName);


                Check this related question and answers: How can I view event logs for an ethereum contract?






                share|improve this answer












                Define a change event like



                event MyMapChange(address _addr, string _newName);


                and then, on each change, emit one like this:



                emit MyMapChange(myAddr, myNewName);


                Events get stored on the blockchain and can be queried, i.e. you can request request history, and also you can subscribe to new events, and even filter them by field values. To enable field filtering, you need to add indexed keyword to no more than 3 of the fields defined in your event, like this:



                event MyMapChange(address indexed _addr, string _newName);


                Check this related question and answers: How can I view event logs for an ethereum contract?







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 3 hours ago









                Utgarda

                35319




                35319



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fethereum.stackexchange.com%2fquestions%2f59351%2fhow-to-maintain-history-of-changes-in-mapping%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Confectionery