currency

package
v0.0.0-...-009c8ec Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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

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 (*CurrencyContract) GetPlayer

GetPlayer retrieves a player from the ledger

func (*CurrencyContract) InitLedger

InitLedger adds a base set of players to the ledger

func (*CurrencyContract) PlayerExists

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

Jump to

Keyboard shortcuts

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