-
Notifications
You must be signed in to change notification settings - Fork 9
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
BMIP-0010 #5
Open
only4sim
wants to merge
9
commits into
BytomDAO:master
Choose a base branch
from
only4sim:BMIP-only4sim-arrays
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
BMIP-0010 #5
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a58976d
Add arrays
cf8204e
Correct1
75f4f6e
Correct2
59c2ecb
mediawiki
a795df0
nowiki
40c6472
strong
0f2918a
Update BMIP-only4sim-arrays.mediawiki
only4sim 6af0511
Update BMIP-only4sim-arrays.mediawiki
only4sim ee04d6a
Rename BMIP-only4sim-arrays.mediawiki to BMIP-0010.mediawiki
only4sim 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,57 @@ | ||
<pre> | ||
BMIP: | ||
Layer: Contracts | ||
Title: Bytom: Arrays in Contracts | ||
Author: Stieg Li <only4sim@outlook.com> | ||
Comments-Summary: No comments yet. | ||
Comments-URI: | ||
Status: Draft | ||
Type: | ||
Created: 2019-03-10 | ||
</pre> | ||
|
||
==Abstract== | ||
|
||
This BMIP describes a specification that how to use arrays in contracts. | ||
|
||
==Motivation== | ||
|
||
Bytom aims to be an interactive protocol of multiple byte assets, which can benefit bonds, notes, contracts, and decentralized exchanges. However, current contracts do not support array type, which means that even the same type of data cannot be batch processed within a contract. For example, even for a bond, each investor needs to generate a new contract. This standard will allow arrays in a smart contract. Through a standard type, the contract will be able to use mutable sequences. This standard will simplify the implementation of contracts, and help achieve Turing complet of the equity. | ||
|
||
==Specification== | ||
|
||
Arrays are mutable sequences which are formed by placing a comma-separated list of expressions in square brackets. The indices of arrays are zero-based and any type of elements can be arrays' elements. | ||
|
||
'''Define:''' | ||
{| | ||
| '''Type''' || '''Define''' || '''Example''' | ||
|- | ||
| Fixed-size array || <pre> define identifier : TypeName [Size] = [expr1, expr2, ..., exprSize]</pre> || <pre> define value : Integer <nowiki>[5] = [amount1, amount2, ..., amount5]</pre> | ||
|- | ||
| Dynamically-sized array || <pre> define identifier : TypeName [] = [expr1, expr2, ..., exprSize]</pre> || <pre> define value : Integer <nowiki>[] = [amount1, amount2, ..., amount5]</pre> | ||
|} | ||
|
||
'''TypeName:''' Integer, Amount, Boolean, String, Hash, Asset, PublicKey, Signature, Program. | ||
|
||
'''Functions:''' | ||
{| | ||
| '''Name''' || '''Meaning''' | ||
|- | ||
| length || Yield the length of the array. | ||
|- | ||
| push || Removes and Returns the last element in the array. | ||
|} | ||
|
||
==Application== | ||
This BMIP could be wildly used in bonds, games, asset management and decentralized exchanges. | ||
|
||
'''Example:''' | ||
<pre> | ||
//Define the remaining amount of the six bonds. | ||
define reAmount : Integer [6] = [100, 24, 55, 19, 90, 36] | ||
</pre> | ||
|
||
==References== | ||
|
||
* [https://solidity.readthedocs.io/en/v0.5.5/types.html#arrays Solidity Arrays] | ||
* [https://docs.python.org/2/tutorial/datastructures.html The Python Tutorial More on Lists] |
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.
BMIP: 10