Use on-chain or off-chain to store user data?

Hi all,

I’m thinking about creating a system that keeps track of points for users. Wondering how to architect this with a smart contract. (I’m a bit new in my ethereum journey; so far, I’ve created an ERC-20 token and a React site that can transfer/send these tokens… so not too much experience yet).

The system I’m thinking of will have a website that will have users where these users will be able to gain points and redeem points (basically transfer them to someone else).

  1. Since the points will really “tokenize” something in the real world, this seems to be a good match for a ERC token (20 or 721), I think :slight_smile:
  2. It would seem to me that the number of points a user has could be equal to the number of tokens they own
  3. Or, would is be better to somehow keep track of the point value in a different way?

When I say off-chain, I’m referring to the data that will be stored in a database and not on the blockchain (including the ethereum account addresses for users); I hope I’m using the “off-chain” term correctly.

Hoping some of you might have experience/best practices in this and be OK to provide your insight. I appreciate the help!


1 Like

Hi @Steve_L,

Some points you may want to consider:

  • What are the regulatory requirements in the jurisdiction your users (and you) are?
  • Could you use a centralized database (do you really need a decentralized solution)?
  • Do points have a value?
  • How do users obtain points?
  • Can points be redeemed for anything?
  • Are points transferable? (assume that transferable points may flow from users least likely to redeem, to those most likely to redeem)
  • Will users have Ether? (should you consider using the Gas Station Network?)
  • How does the value of points compare with that of gas? (What is the minimum amount of points to use in a mint/transfer operation to make the transaction fee worthwhile)
  • If the points have value, then you need appropriate testing (e.g. Test smart contracts like a rockstar) and auditing of your system (e.g. OpenZeppelin performs audits

Some potential options:

  • Centralized database tracking users points
  • Centralized database tracking users points, with users having the option to withdraw points to tokens above a certain threshold e.g. 100 points (depending on their value).
  • Points purely tracked as tokens on Ethereum mainnet
  • Points tracked as tokens on a sidechain (e.g. Proof of Authority sidechain such as xDAI, where the network is not trustless but the transaction fees are lower), with potential option to transfer to Ethereum mainnet.

You may also want to look at:

Tagging community member: @paulinablaszk if they wanted to make any suggestions.

1 Like

I’m struggling/considering this. What I’m thinking here is that a decentralized solution makes the point value public, for transparency purposes…

as yes, the points would be transferrable to other users.

The usecase I’m thinking about are loyalty points that can be owned by one user but redeemable at/by various merchants…think, earn points at a business and redeem there or somewhere else or transfer to someone else to use.

Thanks for your thoughts on users having Ether as I was seeing this a hard on-boarding issue. I need to think about this so thanks for bringing Gas Station Network up as I did not know about this.

Thanks for the sidechain options as well as pointing to ERC777 as an option (looks like it gets you a two for one transaction that is an atomic approve/transferFrom so that cuts your transaction in half).

1 Like

Hi @Steve_L,

Likely to be two of the biggest challenges for your solution will be:

  • Abstracting the blockchain for most users and
  • The cost of transaction fees vs the value of points.

Feel free to ask more questions.

1 Like

Thanks for all the great advice. I’ll keep you posted on this… and yep, may ask more questions.

1 Like