The explorer is out of sync. The last synced block is 184 hours ago. Current block height: explorer: 2206528 / node: 2325752 / ref: 2325751

Program puzzle_game3.aleo

Program ID
puzzle_game3.aleo
Owner signature
sign1mkewjm6htystvgwr7gfrxmwpwfm5956pm283cmaf7zzxcw3dwup2afnsvt2v9wq2md2qapm0cd5rf0fymnpwks0mtv7g6ne74n0czqz0ku3az8jefhsnxk8m7ta0nx0fmcqptyyxchk6rpgql3arfe2eq8ydv3nn6924na68s0x85xgq8pxzm7n74c3pvzy6zm2ds9jzymsq7xj2rsn
Times called
1
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(u128) -> Game_ID finalize(address, u128)
move_puzzle(u64, u128) -> PuzzleMove finalize(address, u64, u128)
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_game3.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 u128.private;
    is.eq aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m self.caller into r1;
    assert.eq r1 true;
    hash.bhp256 r0 into r2 as u128;
    cast aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m r2 into r3 as Game_ID.record;
    async start_game aleo1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m r2 into r4;
    output r3 as Game_ID.record;
    output r4 as puzzle_game3.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;
    input r1 as u128.private;
    hash.keccak512 r0 into r2 as u64;
    cast self.caller r2 into r3 as PuzzleMove.record;
    async move_puzzle self.caller r0 r1 into r4;
    output r3 as PuzzleMove.record;
    output r4 as puzzle_game3.aleo/move_puzzle.future;
finalize move_puzzle:
    input r0 as address.public;
    input r1 as u64.public;
    input r2 as u128.public;
    cast r2 r0 0u64 0u64 into r3 as CLAIM_REWARD;
    get.or_use reward[r2] r3 into r4;
    is.eq r4.zk_id r2 into r5;
    assert.eq r5 true;
    cast r0 r1 0u64 into r6 as PuzzleMoveII;
    get.or_use account[r0] r6 into r7;
    assert.eq r0 r7.player;
    lte r7.count_moves 100u64 into r8;
    assert.eq r8 true;
    add r7.count_moves 1u64 into r9;
    cast r7.player r7.last_move r9 into r10 as PuzzleMoveII;
    set r10 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_game3.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 r1 r4.zk_id into r5;
    assert.eq r5 true;
    is.eq r4.reward 0u64 into r6;
    assert.eq r6 true;
    lte r4.max_reward 10000u64 into r7;
    assert.eq r7 true;
    add r4.reward 100000u64 into r8;
    add r4.max_reward 1u64 into r9;
    cast r1 r0 r8 r9 into r10 as CLAIM_REWARD;
    set r10 into reward[r1];
    get.or_use account_balance[r0] 0u64 into r11;
    add r11 r4.reward into r12;
    set r12 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_game3.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,014,8522024-04-14 02:05:18au1v9u62f9a68hz5jfsppa4hmrs6fau36837qc4jv8668f0ud7p9qgs9t8g7jstart_gameAccepted






Not implemented