-
Notifications
You must be signed in to change notification settings - Fork 13
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
AIP-041 - Aion Fungible Token Standard #41
Comments
ToDo: update the standard function name with AIP number |
|
Changing the status to Discussion |
Note that java smart contracts do not enforce any kind of canonical encoding of method invocations or types. The standard will have to specify the encoding & decoding of these things. |
Summary
A fungible token standard to meet the functionality requirements of current dApp developers. This AIP is based on AIP 004. The reference implementation is in Java and compatible with Aion AVM.
Value Proposition
To enable the creation and management of innovative fungible digital assets on the Aion blockchain.
Motivation
The primary motivation for the proposal is to provide the dApp's that are building on the Aion blockchain(AVM) with a common standard to implement fungible tokens.
Non-Goals
The scope of this standard is limited to on-chain functionality for fungible tokens. This standard does not address cross-chain functionalities across bridges.
Success Metrics
There are two key indicators of success for this standard:
Description
Fungible tokens have proven to be one of the core building blocks of the current decentralized web era. This next-generation fungible token standard reflects the evolving needs of dApp developers for core functionality and security.
The Aion Fungible Token Standard has been designed to address the shortcomings of token standards on other existing blockchains by blurring the line between layer one and layer two. At the core of the design is the ability to perform token transfers while maintaining security and stable total supply. Additional features include safe transfers, token callbacks, and mint/burn interface.
This standard aims to provide a reliable interface which 3rd party tools can use when building products on top of Aion.
High-Level Architecture
TBD.
Specification
Definitions
Methods
Token Information
Functions detailed below MUST be implemented.
AIP041Name
functionThe following rules MUST be applied regarding the token name:
AIP041Symbol
functionThe following rules MUST be applied regarding the token symbol:
AIP041Granularity
functionThe granularity is the smallest number of tokens (the basic unit in the internal denomination, nAmp) which MAY be minted, sent and burned in any transaction.
The following rules MUST be applied regarding the token granularity:
1
.revert
.AIP041TotalSupply
functionThe following rules MUST be applied regarding the token total supply:
18
. Therefore,the initial total supply should be set as inthe desired supply * 10^18
to assure the precision.For example, if your desired initial total supply is 1,234 tokens, then it should be set to 1, 234 * 10^18 upon creation.
AIP041BalanceOf
functionToken Creation
AIP041TokenCreated
eventIndicate the initial
totalSupply
of a new token created bycreator
address. This event MUST be emitted upon a token creation process.Operators
An
operator
is an address which is allowed to send and burn tokens on behalf of another token holder address.The following rules apply to any operator:
AIP041IsOperatorFor
MUST returntrue
.AIP041IsOperatorFor
MUST returnfalse
.AIP041AuthorizedOperator
event with the correct values when a token holder authorizes an address as its operator as defined in theAIP041AuthorizedOperator
Event.AIP041RevokedOperator
event with the correct values when a token holder revokes an address as its operator as defined in theAIP041RevokedOperator
Event.AIP041AuthorizedOperator
eventIndicates the authorization of
operator
as an operator fortokenHolder
.RevokedOperator
eventIndicates the revocation of
operator
as an operator fortokenHolder
.The
AIP041AuthorizeOperator
,AIP041RevokeOperator
andAIP041IsOperatorFor
functions described below MUST be implemented to manage operators.Token contracts MAY implement other functions to manage operators.
AIP041AuthorizeOperator
functionSet a third party
operator
address as an operator ofBlockchain.getCaller()
to send and burn tokens on its behalf.AIP041RevokeOperator
functionRemove the right of the
operator
address to be an operator forBlockchain.getCaller()
and to send and burn tokens on its behalf.AIP041IsOperatorFor
functionIndicate whether the
operator
address is an operator of thetokenHolder
address.Sending Tokens
When an operator sends an
amount
of tokens from a token holder to a recipient with the associateddata
andoperatorData
, the token contract MUST apply the following rules:amount
.amount
.amount
—such that its resulting balance is greater or equal to zero (0
) after the send.AIP041Sent
event with the correct values as defined in theAIP041Sent
Event.operatorData
.data
andoperatorData
MUST be immutable during the entire send process—hence the samedata
andoperatorData
MUST be used to call both hooks and emit theSent
event.The token contract MUST
revert
when sending in any of the following cases:0
).The token contract MAY send tokens from many token holders, to many recipients, or both. In this case:
amount
.amount
.API041Sent
event MUST be emitted for every token holder and recipient pair with the corresponding amount for each pair.API041Sent
event MUST be equal to the total sentamount
.0
) tokens are valid and MUST be treated as a regular send.Optional Implementation:
callSender
hook before updating the state.callRecipient
hook after updating the state.I.e.,
callSender
may be called first, then the balances MUST be updated to reflect the send, and finallycallRecipient
may be called afterward. Thus abalanceOf
call withintokensToSend
returns the balance of the address before the send and abalanceOf
call withintokensReceived
returns the balance of the address after the send.NOTE: The
data
field contains extra information intended for, and defined by the recipient— similar to the data field in a regular ether send transaction. Typically,data
is used to describe the intent behind the send. TheoperatorData
MUST only be provided by the operator. It is intended more for logging purposes and particular cases. (Examples include payment references, cheque numbers, countersignatures and more.) In most of the cases the recipient would ignore theoperatorData
, or at most, it would log theoperatorData
.AIP041Sent
eventIndicate a send of
amount
of tokens from thefrom
address to theto
address by theoperator
address.The
AIP041Send
andAIP041OperatorSend
functions described below MUST be implemented to send tokens.Token contracts MAY implement other functions to send tokens.
AIP041Send
functionSend the
amount
of tokens from the addressBlockchain.getCaller()
to the addressto
.The operator and the token holder MUST both be the
Blockchain.getCaller()
.AIP041OperatorSend
functionSend the
amount
of tokens on behalf of the addressfrom
to the addressto
.The operator MUST be
Blockchain.getCaller()
. The value offrom
MAY be0x0
, then thefrom
(token holder) used for the send MUST beBlockchain.getCaller()
(theoperator
).Reminder: If the operator address is not an authorized operator of the
from
address, then the sending process MUSTrevert
.NOTE:
from
andBlockchain.getCaller()
MAY be the same address. I.e., an address MAY callAIP041OperatorSend
for itself. This call MUST be equivalent tosend
with the addition that the operator MAY specify an explicit value foroperatorData
(which cannot be done with thesend
function).Minting Tokens
Minting tokens is the act of producing new tokens. This standard intentionally does not define specific functions to mint tokens. This intent comes from the wish not to limit the use of the standard as the minting process is generally an implementation detail.
Nonetheless, the rules below MUST be respected when minting for a recipient:
Minted
event with the correct values as defined in the [AIP041Minted
Event][minted].data
andissuerData
MUST be immutable during the entire mint process—hence the samedata
andissuerData
may be used to call thecallRecipient
hook and emit theMinted
event.The token contract MUST
revert
when minting in any of the following cases:AIP041TokenRecipient
interface via [AIP008].NOTE: The initial token supply at the creation of the token contract MUST be considered as minting for the amount of the initial supply to the address (or addresses) receiving the initial supply.
The token contract MAY mint tokens for multiple recipients at once. In this case:
AIP041Minted
event MUST be emitted for every recipient with the corresponding amount for each recipient.Minted
event MUST be equal to the total mintedamount
.NOTE: Minting an amount of zero (
0
) tokens is valid and MUST be treated as a regular mint.NOTE: The
data
field contains extra information intended for, and defined by the recipient— similar to the data field in a regular ether send transaction. Typically,data
is used to describe the intent behind the mint. TheissuerData
MUST only be provided by the issuer. It is intended more for logging purposes and particular cases. (Examples include payment references, cheque numbers, countersignatures and more.) In most of the cases the recipient would ignore theoperatorData
, or at most, it would log theissuerData
.AIP041Minted
eventIndicate the minting of
amount
of tokens to theto
address by theissuer
address.NOTE: This event MUST NOT be emitted outside of a mint process.
Burning Tokens
Burning tokens is the act of destroying existing tokens. AIP explicitly defines two functions to burn tokens (
API041burn
andAIP041OperatorBurn
). These functions facilitate the integration of the burning process in wallets and dapps. However, the token contract MAY prevent some or all token holders from burning tokens for any reason. The token contract MAY also define other functions to burn tokens.The rules below MUST be respected when burning the tokens of a token holder:
AIP041Burned
event with the correct values as defined in theAIP041Burned
Event.burnerData
MUST be immutable during the entire burn process—hence the sameburnerData
may be used to call thecallSender
hook and emit theAIP041Burned
event.The token contract MUST
revert
when burning in any of the following cases:The token contract MAY burn tokens for multiple token holders at once. In this case:
AIP041Burned
event MUST be emitted for every token holder with the corresponding amount for each token holder.Burned
event MUST be equal to the total burnedamount
.NOTE: Burning an amount of zero (
0
) tokens is valid and MUST be treated as a regular burn.AIP041Burned
eventIndicate the burning of
amount
of tokens from thefrom
address by theoperator
address.The
AIP041Burn
andAIP041OperatorBurn
functions described below MUST be implemented to burn tokens.Token contracts MAY implement other functions to burn tokens.
AIP041Burn
functionBurn the
amount
of tokens from the addressBlockchain.getCaller()
.The operator and the token holder MUST both be the
Blockchain.getCaller()
.AIP041OperatorBurn
functionBurn the
amount
of tokens on behalf of the addresstokenHolder
.The operator MUST be
Blockchain.getCaller()
. The value oftokenHolder
MAY be0x0
, then thetokenHolder
used for the burn MUST beBlockchain.getCaller()
(theoperator
).Reminder: If the operator address is not an authorized operator of the
tokenHolder
address, then the burn process MUSTrevert
.Java Smart Contract ABI
1
org.aion.AIP041TokenContract
Clinit: (String, String, int, BigInteger)
public static String AIP041Name()
public static String AIP041Symbol()
public static int AIP041Granularity()
public static BigInteger AIP041TotalSupply()
public static BigInteger AIP041BalanceOf(Address)
public static void AIP041AuthorizeOperator(Address)
public static void AIP041RevokeOperator(Address)
public static boolean AIP041IsOperatorFor(Address, Address)
public static void AIP041Send(Address, BigInteger, byte[])
public static void AIP041OperatorSend(Address, Address, BigInteger, byte[], byte[])
public static void AIP041Burn(BigInteger, byte[])
public static void AIP041OperatorBurn(Address, BigInteger, byte[], byte[])
Logic
This standard is based on AIP-004 from Aion Network AIP. The following modifications have been made:
Risks & Assumptions
Test Cases
Test
Implementations
Reference Implementation
Dependencies
Copyright
All AIP’s are public domain. Copyright waiver: https://creativecommons.org/publicdomain/zero/1.0/
The text was updated successfully, but these errors were encountered: