Lucky Roll is a lucky game that uses fair random number from Nois - a Proof of Stake blockchain protocol that allows developers to use secure, unbiased and cost efficient randomness via IBC
The game is hosted on Aura Network
-
Owner
Instantiatecontract with following parametersnois_proxyis nois proxy contract address in our chaintime_startis time start of game, format "2023-01-19 19:05:00Z" UTC+0time_endis time stop of game, format "2023-01-19 19:05:00Z" UTC+0
-
Owner can execute
resetcommand to reset game with same parameters asInstantiate -
Owner execute
set_white_listcommand to specify who can allowed to playing game -
Onwer execute
set_prizescommand to set prizes -
The game will be played in rounds, every time the
rollcommand is successful, the game will end a round. To play again, use the commandreset -
In the end, owner execute
rollcommand to distribute prizes for players
- Players execute
lucky_numbercommand to receive owned lucky number example:
export LUCKY_ROLL_CONTRACT=aura1r5xw9m0tlwlqg3uhseqq27tzhsn7m5vlc32fen977hswa8f2gy5shfjt43
aurad tx wasm execute $LUCKY_ROLL_CONTRACT \
'{"lucky_number" :{}}' \
--from <your-validator-signing-key> \
--chain-id euphoria-2 \
--gas-prices 0.025ueaura \
--gas=auto \
--gas-adjustment 1.4 \
--node=https://rpc.euphoria.aura.network:443/ \
--broadcast-mode=block \
--amount 300ueaura
- You can also query the state of all attendees using:
aurad query wasm contract-state smart \
$LUCKY_ROLL_CONTRACT \
'{"get_attendees": {}}' \
--node=https://rpc.euphoria.aura.network:443/
The game will allow a period from time_start to time_end to wait for all players to roll. After this period, the owner can execute command roll to distribute the prize
reset
Reset {
nois_proxy: String,
time_start: String,
time_end: String,
}- only allow onwer to execute
- will reset game
set_white_list
SetWhiteList {
attendees: Vec<String>
}- only allow owner to execute
- only executed in round
- specific players by wallet address
set_prizes
Setprizes {
prizes: Vec<String>
}- only allow owner to execute
- only executed in round
- this will make a message to Nois Proxy and will be shuffled randomly using NoisCallback (after execute
set_prizescommand, need to wait 1-2' for NoisCallback then you can execute another command likeroll)
roll
Roll {
}- only allow owner to execute
- only executed in round
- only executed before
time_end - this command will distribute prizes for all attendees base on prizes list and attendee's lucky number
- if success, it will end a round
lucky_number
LuckyNumber {
}- only allow WhiteList member to execute
- only executed before
time_startand aftertime_end - only executed in round
- make a message to Nois Proxy and receive NoisCallback as lucky number
get_prizes
GetPrizes{}- list all prizes
get_attendees
GetAttendees{}- list all attendees
get_distribute_prizes
GetDistributePrizes{}- list attendees and their prize
build wasm file
beaker wasm build
Store wasm file
export CODE_ID=$(aurad tx wasm store \
target/wasm32-unknown-unknown/release/lucky_roll.wasm \
--from <your-key> \
--chain-id euphoria-2 \
--gas=auto \
--gas-adjustment 1.4 \
--gas-prices 0.025ueaura \
--broadcast-mode=block \
--node=https://rpc.euphoria.aura.network:443/ -y \
|yq -r ".logs[0].events[1].attributes[1].value" )
Instantiate contract
export NOIS_PROXY=aura19z2hv8l87qwg8nnq6v76efjm2rm78rkdghq4rkxfgqrzv3usw8lq26rmwt
export TIME_START="2023-01-21 00:00:00Z"
export TIME_END="2023-01-21 23:59:59Z"
export LUCKY_ROLL_CONTRACT=$(aurad \
tx wasm instantiate $CODE_ID \
'{"nois_proxy": "'"$NOIS_PROXY"'","time_start":"'"$TIME_START"'","time_end":"'"$TIME_END"'"}' \
--label=lucky-roll \
--no-admin \
--from <your-key> \
--chain-id euphoria-2 \
--gas=auto \
--gas-adjustment 1.4 \
--broadcast-mode=block \
--node=https://rpc.euphoria.aura.network:443/ -y \
|yq -r '.logs[0].events[0].attributes[0].value' )
Executeexample
aurad tx wasm execute $LUCKY_ROLL_CONTRACT \
'{"lucky_number": {}}' \
--from <your-key> \
--gas-prices 0.025ueaura \
--gas=auto \
--gas-adjustment 1.3 \
--node=https://rpc.euphoria.aura.network:443/ \
--amount 300ueaura
Queryexample
aurad query wasm contract-state smart \
$LUCKY_ROLL_CONTRACT \
'{"get_attendees": {}}' \
--node=https://rpc.euphoria.aura.network:443/