Let's say I have a method:

function appendNewName(string name) {

I want to store this in the backend in DB once a new name is inserted. How can I achieve that? Unfortunately this

function getNames() returns (string[] names) {
    return names;

doesn't work because of the way Ethereum stores data. And with events I might miss some of the new names, right? So, what is the solution?

  • The solution is to emit an event inside the method. Nov 26, 2020 at 11:44

1 Answer 1


You either have to do it yourself or use a third-party API such as Etherscan. I won't discuss using a third-party API as this isn't the 'decentralized way.'

In the case of doing it yourself, your only option is to write your own blockchain scraper (huge overkill) or listen for events from your contract. This answer discusses events: https://ethereum.stackexchange.com/a/11231/1529.

Your question hints that you're worried you would miss events. This may happen (if your 'listener' goes off-line for example), but you can query historical events as well starting at the last known event if you suspect you missed something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.