github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/reference/stdlibs/std/banker.md (about)

     1  ---
     2  id: banker
     3  ---
     4  
     5  # Banker
     6  View concept page [here](../../../concepts/stdlibs/banker.md).
     7  
     8  ```go
     9  type BankerType uint8
    10  
    11  const (
    12      BankerTypeReadonly BankerType = iota
    13      BankerTypeOrigSend
    14      BankerTypeRealmSend
    15      BankerTypeRealmIssue
    16  )
    17  
    18  type Banker interface {
    19      GetCoins(addr Address) (dst Coins)
    20      SendCoins(from, to Address, coins Coins)
    21      IssueCoin(addr Address, denom string, amount int64)
    22      RemoveCoin(addr Address, denom string, amount int64)
    23  }
    24  ```
    25  
    26  ## GetBanker
    27  Returns `Banker` of the specified type.
    28  
    29  #### Parameters
    30  - `BankerType` - type of Banker to get:
    31      - `BankerTypeReadonly` - read-only access to coin balances
    32      - `BankerTypeOrigSend` - full access to coins sent with the transaction that calls the banker
    33      - `BankerTypeRealmSend` - full access to coins that the realm itself owns, including the ones sent with the transaction
    34      - `BankerTypeRealmIssue` - able to issue new coins
    35  
    36  #### Usage
    37  
    38  ```go
    39  banker := std.GetBanker(std.<BankerType>)
    40  ```
    41  ---
    42  
    43  ## GetCoins
    44  Returns `Coins` owned by `Address`.
    45  
    46  #### Parameters
    47  - `addr` **Address** to fetch balances for
    48  
    49  #### Usage
    50  
    51  ```go
    52  coins := banker.GetCoins(addr)
    53  ```
    54  ---
    55  
    56  ## SendCoins
    57  Sends `coins` from address `from` to address `to`. `coins` needs to be a well-defined
    58  `Coins` slice.
    59  
    60  #### Parameters
    61  - `from` **Address** to send from
    62  - `to` **Address** to send to
    63  - `coins` **Coins** to send
    64  
    65  #### Usage
    66  ```go
    67  banker.SendCoins(from, to, coins)
    68  ```
    69  ---
    70  
    71  ## IssueCoin
    72  Issues `amount` of coin with a denomination `denom` to address `addr`.
    73  
    74  #### Parameters
    75  - `addr` **Address** to issue coins to
    76  - `denom` **string** denomination of coin to issue
    77  - `amount` **int64** amount of coin to issue
    78  
    79  #### Usage
    80  ```go
    81  banker.IssueCoin(addr, denom, amount)
    82  ```
    83  ---
    84  
    85  ## RemoveCoin
    86  Removes (burns) `amount` of coin with a denomination `denom` from address `addr`.
    87  
    88  #### Parameters
    89  - `addr` **Address** to remove coins from
    90  - `denom` **string** denomination of coin to remove
    91  - `amount` **int64** amount of coin to remove
    92  
    93  #### Usage
    94  ```go
    95  banker.RemoveCoin(addr, denom, amount)
    96  ```