I have a site, let's say a user solves a game, i want that user to be stored in a database that represents users who solved the game, users stored in this database will then be able to redeem tokens.

How do i establish the connection that the user solved the game and is now eligible to be stored in this database?

1 Answer 1


First, think in terms of what the blockchain/smart contract component of this is meant to prove. There are two obvious approaches:

  1. The contract decides the winner. In this approach, the contract itself enforces the rules of the game and web server and/or browsers defer to its decision.

  2. The contract records that an authority, say ... the web server, simply deemed that a given player is the winner of a given round. There is no evidence of an honest game in the contract, but there is a proof that the server signed a transaction to award the prize.

The choice will determine the structure of the contract in non-trivial ways.

Some very simplified sketches for illustration only:

Method 1:

contract Game {
  address[] public winners;
  function submitWinningMove(bytes32 move) public returns(bool success) {
    emit LogWinningMove(msg.sender, move);
    return true;

Method 2

contract Game {
  address[] public winners;
  function declareWinner(address winner) public onlyOwner returns(bool success) {
    emit LogWinnerDeclared(msg.sender, winner);

Hope it helps.

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.