Documentation ¶
Index ¶
- type BasicTokenInterface
- type Token
- func (t *Token) GetAllowance(stub shim.ChaincodeStubInterface, args []string) (*big.Int, error)
- func (t *Token) GetBalanceOf(stub shim.ChaincodeStubInterface, args []string) (*big.Int, error)
- func (t *Token) GetTotalSupply(stub shim.ChaincodeStubInterface) (*big.Int, error)
- func (t *Token) Transfer(stub shim.ChaincodeStubInterface, args []string, ...) error
- func (t *Token) TransferFrom(stub shim.ChaincodeStubInterface, args []string, ...) error
- func (t *Token) UpdateApproval(stub shim.ChaincodeStubInterface, args []string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicTokenInterface ¶
type BasicTokenInterface interface { GetBalanceOf(stub shim.ChaincodeStubInterface, args []string) (*big.Int, error) GetTotalSupply(stub shim.ChaincodeStubInterface) (*big.Int, error) GetAllowance(stub shim.ChaincodeStubInterface, args []string) (*big.Int, error) Transfer(stub shim.ChaincodeStubInterface, args []string, getBalanceOf func(shim.ChaincodeStubInterface, []string) (*big.Int, error)) error TransferFrom(stub shim.ChaincodeStubInterface, args []string, getBalanceOf func(shim.ChaincodeStubInterface, []string) (*big.Int, error), getAllowance func(shim.ChaincodeStubInterface, []string) (*big.Int, error), ) error UpdateApproval(stub shim.ChaincodeStubInterface, args []string) error }
BasicTokenInterface consists of basic ERC20 methods
type Token ¶
type Token struct{}
Token basic implementation of BasicTokenInterface
func (*Token) GetAllowance ¶
GetAllowance checks the amount of tokens that an owner allowed a spender to transfer in behalf of the owner to another receiver.
* `args[0]` - the ID of owner.
* `args[1]` - the ID of spender
func (*Token) GetTotalSupply ¶
GetTotalSupply returns total number of tokens in existence
func (*Token) Transfer ¶
func (t *Token) Transfer(stub shim.ChaincodeStubInterface, args []string, getBalanceOf func(shim.ChaincodeStubInterface, []string) (*big.Int, error)) error
Transfer token from current caller to a specified address.
* `args[0]` - the ID of receiver.
* `args[1]` - the transfer amount.
* `getBalanceOf` - specifies the function of getting the initial balances of token sender & receiver.
func (*Token) TransferFrom ¶
func (t *Token) TransferFrom(stub shim.ChaincodeStubInterface, args []string, getBalanceOf func(shim.ChaincodeStubInterface, []string) (*big.Int, error), getAllowance func(shim.ChaincodeStubInterface, []string) (*big.Int, error), ) error
TransferFrom transfer tokens from token owner to receiver.
* `args[1]` - the ID of token owner.
* `args[1]` - the ID of receiver.
* `args[2]` - the transfer amount.
* `getBalanceOf` - defines the function of getting the initial balances of token owner & receiver.
* `getAllowance` - defines the function of getting the allowance that the current chaincode invoker can spend from the token owner, to transfer to the receiver.
func (*Token) UpdateApproval ¶
func (t *Token) UpdateApproval(stub shim.ChaincodeStubInterface, args []string) error
UpdateApproval approves the passed-in identity to spend/burn a maximum amount of tokens on behalf of the function caller.
* `args[0]` - the ID of approved user.
* `args[1]` - the maximum approved amount.