Skip to content

Latest commit

 

History

History
148 lines (119 loc) · 4.26 KB

hack.md

File metadata and controls

148 lines (119 loc) · 4.26 KB

Hacking

Setup

Pulling and setting the submodule

  1. git submodule update --remote --recursive

Run the local node:

  1. make sure you have local-node-setup.sh, store-instantiate-contracts.sh and docker/*.sh as executables
  2. run ./local-node-setup.sh
  3. run ./store-instantiate-contracts.sh

This will provide you with Admin and 10 players with chain balance in uscrt

Params

player pj-nft-xp scrt balance
1 0 1000
2 100 2000
3 200 2000
4 300 1000
5 300 10000
6 400 10000
7 400 10000
8 500 10000
9 0 0

Demo

Set up

  1. Run local chain
  2. Store contracts
  3. Instantiate pj-nft contract with account admin
    1. Initially NFT distribution 8 different NFTs at different levels belongs to different 8 accounts
    • admin Call BatchMintNFT with the set metadata
    • DAO calls MintNFTClones (for a few NFTs so new users can have some)
  4. Instantiate pj-dao contract with account admin
    1. Admin sends in scrt to pj DAO
    2. Provide the same 8 accounts (as NFT contract) with pjc
    3. Initialise to use the pj-nft contract address

Demo

  1. Describe rules

  2. Player 9 arrives on landing page

    1. Connect to wallet
    2. New Player page (button to start playing)
    3. DAO tx() -> joinDao() -> call back: on success redirect to user home page
    4. Dao contract mints NFT to player 9
    5. NFT display in player's inventory
  3. (optional) Player 9 attempts to starts game

    1. button to start game ()
    2. DAO tx() -> CreateNewGameRoom -> call back: Error::not_enough_scrt
    3. popup? button to collateralise
    4. NFT tx() -> collateral_init -> pending
  4. (optional) manually provide collateral (nodejs script?)

  5. Player 9 starts game again -> success

  6. Player 1 arrives on landing page

    1. Connect to wallet
    2. Game Query: Sees active games (the one with Player 9)
    3. NFT Query: Sees owned NFTs of wallet. use tokens query to get a list of token_ids then get each token's metadata via NftInfo query
     Tokens {
         owner: HumanAddr,
         /// optional address of the querier if different from the owner
         viewer: Option<HumanAddr>,
         /// optional viewing key
         viewing_key: Option<String>,
         /// paginate by providing the last token_id received in the previous query
         start_after: Option<String>,
         /// optional number of token ids to display
         limit: Option<u32>,
     },
    NftInfo { token_id: String },

    The NftInfo returned is in the form of:

     NftInfo {
         token_uri: Option<String>,
         extension: Option<Extension>,
     },
    • using the NftInfo.extensions.description as the xp
    • using the NftInfo.extension.attributes as the colour displays
    1. joins player 9 with join game with a selected dice set
    2. DAO tx() -> joinGame(nft_id) -> call back: Success (game_id) -> redirect to game page
  7. Player 1 and Player 9 roll dice - button

    1. DAO tx() -> roll(game_id) -> call back: dice outcome {}
    2. Query: display dice outcome to both parties
  8. Reroll

    1. DAO tx() -> reroll(game_id, number_of_dic) -> dice outcome {}
  9. End game

    1. DAO tx() -> endGame(game_id) -> pending_other_player / game ended
    2. if game ended -> home page
  10. Show balance update

    • if Player 9 loses, DAO will exercise the transfers endGame() should trigger check collateral

pages

  1. Landing page
    1. All active / waiting games
    2. Join Dao button
  2. Join Dao popup?
    1. join Dao button
  3. Home page
    1. see all games
    2. join game
    3. start new game
    4. user balance
    5. user dice set nfts
  4. game page
    1. see what the other person has rolled
    2. see own dice metadata and info (query blockchain for metadata)
    3. reroll button after 1st roll

DAO contract msg / queries

  1. joinDao

  2. CreateNewGameRoom

  3. joinGame

  4. roll

  5. reroll

  6. endGame

  7. getActiveGames

NFT contract msg / queries

  1. mint

  2. setMetadata (from DAO)

  3. collateral_init

  4. collateralise

  5. uncollateralise

  6. getNFTs (dice level, colours, )