G3Engine provides native Web3 integration for Solana, enabling you to create token economies, mint NFTs, and integrate with Pump.fun bonding curves directly in your games.
Overview
The Web3 system connects your game to Solana blockchain, supporting:
Wallet connection via Solana wallet adapters
Token operations on Pump.fun bonding curves
NFT minting from game assets
Token gating for premium content
In-game economy with real blockchain assets
Web3 features require a Solana wallet browser extension (Phantom, Solflare, etc.) and SOL for transaction fees.
Network Configuration
G3Engine supports both Solana networks:
export type SolanaNetwork = 'devnet' | 'mainnet-beta' ;
const RPC_ENDPOINTS : Record < SolanaNetwork , string > = {
'devnet' : 'https://api.devnet.solana.com' ,
'mainnet-beta' : 'https://api.mainnet-beta.solana.com' ,
};
Switching Networks
Open Web3 Panel
Click the Web3 icon in the editor toolbar to open the Web3 panel.
Navigate to Settings
Select the “Settings” tab in the Web3 panel.
Choose Network
Toggle between Devnet (for testing) and Mainnet (for production).
Auto-Update RPC
The RPC endpoint automatically updates when you change networks.
Always test on devnet first. Devnet SOL is free from faucets, mainnet SOL costs real money.
Wallet Connection
Connect player wallets to enable blockchain features:
Connection State
interface Web3State {
walletConnected : boolean ;
walletAddress : string | null ;
solBalance : number ;
network : SolanaNetwork ;
rpcEndpoint : string ;
}
Connection Flow
Request Connection
Call setWalletConnected(true, address) when wallet approves connection.
Store Address
Wallet address is stored in state: walletAddress: string | null
Fetch Balance
Query SOL balance and update with setSolBalance(balance)
Enable Features
Web3 actions are now available to the player
// From web3Store.ts:122-126
setWalletConnected : ( connected , address ) => set ({
walletConnected: connected ,
walletAddress: address ?? null ,
solBalance: connected ? undefined as any : 0 , // reset on disconnect
}),
Token System
Manage SPL tokens and Pump.fun tokens:
interface TokenInfo {
mint : string ; // Token mint address
name : string ; // Token name
symbol : string ; // Ticker symbol (e.g., "USDC")
balance : number ; // User's balance
decimals : number ; // Decimal places
imageUri ?: string ; // Token logo
// Pump.fun specific
isPumpToken ?: boolean ; // Launched on Pump.fun
bondingCurveComplete ?: boolean ; // Graduated to Raydium
priceInSol ?: number ; // Current price
}
Adding Tokens
Single Token
Batch Import
addToken ({
mint: '9vMJfxuKxXBoEa7rM12mYLMwTacLMLDJqHozw96WQL8i' ,
name: 'My Game Token' ,
symbol: 'GAME' ,
balance: 1000 ,
decimals: 9 ,
isPumpToken: true ,
priceInSol: 0.001
});
setTokens ([
{ mint: '...' , name: 'Token A' , ... },
{ mint: '...' , name: 'Token B' , ... },
{ mint: '...' , name: 'Token C' , ... },
]);
Pump.fun Integration
G3Engine provides first-class support for Pump.fun token bonding curves:
Token Launch
Launch tokens directly from your game:
// Token launch parameters
{
name : string ; // Token name ("My Game Coin")
symbol : string ; // Ticker ("GAME")
description : string ; // Token description
imageUri : string ; // Token logo (IPFS or HTTP)
twitter ?: string ; // Social links
telegram ?: string ;
website ?: string ;
}
Prepare Metadata
Create token name, symbol, and upload image to IPFS or hosting.
Open Launch Modal
Use the ”🚀 Launch Token” button in Web3 panel or visual scripting node.
Fill Parameters
Enter token details and social links.
Confirm Transaction
Approve the transaction in your wallet. Cost: ~0.02 SOL.
Receive Mint Address
Token mint address is returned and automatically added to your token list.
Buy/Sell Operations
// Buy tokens
{
tokenMint : string ; // Target token address
solAmount : number ; // SOL to spend
slippage : number ; // Slippage tolerance % (e.g., 5 = 5%)
}
// Sell tokens
{
tokenMint : string ; // Target token address
tokenAmount : number ; // Tokens to sell
slippage : number ; // Slippage tolerance %
}
Pump.fun trades execute on bonding curves with automatic pricing. High slippage may be needed for large trades.
Price Queries
Get real-time token prices from bonding curves:
// Query token price
interface PriceData {
priceInSol : number ; // Current price in SOL
marketCap : number ; // Total market cap in SOL
bondingCurveProgress : number ; // % to Raydium graduation
}
NFT System
Mint NFTs from game assets:
interface NFTInfo {
mint : string ; // NFT mint address
name : string ; // NFT name
imageUri : string ; // Image URL (IPFS recommended)
collection ?: string ; // Collection address
attributes ?: { // Metadata attributes
trait_type : string ;
value : string ;
}[];
}
Minting NFTs
Capture Asset
Take screenshot or export 3D model/sprite as image.
Upload to IPFS
Store image and metadata on IPFS for decentralization.
Open Mint Modal
Use ”🎨 Mint NFT” in Web3 panel or visual scripting.
Configure Metadata
Set name, description, attributes (rarity traits, stats, etc.).
Mint Transaction
Approve transaction (~0.01 SOL). NFT is minted to your wallet.
Auto-Add to Collection
Minted NFT appears in the NFTs tab of Web3 panel.
{
"name" : "Legendary Sword #123" ,
"symbol" : "SWORD" ,
"description" : "A powerful blade forged in the fires of Mount Doom" ,
"image" : "https://ipfs.io/ipfs/Qm..." ,
"attributes" : [
{ "trait_type" : "Rarity" , "value" : "Legendary" },
{ "trait_type" : "Damage" , "value" : "150" },
{ "trait_type" : "Element" , "value" : "Fire" },
{ "trait_type" : "Level" , "value" : "50" }
],
"properties" : {
"files" : [
{ "uri" : "https://ipfs.io/ipfs/Qm..." , "type" : "image/png" }
],
"category" : "image"
}
}
Game Economy
Configure token-based game economies:
interface GameEconomyConfig {
rewardTokenMint : string | null ; // Token used for rewards
rewardPerLevel : number ; // Tokens earned per level
tipJarEnabled : boolean ; // Allow players to tip developer
itemPrices : { // In-game shop prices
itemId : string ;
priceToken : string ; // Token mint address
amount : number ; // Price in tokens
}[];
}
Reward System Example
// Configure economy
updateEconomy ({
rewardTokenMint: '9vMJfxuKxXBoEa7rM12mYLMwTacLMLDJqHozw96WQL8i' ,
rewardPerLevel: 10 ,
tipJarEnabled: true
});
// In-game: Award tokens when player completes level
if ( levelComplete ) {
const reward = economy . rewardPerLevel ;
// Transfer tokens to player wallet
airdropTokens ( playerWallet , economy . rewardTokenMint , reward );
}
Token Gating
Restrict content based on token holdings:
// Check if player holds minimum tokens
const hasAccess = await checkTokenBalance (
walletAddress ,
requiredTokenMint ,
minimumBalance // e.g., 100 tokens
);
if ( hasAccess ) {
// Grant access to VIP area
unlockPremiumContent ();
} else {
// Show "Insufficient tokens" message
showTokenGateModal ();
}
Token gating is perfect for:
VIP/premium areas
Special skins and items
Leaderboard access
Tournament entry
Exclusive game modes
Transaction System
Track all blockchain transactions:
interface Web3Transaction {
id : string ;
type : 'token_launch' | 'buy' | 'sell' | 'mint_nft' | 'transfer' | 'airdrop' ;
signature : string ; // Solana transaction signature
status : 'pending' | 'confirmed' | 'failed' ;
description : string ; // Human-readable description
timestamp : number ; // Unix timestamp
}
Adding Transactions
// When initiating a transaction
const txId = uuidv4 ();
addTransaction ({
id: txId ,
type: 'buy' ,
signature: '' , // populated after wallet signs
status: 'pending' ,
description: 'Buy 1000 GAME tokens' ,
timestamp: Date . now ()
});
// After wallet confirmation
updateTransaction ( txId , {
signature: '3Xz7Kj2...actual_signature' ,
status: 'pending'
});
// After blockchain confirmation
updateTransaction ( txId , {
status: 'confirmed'
});
Transaction History
The Web3 panel shows transaction history:
Recent transactions displayed in reverse chronological order
Status indicators : Pending (spinner), Confirmed (checkmark), Failed (X)
Explorer links : Click signature to view on Solana Explorer
Type icons : Visual indicators for transaction types
Web3 Panel UI
The Web3 panel has four main tabs:
Tokens
NFTs
Economy
Settings
View all SPL tokens in wallet
See balances and prices
Buy/sell Pump.fun tokens
Launch new tokens
Filter by Pump.fun tokens only
View NFT collection
Display metadata and images
Mint new NFTs from game assets
View NFT attributes and rarity
Collection grouping
Configure game token rewards
Set item shop prices
Enable/disable tip jar
View economy statistics
Test token gating
Switch networks (devnet/mainnet)
Custom RPC endpoints
View wallet address
Transaction history
Disconnect wallet
Visual Scripting Integration
All Web3 features are available as visual scripting nodes:
Token Nodes
🚀 Launch Token - Create Pump.fun token
💰 Buy Token - Purchase on bonding curve
💸 Sell Token - Sell on bonding curve
📊 Get Token Price - Query current price
💎 Check Balance - Get token balance
NFT Nodes
🎨 Mint NFT - Create NFT from asset
🔐 Token Gate - Check if player holds NFT/token
Transfer Nodes
🏦 Airdrop Tokens - Send tokens to player
⬡ Send SOL - Transfer SOL
🎁 Reward Player - Give tokens as game reward
See Visual Scripting for detailed node documentation.
Security Best Practices
Critical Security Guidelines:
Never store private keys in game code or editor
Validate all transactions in wallet before signing
Test on devnet first before deploying to mainnet
Use HTTPS for all API endpoints and RPC connections
Verify token mints to avoid scams and fake tokens
Wallet Security
Transaction Limits
Token Validation
Users control their own wallets
Game never has access to private keys
All transactions require explicit wallet approval
Support hardware wallets for high-value operations
Implement daily/hourly transaction limits
Require confirmation for large transfers
Rate-limit automated token rewards
Add cooldowns to prevent spam
Verify token mint addresses from trusted sources
Check Pump.fun API for legitimate tokens
Warn users about unknown tokens
Maintain whitelist of approved tokens
Testing on Devnet
Switch to Devnet
Set network to devnet in Web3 settings.
Test All Features
Try token launches, NFT mints, transfers without real money.
Switch to Mainnet
Only after thorough devnet testing, switch to mainnet for production.
Devnet tokens and NFTs have no real value. Use them freely for testing.
Next Steps
Visual Scripting Use Web3 nodes in your game logic
3D Editor Create 3D assets to mint as NFTs
2D Editor Design 2D sprites for NFT artwork
Asset Library Build game content for tokenization