Skip to content

Instantly share code, notes, and snippets.

@fullkomnun
Created June 16, 2025 20:10
Show Gist options
  • Save fullkomnun/0f40413d9c75e37a66f7fa80c8046ce5 to your computer and use it in GitHub Desktop.
Save fullkomnun/0f40413d9c75e37a66f7fa80c8046ce5 to your computer and use it in GitHub Desktop.
program example_program1.aleo {
mapping data_map: address => u8;
// transition is executed off-chain
async transition save_sum(private a: u8, private b: u8) -> (u8, Future) {
let sum: u8 = a + b;
return (sum, finalize_save_sum(self.caller, sum));
}
// finalize is executed on-chain
async function finalize_save_sum(caller: address, sum: u8) {
data_map.set(caller, sum);
}
}
@fullkomnun
Copy link
Author

program example_program2.aleo {
    record Token {
        owner: address,
        amount: u128
    }
    transition private_transfer_token(private receiver: address, private token: Token) -> Token {
        let new_token: Token = Token {
            owner: receiver,
            amount: token.amount
        };
        return new_token;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment