github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/examples/gno.land/p/demo/grc/grc20/igrc20.gno (about)

     1  package grc20
     2  
     3  import (
     4  	"std"
     5  
     6  	"gno.land/p/demo/grc/exts"
     7  )
     8  
     9  type IGRC20 interface {
    10  	exts.TokenMetadata
    11  
    12  	// Returns the amount of tokens in existence.
    13  	TotalSupply() uint64
    14  
    15  	// Returns the amount of tokens owned by `account`.
    16  	BalanceOf(account std.Address) (uint64, error)
    17  
    18  	// Moves `amount` tokens from the caller's account to `to`.
    19  	//
    20  	// Returns an error if the operation failed.
    21  	Transfer(to std.Address, amount uint64) error
    22  
    23  	// Returns the remaining number of tokens that `spender` will be
    24  	// allowed to spend on behalf of `owner` through {transferFrom}. This is
    25  	// zero by default.
    26  	//
    27  	// This value changes when {approve} or {transferFrom} are called.
    28  	Allowance(owner, spender std.Address) (uint64, error)
    29  
    30  	// Sets `amount` as the allowance of `spender` over the caller's tokens.
    31  	//
    32  	// Returns an error if the operation failed.
    33  	//
    34  	// IMPORTANT: Beware that changing an allowance with this method brings the risk
    35  	// that someone may use both the old and the new allowance by unfortunate
    36  	// transaction ordering. One possible solution to mitigate this race
    37  	// condition is to first reduce the spender's allowance to 0 and set the
    38  	// desired value afterwards:
    39  	// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
    40  	Approve(spender std.Address, amount uint64) error
    41  
    42  	// Moves `amount` tokens from `from` to `to` using the
    43  	// allowance mechanism. `amount` is then deducted from the caller's
    44  	// allowance.
    45  	//
    46  	// Returns an error if the operation failed.
    47  	TransferFrom(from, to std.Address, amount uint64) error
    48  }
    49  
    50  // Emitted when `value` tokens are moved from one account (`from`) to another (`to`).
    51  //
    52  // Note that `value` may be zero.
    53  type TransferEvent struct {
    54  	From  std.Address
    55  	To    std.Address
    56  	Value uint64
    57  }
    58  
    59  // Emitted when the allowance of a `spender` for an `owner` is set by
    60  // a call to {approve}. `value` is the new allowance.
    61  type ApprovalEvent struct {
    62  	Owner   std.Address
    63  	Spender std.Address
    64  	Value   uint64
    65  }