Getting Started
This guide will help you get up and running with the Arcadia Game SDK in just a few minutes.
Prerequisites
Before you begin, make sure you have:
- A game that runs in a browser - HTML5, JavaScript, or any web-based game framework
- Your game hosted - The game must be accessible via URL (for iframe embedding)
- A game ID - You'll receive this when you register your game on Arcadia
- Basic JavaScript knowledge - Familiarity with async/await and promises
Installation
Choose your preferred installation method:
Option 1: NPM (Recommended for TypeScript/Modern Projects)
npm install @arcadiasol/sdk
Option 2: CDN (Quick Start)
<script src="https://cdn.jsdelivr.net/npm/@arcadiasol/sdk@latest/dist/umd/arcadia-game-sdk.js"></script>
For detailed installation instructions, see the Installation Guide.
Basic Setup
Step 1: Initialize the SDK
import { ArcadiaSDK } from '@arcadiasol/sdk';
// Create SDK instance
const arcadia = new ArcadiaSDK({
gameId: 'your-game-id', // Replace with your actual game ID
});
// Initialize SDK
await arcadia.init();
CDN Usage:
<script>
const arcadia = new ArcadiaGameSDK({
gameId: 'your-game-id',
});
await arcadia.init();
</script>
Step 2: Get Wallet Address
The wallet address is your primary user identifier. Use it to link save data, track progress, and identify players.
const walletAddress = await arcadia.getWalletAddress();
if (!walletAddress) {
// Wallet not connected - show message to user
showMessage('Please connect your wallet in Arcadia to play');
return;
}
// Use wallet address as user ID
console.log('Player wallet:', walletAddress);
// Load or create save data
const saveData = await loadSaveDataByWallet(walletAddress);
Step 3: Handle Payments (Optional)
If your game requires payment, you can process it like this:
try {
// Pay-to-play example
const result = await arcadia.payment.payToPlay(0.5, 'SOL');
console.log('Payment successful!');
console.log('Transaction:', result.txSignature);
console.log('Amount:', result.amount, result.token);
// Start game after successful payment
startGame();
} catch (error) {
console.error('Payment failed:', error.message);
showError('Payment failed. Please try again.');
}
Complete Minimal Example
Here's a complete, minimal example that you can use as a starting point:
<!DOCTYPE html>
<html>
<head>
<title>My Arcadia Game</title>
<script src="https://cdn.jsdelivr.net/npm/@arcadiasol/sdk@latest/dist/umd/arcadia-game-sdk.js"></script>
</head>
<body>
<div id="game-container">
<div id="status">Initializing...</div>
</div>
<script>
let arcadia;
let walletAddress = null;
async function initGame() {
try {
// Initialize SDK
arcadia = new ArcadiaGameSDK({
gameId: 'your-game-id', // Replace with your game ID
});
await arcadia.init();
document.getElementById('status').textContent = 'SDK initialized!';
// Get wallet address
walletAddress = await arcadia.getWalletAddress();
if (!walletAddress) {
document.getElementById('status').textContent = 'Please connect your wallet in Arcadia';
return;
}
document.getElementById('status').textContent = `Wallet: ${walletAddress.slice(0, 8)}...`;
// Load save data
await loadGameData(walletAddress);
// Start game
startGame();
} catch (error) {
console.error('Initialization error:', error);
document.getElementById('status').textContent = 'Error: ' + error.message;
}
}
async function loadGameData(address) {
// Load your game's save data using the wallet address
// This is just an example - implement your own save system
console.log('Loading data for wallet:', address);
}
function startGame() {
// Start your game here
console.log('Game started!');
}
// Initialize when page loads
window.addEventListener('DOMContentLoaded', initGame);
</script>
</body>
</html>
Next Steps
Now that you have the basics working:
- Learn about Wallet Integration - See Wallet Integration Guide
- Implement Payments - See Payments Guide
- Explore Examples - See Examples for real-world use cases
- Read the API Reference - See API Reference for complete documentation
Common Setup Issues
SDK Not Loading (CDN)
If you're using CDN and the SDK doesn't load:
- Check your internet connection
- Verify the CDN URL is correct
- Check browser console for errors
- Try using NPM instead
Wallet Not Connected
If getWalletAddress() returns null:
- Make sure the game is running inside Arcadia's iframe
- Ensure the player has connected their wallet in Arcadia
- Check that
init()was called successfully
Payment Errors
If payments fail:
- Verify the wallet has sufficient balance
- Check that the game ID is correct
- Ensure the game is running in Arcadia's iframe
- See Error Handling Guide for specific error types
Need Help?
- Check the FAQ for common questions
- Review the Error Handling Guide for troubleshooting
- See Examples for complete working code
- Contact support@arcadia.com for additional assistance