SPDR API Chaincode ERC20 Methods

SPDR Admin's photo
SPDR Admin
·Dec 31, 2021·

2 min read

SPDR API Chaincode ERC20 Methods

This article provides documentation of all the SPDR API functions for the SmartContract ERC20 Methods.

type SmartContract

type SmartContract struct {

SmartContract provides functions for transferring tokens between accounts

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 (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 (s *SmartContract) BalanceOf(ctx contractapi.TransactionContextInterface, account string) (int, error)

BalanceOf returns the balance of the given account

func (s *SmartContract) ClientAccountBalance(ctx contractapi.TransactionContextInterface) (int, error)

ClientAccountBalance returns the balance of the requesting client's account

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 (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, amount int) error

Mint creates new tokens and adds them to minter's account balance

func (s *SmartContract) TotalSupply(ctx contractapi.TransactionContextInterface) (int, error)

TotalSupply returns the total token supply

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 (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.

Share this