The explorer is out of sync. The last synced block is 192 hours ago. Current block height: explorer: 2206528 / node: 2330631 / ref: 2330631

Program puzzle_game.aleo

Program ID
puzzle_game.aleo
Owner signature
sign1mkjcpk3hn5cqdgysup8jfkdt4lyl4vedm2wgeeec0pwa6vsh7vqj960d3qs8h6qdklyrgk095hpuj6aqdvsruc9jef4jgqcx6nwdzq60ku3az8jefhsnxk8m7ta0nx0fmcqptyyxchk6rpgql3arfe2eq8ydv3nn6924na68s0x85xgq8pxzm7n74c3pvzy6zm2ds9jzymsq72kptcs
Times called
3
Similar programs
Imports
-
Mappings
account (address -> PuzzleMoveII)
reward (u128 -> CLAIM_REWARD)
account_balance (address -> u64)
Structs
PuzzleMoveII
CLAIM_REWARD
Records
PuzzleMove
Game_ID
Functions
-
Transitions
main(public u32, u32) -> u32
start_game(address, u128) -> Game_ID finalize(address, u128)
move_puzzle(u64) -> PuzzleMove finalize(address, u64)
claim_puzzle_reward(address, u128) -> address finalize(address, u128)
end_game(u128) -> () finalize(address, u128)
Program Source Code (Aleo Instruction) Upload Leo source

program puzzle_game.aleo;

record PuzzleMove:
    owner as address.private;
    moves as u64.private;

record Game_ID:
    owner as address.private;
    game_id as u128.private;

struct PuzzleMoveII:
    player as address;
    last_move as u64;
    count_moves as u64;

struct CLAIM_REWARD:
    zk_id as u128;
    player as address;
    reward as u64;
    max_reward as u64;

mapping account:
    key as address.public;
    value as PuzzleMoveII.public;

mapping reward:
    key as u128.public;
    value as CLAIM_REWARD.public;

mapping account_balance:
    key as address.public;
    value as u64.public;

function main:
    input r0 as u32.public;
    input r1 as u32.private;
    add r0 r1 into r2;
    output r2 as u32.private;

function start_game:
    input r0 as address.private;
    input r1 as u128.private;
    is.eq aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m into r2;
    assert.eq r2 true;
    hash.bhp256 r1 into r3 as u128;
    cast aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m r3 into r4 as Game_ID.record;
    async start_game aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m r3 into r5;
    output r4 as Game_ID.record;
    output r5 as puzzle_game.aleo/start_game.future;
finalize start_game:
    input r0 as address.public;
    input r1 as u128.public;
    is.eq r0 aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m into r2;
    assert.eq r2 true;
    cast r1 r0 0u64 0u64 into r3 as CLAIM_REWARD;
    get.or_use reward[r1] r3 into r4;
    cast r1 r0 0u64 0u64 into r5 as CLAIM_REWARD;
    set r5 into reward[r1];

function move_puzzle:
    input r0 as u64.private;
    hash.keccak512 r0 into r1 as u64;
    cast self.caller r1 into r2 as PuzzleMove.record;
    async move_puzzle self.caller r0 into r3;
    output r2 as PuzzleMove.record;
    output r3 as puzzle_game.aleo/move_puzzle.future;
finalize move_puzzle:
    input r0 as address.public;
    input r1 as u64.public;
    cast r0 r1 0u64 into r2 as PuzzleMoveII;
    get.or_use account[r0] r2 into r3;
    assert.eq r0 r3.player;
    lte r3.count_moves 100u64 into r4;
    assert.eq r4 true;
    add r3.count_moves 1u64 into r5;
    cast r3.player r3.last_move r5 into r6 as PuzzleMoveII;
    set r6 into account[r0];

function claim_puzzle_reward:
    input r0 as address.private;
    input r1 as u128.private;
    async claim_puzzle_reward self.caller r1 into r2;
    output r0 as address.private;
    output r2 as puzzle_game.aleo/claim_puzzle_reward.future;
finalize claim_puzzle_reward:
    input r0 as address.public;
    input r1 as u128.public;
    hash.bhp256 r0 into r2 as address;
    cast r1 r0 0u64 0u64 into r3 as CLAIM_REWARD;
    get.or_use reward[r1] r3 into r4;
    is.eq r4.reward 0u64 into r5;
    assert.eq r5 true;
    lte r4.max_reward 10000u64 into r6;
    assert.eq r6 true;
    add r4.reward 100000u64 into r7;
    add r4.max_reward 1u64 into r8;
    cast r1 r0 r7 r8 into r9 as CLAIM_REWARD;
    set r9 into reward[r1];
    get.or_use account_balance[r0] 0u64 into r10;
    add r10 r4.reward into r11;
    set r11 into account_balance[r0];

function end_game:
    input r0 as u128.private;
    is.eq aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m self.caller into r1;
    assert.eq r1 true;
    async end_game self.caller r0 into r2;
    output r2 as puzzle_game.aleo/end_game.future;
finalize end_game:
    input r0 as address.public;
    input r1 as u128.public;
    cast r1 r0 0u64 0u64 into r2 as CLAIM_REWARD;
    get.or_use reward[r1] r2 into r3;
    is.eq r3.zk_id r1 into r4;
    assert.eq r4 true;
    is.eq r0 aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m into r5;
    assert.eq r5 true;
    remove reward[r1];

Block heightTimestampTransition IDFunction callState
2,000,7532024-04-13 03:49:29au1v38atqyeareeqweq38hk0rgwpa8jwdxhs5ptazzau8ce0k8agqzqchrx3vmove_puzzleAccepted
2,000,6912024-04-13 03:43:54au1lmxapp28q2mtve0dkthpea7qpq70769w8s0g9wey43s4926hf5xqcwr85vmove_puzzleAccepted
2,000,6442024-04-13 03:39:23au1c84lf0upvks8lvp2xwt25hmgffkn6s074xdp2u2jrvllr25ytursl0nusumove_puzzleAccepted






Not implemented