Skip to content

HX Token contract protocol proposal(HRC12) #12

@zoowii

Description

@zoowii

Valid hx token contracts must have some fixed APIs and offline APIs.

Indicate the token amount with a number without precision in all apis of token contracts

APIs

  • transfer: arg format: "toAddress,amount[,optional_memo]": transfer amount of token from caller to toAddress. caller can be other smart contract
  • transferFrom: arg format: "authorizerAddress,toAddress,amount[,optional_memo]": If authorizerAddress approved some balance(amountApproved) of this token to caller_address(user B). Then user B can use this API(transferFrom) to transfer at-most amountApproved of this token from authorizerAddress to other user. If this operation is successful, the amount of approved will be reduced.
  • approve: arg format: "spenderAddress,amount[,optional_memo]": caller approve amount of this token to spenderAddress. If this operation is successfully, then the spenderAddress can transferFrom at-most amount of this token to other users.

Offline APIs(for query execution)

  • tokenName: return name of this token(not unique)
  • tokenSymbol: return symbol of this token(not unique)
  • totalSupply: return total supply of this token
  • precision: return precision of this token. Precisions are 1, 10, 100, 1000, ... 100000000, etc.
  • balanceOf: arg format: "ownerAddress", return owner's token balance of this token
  • approvedBalanceFrom: arg format: "spenderAddress,authorizerAddress": query approved balance from authorizerAddress to spenderAddress
  • allApprovedFromUser: arg format: "authorizerAddress": query all approved balance from authorizerAddress

Events

HX token contracts must use some events to notify third-party to know token contract changes. At least need to include the following events:

  • Approved(json string of {from: authorizerAddress, spender: spenderAddress, amount: amount})
  • Transfer(json string of {from: fromAddress, to: toAddress, amount: transfer amount, memo: memo string})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions