How to maintain history of changes in mapping?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
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
add a comment |Â
up vote
1
down vote
favorite
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
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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
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
solidity contract-development mapping logs history
asked 3 hours ago
Gagan
687
687
add a comment |Â
add a comment |Â
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?
add a comment |Â
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?
add a comment |Â
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?
add a comment |Â
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?
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?
answered 3 hours ago
Utgarda
35319
35319
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%2fethereum.stackexchange.com%2fquestions%2f59351%2fhow-to-maintain-history-of-changes-in-mapping%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