From b5ae4b509786e244ef06c79c6115112cf026a866 Mon Sep 17 00:00:00 2001 From: Eduardo Damian Veralli Date: Wed, 21 Sep 2022 15:38:44 -0300 Subject: [PATCH 1/2] arc-0020 --- arc-0020/README.md | 340 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 arc-0020/README.md diff --git a/arc-0020/README.md b/arc-0020/README.md new file mode 100644 index 0000000..9cac8a2 --- /dev/null +++ b/arc-0020/README.md @@ -0,0 +1,340 @@ +--- +arc: 0003 # Add the next sequence number +title: ARC20_leo # Title +authors: eduardo.veralli # Add all Github usernames, emails, and/or full names +discussion: # Create a 'Github Discussion' titled 'ARC-XXXX: {TITLE}` +topic: Application # Choose: Protocol, Network, or Application +status: Draft +created: 2022-09-21 # Date +--- + +## Abstract + +Implementation of the 6 mandatory rules in Leo Programming Language so that they can be invoked in a Smart contract. + +They are: **balance_of**, **total_supply**, **approve**, **transfer_from**, **transfer**, and **allowance**. + +ARC20 includes 3 optional rules. They are: **decimals**, **name**, **symbol**. + +This is a WIP at [ARC20_leo](https://github.com/Entropy1729/ARC20_leo) + + + +## Specification + +### Mandatory functions + +#### To run *balance_of* function: + +Input file ARC20_leo/inputs/arc20_leo.in +``` +[balanceof] +owner_balance: Balance = Balance { + owner: aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7, + gates: 0u64, + amount: 269u64, + _nonce: 0group, +}; +``` + +`leo run balance_of` + +Console output +``` + • Executing 'arc20_leo.aleo/balance_of'... + • Executed 'balanceof' (in 11642 ms) + +➡️ Output + + • 269u64 +``` + +#### To run *total_supply* function: + +Input file ARC20_leo/inputs/arc20_leo.in +``` +[total_supply] +amount_supply: u64 = 1729u64; +``` + +`leo run total_supply` + +Console output. +``` + • Executing 'arc20_leo.aleo/total_supply'... + • Executed 'total_supply' (in 5944 ms) + +➡️ Output + + • 1729u64 +``` + +#### To run *approve* function: + +Input file ARC20_leo/inputs/arc20_leo.in +``` +[approve] +owner: address = aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7; +amount_owner: u64 = 164u64; +spender: address = aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau; +amount_desired: u64 = 64u64; +``` + +`leo run approve` + +Console output. +``` + • Executing 'arc20_leo.aleo/approve'... + • Executed 'approve' (in 9745 ms) + +➡️ Output + + • true +``` + +#### To run *transfer_from* function: + +Input file ARC20_leo/inputs/arc20_leo.in +``` +[test_transferfrom] +from_balance: Balance = Balance { + owner: aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7, + gates: 0u64, + amount: 25u64, + _nonce: 0group, +}; +from: address = aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7; +to_address: address = aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau; +to_gates: u64 = 0u64; +to_amount: u64 = 30u64; +amount: u64 = 5u64; +``` +`leo run transfer_from` + +Console output. +``` + • Executing 'arc20_leo.aleo/transfer_from'... + • Executed 'transferfrom' (in 21740 ms) + +➡️ Outputs + + • { + owner: aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7.private, + gates: 0u64.private, + amount: 20u64.private, + _nonce: 6431287615986696097612324621785026814136142669749924915411966793544219414836group.public +} + • aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau + • 35u64 + • 0u64 +``` + +#### To run *transfer* function: + +Input file ARC20_leo/inputs/arc20_leo.in +``` +[transfer] +to_balance: Balance = Balance { + owner: aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7, + gates: 0u64, + amount: 25u64, + _nonce: 0group, +}; +to: address = aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7; +amount: u64 = 5u64; +``` + +`leo run transfer` + +Console output. +``` + • Executing 'arc20_leo.aleo/transfer'... + • Executed 'transfer' (in 14139 ms) + +➡️ Output + + • { + owner: aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7.private, + gates: 0u64.private, + amount: 30u64.private, + _nonce: 5223267181059685515422878880245687591758320347768724919987298470390181053809group.public +} +``` + +#### To run *allowance* function: +Input file ARC20_leo/inputs/arc20_leo.in +``` +[allowance] +owner: address = aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7; +spender: address = aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau; +balance_owner: Balance = Balance { + owner: aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7, + gates: 0u64, + amount: 250u64, + _nonce: 0group, +}; +amount_remaining: u64 = 78u64; + +``` + +`leo run allowance` + +Console output. +``` + • Executing 'arc20_leo.aleo/allowance'... + • Executed 'allowance' (in 16274 ms) + +➡️ Output + + • 78u64 +``` + +### Optional functions +ARC20 includes 3 optional rules. They are: **decimals**, **name**, and **symbol**. + +#### To run *decimals* function: +Input file ARC20_leo/inputs/arc20_leo.in +``` +[decimals] +quantity_decimals: u64 = 8u64; +``` + +`leo run decimals` + +Console output. +``` + • Executing 'arc20_leo.aleo/decimals'... + • Executed 'decimals' (in 4244 ms) + +➡️ Output + + • 8u64 +``` + +#### To run *name* function: +Input file ARC20_leo/inputs/arc20_leo.in +``` +[name] +is_dummmy: u64 = 0u64; +``` + +`leo run name` + +Console output. +``` + • Executing 'arc20_leo.aleo/name'... + • Executed 'name' (in 6431 ms) + +➡️ Outputs + + • 65u64 + • 76u64 + • 69u64 + • 79u64 +``` + +#### To run *symbol* function: +Input file ARC20_leo/inputs/arc20_leo.in +``` +[symbol] +is_dummmy: u64 = 0u64; +``` + +`leo run symbol` + +Console output. +``` + • Executing 'arc20_leo.aleo/symbol'... + • Executed 'symbol' (in 6450 ms) + +➡️ Outputs + + • 76u64 + • 69u64 + • 79u64 +``` + + + +### Test Cases + +#### To run **Test** functions: +In every ARC20 function the input values are declared in ```\input\arc20_leo.in```. + +Each Test function uses the algorithm of the original function and compares its output with the values coded into the test function. + +In case the comparison is successful, the Test function will return True in a boolean variable. + + + + + + + + + + + + + + + + + + + + From 67f97a87246a16dfb6759e90c7b17b09ba121688 Mon Sep 17 00:00:00 2001 From: EdVeralli Date: Wed, 21 Sep 2022 16:32:02 -0300 Subject: [PATCH 2/2] Update README.md Add reference for discussion and fix syntax errors Signed-off-by: EdVeralli --- arc-0020/README.md | 92 ++++------------------------------------------ 1 file changed, 7 insertions(+), 85 deletions(-) diff --git a/arc-0020/README.md b/arc-0020/README.md index 9cac8a2..94f2cdc 100644 --- a/arc-0020/README.md +++ b/arc-0020/README.md @@ -1,11 +1,11 @@ --- arc: 0003 # Add the next sequence number -title: ARC20_leo # Title -authors: eduardo.veralli # Add all Github usernames, emails, and/or full names -discussion: # Create a 'Github Discussion' titled 'ARC-XXXX: {TITLE}` -topic: Application # Choose: Protocol, Network, or Application +title: ARC20_leo +authors: eduardo.veralli +discussion: https://github.com/AleoHQ/ARCs/discussions/13 +topic: Application status: Draft -created: 2022-09-21 # Date +created: 2022-09-21 --- ## Abstract @@ -17,18 +17,6 @@ They are: **balance_of**, **total_supply**, **approve**, **transfer_from**, **tr ARC20 includes 3 optional rules. They are: **decimals**, **name**, **symbol**. This is a WIP at [ARC20_leo](https://github.com/Entropy1729/ARC20_leo) - - ## Specification @@ -52,7 +40,7 @@ owner_balance: Balance = Balance { Console output ``` • Executing 'arc20_leo.aleo/balance_of'... - • Executed 'balanceof' (in 11642 ms) + • Executed 'balance_of' (in 11642 ms) ➡️ Output @@ -106,7 +94,7 @@ Console output. Input file ARC20_leo/inputs/arc20_leo.in ``` -[test_transferfrom] +[transfer_from] from_balance: Balance = Balance { owner: aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7, gates: 0u64, @@ -264,17 +252,6 @@ Console output. • 79u64 ``` - - ### Test Cases #### To run **Test** functions: @@ -283,58 +260,3 @@ In every ARC20 function the input values are declared in ```\input\arc20_leo.in` Each Test function uses the algorithm of the original function and compares its output with the values coded into the test function. In case the comparison is successful, the Test function will return True in a boolean variable. - - - - - - - - - - - - - - - - - - - -