Skip to main content
The Crypto component manages cryptocurrency coins, player wallets, and exchange operations (buying, selling, transferring).

Overview

Access via Crypto (server-side only).

Coin Management

Create and manage coin types

Wallets

Player crypto holdings

Exchange

Buy, sell, and transfer crypto
Crypto balances are stored in the character’s data as Crypto[ACRONYM] = amount. Players access crypto through a CryptoWallet ID linked to their character.

Coin Management

Crypto.Coin:Create

Register or update a cryptocurrency type.
Crypto.Coin:Create(name, acronym, price, buyable, sellable)
name
string
required
Full coin name (e.g., “Bitcoin”)
acronym
string
required
Short identifier (e.g., “BTC”)
price
number
required
Price per unit in dollars
buyable
boolean
required
Whether players can buy this coin
sellable
boolean
required
Whether players can sell this coin
Example:
-- Register coins
Crypto.Coin:Create('Bitcoin', 'BTC', 50000, true, true)
Crypto.Coin:Create('Cayo Coin', 'CAYO', 150, true, false)  -- Can buy, can't sell

Crypto.Coin:Get

Get data for a specific coin.
Crypto.Coin:Get(acronym)
coin
table|nil
Coin data or nil if not registered

Crypto.Coin:GetAll

Get all registered coins.
Crypto.Coin:GetAll()
coins
table
Array of all registered coin data

Wallet Operations

Crypto:Has

Check if a player owns a minimum amount of a coin.
Crypto:Has(source, coin, amount)
source
number
required
Player server ID
coin
string
required
Coin acronym (e.g., “BTC”)
amount
number
required
Minimum amount to check
has
boolean
true if player owns >= amount
Example:
if Crypto:Has(source, 'BTC', 2) then
    -- Player has at least 2 BTC
end

Exchange Operations

Crypto.Exchange:IsListed

Check if a coin is tradeable on the exchange.
Crypto.Exchange:IsListed(coin)

Crypto.Exchange:Buy

Purchase cryptocurrency using the player’s bank account.
Crypto.Exchange:Buy(coin, target, amount)
coin
string
required
Coin acronym
target
number
required
Character State ID (SID) of the buyer
amount
number
required
Amount of coin to buy
success
boolean
true if purchase was successful
Example:
local char = Fetch:Source(source):GetData('Character')
local stateId = char:GetData('SID')

-- Buy 2 BTC for the player
Crypto.Exchange:Buy('BTC', stateId, 2)

Crypto.Exchange:Sell

Sell cryptocurrency back for bank balance.
Crypto.Exchange:Sell(coin, target, amount)
coin
string
required
Coin acronym (must be sellable)
target
number
required
Character State ID (SID) of the seller
amount
number
required
Amount of coin to sell
result
number|boolean
New balance or false if failed

Crypto.Exchange:Add

Add cryptocurrency directly to a wallet (no bank charge).
Crypto.Exchange:Add(coin, target, amount, skipAlert)
coin
string
required
Coin acronym
target
string
required
CryptoWallet ID (from char:GetData('CryptoWallet'))
amount
number
required
Amount to add
skipAlert
boolean
Skip phone notification
Example:
-- Reward crypto for completing a job
local char = Fetch:Source(source):GetData('Character')
local walletId = char:GetData('CryptoWallet')

Crypto.Exchange:Add('BTC', walletId, 0.5)

Crypto.Exchange:Remove

Remove cryptocurrency from a wallet.
Crypto.Exchange:Remove(coin, target, amount, skipAlert)
success
boolean
true if successfully removed

Crypto.Exchange:Transfer

Transfer cryptocurrency between two wallets.
Crypto.Exchange:Transfer(coin, sender, target, amount)
coin
string
required
Coin acronym
sender
number
required
Sender’s State ID (SID)
target
string
required
Recipient’s CryptoWallet ID
amount
number
required
Amount to transfer
success
boolean
true if transfer was successful
Example:
-- Transfer crypto between players
local char = Fetch:Source(source):GetData('Character')
local senderSID = char:GetData('SID')
local targetWalletId = '...' -- Recipient's CryptoWallet ID

local success = Crypto.Exchange:Transfer('BTC', senderSID, targetWalletId, 1.5)

Next Steps

Finance - Banking

Bank account operations

Finance - Payments

Bills and fines

Characters API

Character data access