# README
Kiesnet Token Chaincode
An account/balance based token
requirement
- kiesnet-id chaincode (devmode: kiesnet-cc-id)
- kiesnet-contract chaincode (devmode: kiesnet-cc-contract)
- knt-{token_code} chaincodes (devmode: knt-cc-{token_code})
Terms
- PAOT : personal(main) account of the token
- EOA : Externally Owned Accounts
API
method func
[arg1, arg2, ... ] {trs1, trs2, ... }
- method : query or invoke
- func : function name
- [arg] : mandatory argument
- [arg] : optional argument
- {trs} : mandatory transient
- {trs} : optional transient
invoke
account/create
[token_code, co-holders...] {"kiesnet-id/pin"}
- Create an account
- [token_code] : issued token code
- [co-holders...] : PAOTs (exclude invoker, max 127)
- If holders(include invoker) are more then 1, it creates a joint account. If not, it creates the PAOT.
query
account/get
[token_code|address]
- Get the account
- If the parameter is token code, it returns the PAOT.
- account types
- 0x00 : unknown
- 0x01 : personal
- 0x02 : joint
invoke
account/holder/add
[account, holder] {"kiesnet-id/pin"}
- Create a contract to add the holder
- [account] : the joint account address
- [holder] : PAOT of the holder to be added
invoke
account/holder/remove
[account, holder] {"kiesnet-id/pin"}
- Create a contract to remove the holder
- [account] : the joint account address
- [holder] : PAOT of the holder to be removed
query
account/list
[token_code, bookmark, fetch_size]
- Get account list
- If token_code is empty, it returns all account regardless of tokens.
- [fetch_size] : max 200, if it is less than 1, default size will be used (20)
invoke
account/suspend
[token_code] {"kiesnet-id/pin"}
- Suspend the PAOT
invoke
account/unsuspend
[token_code] {"kiesnet-id/pin"}
- Unsuspend the PAOT
query
balance/logs
[token_code|address, log_type, bookmark, fetch_size, starttime, endtime]
- Get balance logs
- If the parameter is token code, it returns logs of the PAOT.
- [fetch_size] : max 200, if it is less than 1, default size will be used (20)
- [starttime] : time(seconds) represented by int64
- [endtime] : time(seconds) represented by int64
- log types
- 0x00 : mint
- 0x01 : burn
- 0x02 : send
- 0x03 : receive
- 0x04 : deposit (create a pending balance)
- 0x05 : withdraw (from the pending balance)
- 0x06 : pay
- 0x07 : refund
- 0x08 : prune pay
- 0x09 : prune fee
- 0x0a : wrap
- 0x0b : unwrap
- 0x0c : wrap complete
- 0x0d : unwrap complete
query
balance/pending/get
[pending_balance_id]
- Get the pending balance
- pending types
- 0x00 : account
- 0x01 : contract
query
balance/pending/list
[token_code|address, sort, bookmark, fetch_size]
- Get pending balances list
- If the parameter is token code, it returns logs of the PAOT.
- [sort] : 'created_time' or 'pending_time'(default)
- [fetch_size] : max 200, if it is less than 1, default size will be used (20)
- pending types
- 0x00 : account
- 0x01 : contract
invoke
balance/pending/withdraw
[pending_balance_id] {"kiesnet-id/pin"}
- Withdraw the balance
query
fee/list
[token_code, bookmark, fetch_size, starttime, endtime]
- Get fee list of token
- [fetch_size] : max 200, if it is less than 1, default size will be used (20)
- [starttime] : time(seconds) represented by int64
- [endtime] : time(seconds) represented by int64
invoke
fee/prune
[token_code, ten_minutes_flag, endtime] {"kiesnet-id/pin"}
- prune the fees from last fee time to end_time. if end_time is not provided, prune to 10 mins lesser than current time(if ten_minutes_flag is set to true).
- Only holder of FeePolicy.TargetAddress is able to prune.
- [ten_minutes_flag] : Boolean if set to true, the end_time can't be greater than current time minus 10 minutes.
- [end_time]: to time for pruning
has_more
field is true in the response json string, it means there are more fees to prune given time period.
invoke
token/burn
[token_code, amount] {"kiesnet-id/pin"}
- Get the burnable amount and burn the amount.
- [amount] : big int
- If genesis account holders are more than 1, it creates a contract.
invoke
token/create
[token_code, co-holders...] {"kiesnet-id/pin"}
- Create(Issue) the token
- [token_code] : 3~6 alphanum
- [co-holders...] : PAOTs (exclude invoker, max 127)
- It queries meta-data of the token from the knt-{token_code} chaincode.
query
token/get
[token_code]
- Get the current state of the token
invoke
token/mint
[token_code, amount] {"kiesnet-id/pin"}
- Get the mintable amount and mint the amount.
- [amount] : big int
- If genesis account holders are more than 1, it creates a contract.
invoke
token/update
[token_code] {"kiesnet-id/pin"}
- // Get updated information from the token meta chaincode(e.g. knt-cc-pci) and save it to the ledger.
- [token_code] : issued token code. If the token is not issued, this function does nothing and returns success.
invoke
transfer
[sender, receiver, amount, memo, order_id, pending_time, expiry, extra-signers...] {"kiesnet-id/pin"}
- Transfer the amount of the token or create a contract
- [sender] : an account address, empty = PAOT
- [receiver] : an account address
- [amount] : big int
- [memo] : max 1024 charactors
- [order_id] : order ID (vendor specific)
- [pending_time] : time(seconds) represented by int64
- [expiry] : duration(seconds) represented by int64, multi-sig only
- [extra-signers...] : PAOTs (exclude invoker, max 127)
query
transfer/get
[order_id]
- Get the balance log by order id
- [order_id] : order ID (vender specific)
invoke
pay
[sender, receiver, amount, order_id, memo, expiry] {"kiesnet-id/pin"}
- pay the amount of positive token to the receiver or creaete a pay contract
- [sender]: an account address, TOKENCODE = PAOT
- [receiver] : an account address
- [amount] : big int
- [order_id] : order ID (vendor specific)
- [memo] : max 1024 charactors
- [expiry] : duration(seconds) represented by int64, multi-sig only
query
pay/get
[pay_id, order_id]
- Get the pay (unspent token)
- [pay_id] : pay ID
- [order_id] : order ID (vendor specific)
invoke
pay/refund
[original_pay_id, amount, memo, order_id ] {"kiesnet-id/pin"}
- refund the amount of token the based on original_pay_id
- [original_pay_id] : original_pay_id
- [amount]: the amount of token to refund. This value cannot be acculumated more than the original pay amount.
- [memo]: max 1024 charactors
- [order_id] : order ID (vendor specific)
invoke
pay/prune
[token_code|address, ten_minutes_flag, end_time] {"kiesnet-id/pin"}
- prune the pays from last pay time to end_time. if end_time is not provided, prune to 10 mins lesser than current time(if ten_minutes_flag is set to true).
- [ten_minutes_flag] : Boolean if set to true, the end_time can't be greater than current time minus 10 minutes.
- [end_time]: to time for pruning
has_more
field is true in the response json string, it means there are more pays to prune given time period.
query
pay/list
[token_code|address, sort_order, bookmark, fetchsize, start_time, end_time ]
- Get pay list
- If the 1st parameter is token code, it returns list of the PAOT.
- [sort_order] : "asc" ascending order. "desc" decending order. if not set, decending order is the default value.
- [fetch_size] : max 200, if it is less than 1, default size will be used (20)
- [starttime] : time(seconds) represented by int64
- [endtime] : time(seconds) represented by int64
invoke
wrap
[token_code|sender, ext_token_code, ext_address, amount, memo, order_id, expiry, extra-signers...]
- Wrap the amount of the token or create a contract
- [sender]: an account address, TOKENCODE = PAOT
- [ext_token_code] : external token code (eg. wpci)
- [ext_address] : external address(EOA)
- [amount] : big int
- [memo]: max 1024 charactors
- [order_id] : order ID (vendor specific)
- [expiry] : duration(seconds) represented by int64, multi-sig only
- [extra-signers...] : PAOTs (exclude invoker, max 127)
invoke
wrap/complete
[wrap_key, fee, ext_tx_id]
- When bridge receive wrap event, handling fee
- [wrap_key] : wrap tx hash (without '0x' prefix)
- [fee] : big int
- [ext_tx_id] : external tx hash (with '0x' prefix)
invoke
unwrap
[token_code|receiver, ext_token_code, ext_address, ext_tx_id, amount]
- Unwrap the amount of the token
- If the 1st parameter is token code, send amount to wrap address.
- [ext_token_code] : external token code (eg. wpci)
- [ext_address] : external address(EOA)
- [ext_tx_id] : external transaction id, for handling duplicate check
- [amount] : big int
query
ver
- Get version