Integration Guide
Learn how to integrate GPMIN into your application.
Using the SDK
The easiest way to integrate GPMIN
import { GalaxiaPredictionsSDK, MarketType } from '@galaxia-predictions-market/sdk';
import { Connection, Wallet } from '@solana/web3.js';
const connection = new Connection('https://api.devnet.solana.com');
const wallet = new Wallet(keypair);
const sdk = new GalaxiaPredictionsSDK(connection, wallet);
// Create a market
await sdk.createMarket({
marketId: 'my-market',
question: 'Will X happen?',
marketType: MarketType.BINARY,
outcomes: ['Yes', 'No'],
endTime: Math.floor(Date.now() / 1000) + 31536000,
oracle: oraclePublicKey,
});Using the REST API
Direct HTTP integration
// Get all markets
const response = await fetch('http://localhost:3000/api/markets');
const markets = await response.json();
// Create a market (requires authentication)
const response = await fetch('http://localhost:3000/api/markets', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN',
},
body: JSON.stringify({
marketId: 'my-market',
question: 'Will X happen?',
marketType: 'BINARY',
outcomes: ['Yes', 'No'],
endTime: '1735689600',
oracle: 'oracle-address',
}),
});Using GraphQL
Query and mutate data with GraphQL
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const client = new ApolloClient({
uri: 'http://localhost:3000/graphql',
cache: new InMemoryCache(),
});
// Query markets
const { data } = await client.query({
query: gql`
query {
markets {
id
question
outcomes
isResolved
}
}
`,
});Galaxia Ecosystem Integration
Integrate with other Galaxia services
Best Practices
Error Handling
try {
const market = await sdk.createMarket(config);
} catch (error) {
console.error('Failed to create market:', error);
// Handle error appropriately
}Transaction Confirmation
const tx = await sdk.trade(params);
// Wait for confirmation
await connection.confirmTransaction(tx, 'confirmed');Rate Limiting
The API has rate limits (100 requests per 15 minutes). Implement exponential backoff for retries.