This contract implements simple lottery game with a 1 NEAR prize for the first person to guess the winning number.
Contract in src/lib.rs provides methods to 1. Set a winning lottery number 2. Guess the winning lottery number
Follow the guide provided by NEAR Org (https://www.near-sdk.io/zero-to-hero/basics/set-up-skeleton)
near create-account lottery.ryantan.testnet --masterAccount ryantan.testnet
*reminder: substitute the testnet accounts with your own
./build.sh
near deploy lottery.ryantan.testnet --wasmFile res/lottery.wasm \
--initFunction 'new' \
--initArgs '{"winner": "fe2592b42a727e977f055947385b709cc82b16b9a87f88c6abf3900d65d0cdc3"}'
*reminder: 'winner' is the sha256 hash of the number chosen. The value above is the sha256 hash of 4321
Wrong guess attempt:
near call lottery.ryantan.testnet guess_number '{"guess": "1234"}' --accountId ryantan.testnet
Correct guesss attempt:
near call lottery.ryantan.testnet guess_number '{"guess": "4321"}' --accountId ryantan.testnet
*reminder: substitute the testnet accounts with your own
Get more info at: