BUMO ATP 30 Protocol
brief introduction
ATP 30 (Account-based Tokenization Protocol) is "Non-Fungible Tokens", short for "NFT", which can be translated into non-interchangeable tokens. Simply put, each token is unique and cannot be exchanged.
Be careful:
- tokenId is unique within the scope of the contract
- tokenId can only be owned by one owner (i.e. address)
- An owner can have more than one NFTs, and its balance only counts the number.
- ATP 30 provides approve, transfer, and transferFrom Interface for transfer of ownership
standard
NTF ID
NTF ID, or tokenId, uses a unique identifier in the contract, and the ID of each NFT is not allowed to change during the life cycle of the smart contract. Recommended ways of implementation are: starting from 0, adding a new NFT, NTF ID plus 1
Token attribute
Token attributes can be queried by the tokenInfo function of the contract and stored in the account of the smart contract. Contains the following
variable | describe |
---|---|
id | Token Unique Identifier |
owner | Token owner |
description | Token description |
creationTime | Token creation time |
Be careful:
- id: Starting from 0, for each Token created, the id increases by 1.
- description: String length ranges from 1 to 200 K.
Event
Function issue,transfer,transferFrom,approve Events are triggered by calling the tlog interface to record a transaction log on the block chain, which records the details of function calls for user's convenience.
tlog is defined as follows:
tlog(topic,args...);
- tlog generates a transaction written on a block
- Topic: Log topic, must be string type, parameter length (0,128)
- args...: It can contain up to five parameters, which can be string, numeric or Boolean, with each parameter length (0,1024)
Function function
The functions in the BUMO ATP 30 protocol include issue,totalSupply,balanceOf,ownerOf,approve,transfer,transferFrom,tokensOfOwner,tokenInfo,name,symbol.
issue
-
function
Issuing a new Token.
-
Entry function
main
-
Parameter json structure
{ "method":"issue", "params": { "description": "demo" } }
-
json parameter
parameter describe description Token's Description -
function
function issue(description)
-
Return value
true or throw an exception
-
Event:
tlog('issue', sender, tokenId, description);
topic: Method name, here is'issue'
sender: Contract Call Account Address
TokenId: Transferred tokenId
Description: Token's description
totalSupply
-
function
Returns the total number of token s issued.
-
Entry function
query
-
Parameter json structure
{ "method":"totalSupply" }
-
Function:
function totalSupply()
-
Return value:
{ "result":{ "type": "string", "value": { "totalSupply": "2" } } }
balanceOf
-
function
Returns the total token of the specified account.
-
Entry function
query
-
Parameter json structure
{ "method":"balanceOf", "params":{ "address":"buQnTmK9iBFHyG2oLce7vcejPQ1g5xLVycsj" } }
-
json parameter
parameter describe address Account address -
Function:
function balanceOf(address)
-
Return value: the sum of tokens at the specified address
{ "result":{ "type": "number", "value": { "count": 1 } } }
ownerOf
-
function
Return to the owner of token.
-
Entry function
query
-
Parameter json structure
{ "method":"ownerOf", "params": { "tokenId": 1 } }
-
json parameter
parameter describe tokenId Token Unique Identity -
Function:
function ownerOf(tokenId)
-
Return value:
{ "result":{ "type": "string", "value": { "owner": "buQnTmK9iBFHyG2oLce7vcejPQ1g5xLVycsj" } } }
approve
-
function
The authorized account spender can transfer the token of the specified tokenId from the transaction sender account. Only the owner of token can invoke it.
-
Entry function
main
-
Parameter json structure
{ "method":"approve", "params":{ "spender":"buQnTmK9iBFHyG2oLce7vcejPQ1g5xLVycsj", "tokenId": 2 } }
-
json parameter
parameter describe spender Account address tokenId Token identifier -
function
function approve(spender, tokenId)
-
Return value
true or throw an exception
-
Event:
tlog('approve', sender, spender, tokenId);
topic: Method name, here's'approve'
sender: Contract Call Account Address
spender: Authorized Account Address
TokenId: Transferred tokenId
transfer
-
function
The token of the specified tokenId is transferred to the destination address to, and the log event must be triggered. Only the owner of token can invoke it.
-
Entry function
main
-
Parameter json structure
{ "method":"transfer", "params":{ "to":"buQnTmK9iBFHyG2oLce7vcejPQ1g5xLVycsj", "tokenId": 0 } }
-
json parameter
parameter describe to Target account address tokenId Token identifier -
function
function transfer(to, tokenId)
-
Return value
true or throw an exception
-
Event:
tlog('transfer', sender, to, tokenId);
topic: Method name, here is'transfer'
sender: Contract Call Account Address
to: Target Account Address
TokenId: Transferred tokenId
transferFrom
-
function
The log event must be triggered to send tokenId-specified tokenId from front to to. Before transferFrom, from must grant authorization to the initiator of the current transaction (that is, approve operation). Only token's authorization address can be invoked.
-
Entry function
main
-
Parameter json structure
{ "method":"transferFrom", "params":{ "from":"buQnTmK9iBFHyG2oLce7vcejPQ1g5xLVycsj", "to":"buQYH2VeL87svMuj2TdhgmoH9wSmcqrfBner", "tokenId": 1 } }
-
json parameter
parameter describe from Source account address to Target account address tokenId Token identifier -
function
function transferFrom(from,to,tokenId)
-
Return value
true or throw an exception
-
Event
tlog('transferFrom', sender, from, to, tokenId);
topic: Method name, here is'transferFrom'
sender: Contract Call Account Address
from: Source Account Address
to: Target Account Address
TokenId: Transferred tokenId
tokensOfOwner
-
function
Returns all token s of owner.
-
Entry function
query
-
Parameter json structure
{ "method":"ownerOf", "params": { "owner": "buQnTmK9iBFHyG2oLce7vcejPQ1g5xLVycsj" } }
-
json parameter
parameter describe owner Token Owner -
Function:
function ownerOf(tokenId)
-
Return value:
{ "result":{ "type": "Array", "value": { "tokens": [0, 2] } } }
tokenInfo
-
function
Returns Token's basic information.
-
Entry function
query
-
Parameter json structure
{ "method":"tokenInfo", "params":{ "tokenId": 0 } }
-
json parameter
parameter describe tokenId Token Unique Identity -
Function:
function tokenInfo(tokenId)
-
Return value:
{ "result":{ "type": "string", "value": { "tokenInfo": { "title": "demo", "author": "buQnTmK9iBFHyG2oLce7vcejPQ1g5xLVycsj", "info": "demo", "creationTime": "135665626565612" } } } }
name
-
function
Returns the name of the token set contained in the current contract.
-
Entry function
query
-
Parameter json structure
{ "method":"name" }
-
Function:
function name()
-
Return value:
{ "result":{ "type": "string", "value": { "name": "demo" } } }
symbol
-
function
Returns the symbol of the token set contained in the current contract.
-
Entry function
query
-
Parameter json structure
{ "method":"symbol" }
-
Function:
function symbol()
-
Return value:
{ "result":{ "type": "string", "value": { "symbol": "DM" } } }
Contract entry
init
-
When creating a contract, trigger the contract init entry function, which is responsible for the initialization of the contract when it is created.
-
function
function init(input_str){ }
-
Parametric Json structure
{ "params":{ "name":"DemoToken", "symbol":"DT" } }
-
Return value
true or throw an exception
main
-
Responsible for data writing, which includes the ____________ issue,transfer,transferFrom,approve.
-
Function body
function main(arg) { const data = JSON.parse(arg); const operation = data.operation || ''; const param = data.param || {}; switch (operation) { case 'issue': issue(param); break; case 'approve': approve(param.to, param.tokenId); break; case 'transfer': transfer(param.to, param.tokenId); break; case 'transferFrom': transferFrom(param.from, param.to, param.tokenId); break; default: throw '<Main interface passes an invalid operation type>'; } }
query
-
Responsible for data queries, which include totalSupply,balanceOf,ownerOf,tokensOfOwner,tokenInfo,name,symbol And other interfaces.
-
Function body
function query(arg) { let result = {}; let input = JSON.parse(input_str); if(input.method === 'name'){ result.name = name(); } else if(input.method === 'symbol'){ result = symbol(); } else if(input.method === 'tokenInfo'){ result = tokenInfo(input.tokenId); } else if(input.method === 'totalSupply'){ result.totalSupply = totalSupply(); } else if(input.method === 'balanceOf'){ result.balance = balanceOf(input.owner); } else if(input.method === 'ownerOf'){ result.owner = ownerOf(input.tokenId); } else if(input.method === 'tokensOfOwner'){ result.tokens = tokensOfOwner(input.owner); } else{ throw '<Query interface passes an invalid operation type>'; } return JSON.stringify(result); }