0

I am rather new to Ethereum and I wonder if the following scenario is possible. I want/need to store some data encoded as a JWT in the blockchain and have it (publicly) accessible via an ID. Only the "owner" of the data can change it, where the ID always remains the same.

As far as I can see, this is achievable via Ethereum EOAs:

Creating:

  • Owner creates EC keypair
  • Owner creates an EOA, the public key becoming the ID of this account
  • Owner stores the JWT in the account

Retrieving:

  • Viewer knows the ID (i.e. the public key of the owner). How is irrelevant here.
  • Viewer fetches contract from the chain and extracts the enclosed JWT

Updating:

  • Owner creates a transaction to change the JWT in the account
  • Transaction is signed with his private key

Does this check out or do I have an error in this concept? Maybe I misunderstood how details work in Ethereum or with EOAs in general.

Edit: To clarify:

  • EOA = Externally Owned Account in Ethereum
  • JWT = JSON Web Token, for the sake of simplicity it is a base64-encoded String, nothing more
1

Welcome to Ethereum - you wont regret this :)

Conceptually we store data inside smart contracts. This blockchain - which basically is an expensive, slow and inefficient database can be used to store data. More precisely you store data inside smart contracts running on a the Ethereum blockchain. I'm not familiar with EOA or JWT but basically you can write a simple storage smart contract that only you can update. e.g. like this

contract storeStuff {
  string content
  address owner;

  // this is the constructor and it sets the owner
  // here we do not allow the owner to be updatable and they are thus carved in stone for eternity!
  function storeStuff() {
    owner = msg.sender;
  }

  function updateContent (string newContent) {
    if (msg.sender == owner)
      content = newContent;
  }
}

You can play around with this in remix fully in your browser without paying Ether for transaction fees while fooling around. There are a lot more complex situtations that are cheaper (in terms of tx fees), more secure (e.g. change owner), store data not in contract but just use events, you have to learn how to interface that but this is a great starting case.

  • 1
    EOA = Externally-owned account (vs. contract account), JWT = JSON web token (i.e. how lots of forms of authentication/sessions work). – Richard Horrocks Jun 21 '17 at 12:06
  • Yet accounts cannot be used for that? – Xenonite Jun 21 '17 at 12:30
  • @Xenonite. In theory you could probably send stuff in the data field of a transaction to an EOA (thx for the abbreviation @Richard Horrocks!). The drawbacks are: this would be difficult to parse and not available for smart contracts. Just a general consideration: no matter where you store data, on the public chain all this data is publicly visible. – Validity Labs - Sebastian Jun 21 '17 at 15:54
  • thanks. yet that's EXACTLY what I need. The data should be readable by anyone and retrieved by an id that is not going to change ever - i.e. the accounts id. finally, only the owner of an account should be able to change it. – Xenonite Jun 22 '17 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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