-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arc-0020 #14
Open
EdVeralli
wants to merge
2
commits into
AleoNet:master
Choose a base branch
from
lambdaclass:arc-0020
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
arc-0020 #14
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,262 @@ | ||||||
--- | ||||||
arc: 0003 # Add the next sequence number | ||||||
title: ARC20_leo | ||||||
authors: eduardo.veralli | ||||||
discussion: https://github.com/AleoHQ/ARCs/discussions/13 | ||||||
topic: Application | ||||||
status: Draft | ||||||
created: 2022-09-21 | ||||||
--- | ||||||
|
||||||
## 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] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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 'balance_of' (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 | ||||||
``` | ||||||
[transfer_from] | ||||||
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) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
➡️ 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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.