Documentation
¶
Index ¶
- type SmartContract
- func (s *SmartContract) Allowance(ctx contractapi.TransactionContextInterface, owner string, spender string) (int, error)
- func (s *SmartContract) Approve(ctx contractapi.TransactionContextInterface, spender string, value int) error
- func (s *SmartContract) BalanceOf(ctx contractapi.TransactionContextInterface, account string) (int, error)
- func (s *SmartContract) ClientAccountBalance(ctx contractapi.TransactionContextInterface) (int, error)
- func (s *SmartContract) ClientAccountID(ctx contractapi.TransactionContextInterface) (string, error)
- func (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, amount int) error
- func (s *SmartContract) TotalSupply(ctx contractapi.TransactionContextInterface) (int, error)
- func (s *SmartContract) Transfer(ctx contractapi.TransactionContextInterface, recipient string, amount int) error
- func (s *SmartContract) TransferFrom(ctx contractapi.TransactionContextInterface, from string, to string, value int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SmartContract ¶
type SmartContract struct {
contractapi.Contract
}
SmartContract provides functions for transferring tokens between accounts
func (*SmartContract) Allowance ¶
func (s *SmartContract) Allowance(ctx contractapi.TransactionContextInterface, owner string, spender string) (int, error)
Allowance returns the amount still available for the spender to withdraw from the owner.
func (*SmartContract) Approve ¶
func (s *SmartContract) Approve(ctx contractapi.TransactionContextInterface, spender string, value int) error
Approve allows the spender to withdraw from the calling client's token account. The spender can withdraw multiple times if necessary, up to the value amount.
func (*SmartContract) BalanceOf ¶
func (s *SmartContract) BalanceOf(ctx contractapi.TransactionContextInterface, account string) (int, error)
BalanceOf returns the balance of the given account
func (*SmartContract) ClientAccountBalance ¶
func (s *SmartContract) ClientAccountBalance(ctx contractapi.TransactionContextInterface) (int, error)
ClientAccountBalance returns the balance of the requesting client's account
func (*SmartContract) ClientAccountID ¶
func (s *SmartContract) ClientAccountID(ctx contractapi.TransactionContextInterface) (string, error)
ClientAccountID returns the id of the requesting client's account. In this implementation, the client account ID is the clientId itself. Users can use this function to get their own account id, which they can then give to others as the payment address
func (*SmartContract) Mint ¶
func (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, amount int) error
Mint creates new tokens and adds them to minter's account balance
func (*SmartContract) TotalSupply ¶
func (s *SmartContract) TotalSupply(ctx contractapi.TransactionContextInterface) (int, error)
TotalSupply returns the total token supply
func (*SmartContract) Transfer ¶
func (s *SmartContract) Transfer(ctx contractapi.TransactionContextInterface, recipient string, amount int) error
Transfer transfers tokens from client account to recipient account. recipient account must be a valid clientID as returned by the ClientID() function.
func (*SmartContract) TransferFrom ¶
func (s *SmartContract) TransferFrom(ctx contractapi.TransactionContextInterface, from string, to string, value int) error
TransferFrom transfers the value amount from the "from" address to the "to" address. This function triggers a Transfer event.