Documentation
¶
Index ¶
- Constants
- type CurrencyContract
- func (c *CurrencyContract) CreatePlayer(ctx contractapi.TransactionContextInterface, id int64) error
- func (c *CurrencyContract) ExchangeInGameCurrency(ctx contractapi.TransactionContextInterface, userID, benAmountChange int64) error
- func (c *CurrencyContract) GetAllPlayers(ctx contractapi.TransactionContextInterface) ([]*types.Player, error)
- func (c *CurrencyContract) GetPlayer(ctx contractapi.TransactionContextInterface, id int64) (*types.Player, error)
- func (c *CurrencyContract) InitLedger(ctx contractapi.TransactionContextInterface) error
- func (c *CurrencyContract) PlayerExists(ctx contractapi.TransactionContextInterface, id int64) (bool, error)
- func (c *CurrencyContract) RecordBankTransaction(ctx contractapi.TransactionContextInterface, ...) error
- func (c *CurrencyContract) SetExchangeRate(ctx contractapi.TransactionContextInterface, newRate int64) error
Constants ¶
View Source
const PLAYER string = "PLAYER"
View Source
const TRANSACTION string = "TRANS"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CurrencyContract ¶
type CurrencyContract struct {
contractapi.Contract
ExchangeRate int64 `json:"exchangeRate"` // Exchange rate for USD to BEN conversion (3 decimal places)
}
CurrencyContract defines the Smart Contract structure.
func (*CurrencyContract) CreatePlayer ¶
func (c *CurrencyContract) CreatePlayer(ctx contractapi.TransactionContextInterface, id int64) error
CreatePlayer adds a new player to the ledger, and initialize it
func (*CurrencyContract) ExchangeInGameCurrency ¶
func (c *CurrencyContract) ExchangeInGameCurrency(ctx contractapi.TransactionContextInterface, userID, benAmountChange int64) error
ExchangeInGameCurrency allows users to exchange currency (USD to BEN or BEN to USD).
func (*CurrencyContract) GetAllPlayers ¶
func (c *CurrencyContract) GetAllPlayers(ctx contractapi.TransactionContextInterface) ([]*types.Player, error)
func (*CurrencyContract) GetPlayer ¶
func (c *CurrencyContract) GetPlayer(ctx contractapi.TransactionContextInterface, id int64) (*types.Player, error)
GetPlayer retrieves a player from the ledger
func (*CurrencyContract) InitLedger ¶
func (c *CurrencyContract) InitLedger(ctx contractapi.TransactionContextInterface) error
InitLedger adds a base set of players to the ledger
func (*CurrencyContract) PlayerExists ¶
func (c *CurrencyContract) PlayerExists(ctx contractapi.TransactionContextInterface, id int64) (bool, error)
PlayerExists returns true if a player with the given ID exists in the ledger
func (*CurrencyContract) RecordBankTransaction ¶
func (c *CurrencyContract) RecordBankTransaction(ctx contractapi.TransactionContextInterface, userID, amountUSD, transactionID int64) error
RecordBankTransaction records a new bank transaction to the ledger.
func (*CurrencyContract) SetExchangeRate ¶
func (c *CurrencyContract) SetExchangeRate(ctx contractapi.TransactionContextInterface, newRate int64) error
SetExchangeRate sets the exchange rate for USD to BEN conversion
Click to show internal directories.
Click to hide internal directories.