erc20basic

package
v0.0.0-...-b1d75aa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

func (t *Token) GetAllowance(stub shim.ChaincodeStubInterface, args []string) (*big.Int, error)

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) GetBalanceOf

func (t *Token) GetBalanceOf(stub shim.ChaincodeStubInterface, args []string) (*big.Int, error)

GetBalanceOf sender by ID.

* `args[0]` - the ID of user.

func (*Token) GetTotalSupply

func (t *Token) GetTotalSupply(stub shim.ChaincodeStubInterface) (*big.Int, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL