Getting Started with OAS
Prerequisites
Before you begin integrating OAS, ensure you have the following requirements met:
-
✓
Node.js 16.0+ - Required for JavaScript SDK
-
✓
Web3 Wallet - MetaMask, WalletConnect, or compatible wallet
-
✓
API Key - Register at dashboard.omniasset.io
-
✓
Test Tokens - Available from our faucet for development
Installation
Package Manager
# Using npm
npm install @omniasset/sdk @omniasset/contracts
# Using yarn
yarn add @omniasset/sdk @omniasset/contracts
# Using pnpm
pnpm add @omniasset/sdk @omniasset/contracts
CDN
<!-- Latest version -->
<script src="https://cdn.omniasset.io/sdk/latest/oas.min.js"></script>
<!-- Specific version -->
<script src="https://cdn.omniasset.io/sdk/v1.0.0/oas.min.js"></script>
Configuration
Configure the OAS SDK with your API credentials and network preferences.
Basic Configuration
import { OAS, Network } from '@omniasset/sdk';
const config = {
apiKey: process.env.OAS_API_KEY,
secretKey: process.env.OAS_SECRET_KEY,
network: Network.MAINNET, // or Network.TESTNET
options: {
autoConnect: true,
debug: false
}
};
const oas = new OAS(config);
// Verify connection
await oas.connect();
console.log('Connected to OAS Network');
Environment Variables
# .env file
OAS_API_KEY=your_api_key_here
OAS_SECRET_KEY=your_secret_key_here
OAS_NETWORK=mainnet
OAS_RPC_URL=https://rpc.omniasset.io
OAS_WEBHOOK_SECRET=your_webhook_secret
Create Your First Asset
Let's create and deploy your first tokenized asset on the OAS platform.
Step 1: Define Asset Parameters
const assetConfig = {
name: "Premium Real Estate Fund",
symbol: "PREF",
type: "REAL_ESTATE",
totalSupply: 1000000,
decimals: 18,
pricePerToken: 100, // USD
metadata: {
description: "Tokenized commercial real estate in prime locations",
image: "ipfs://QmXxx...",
properties: {
location: "New York, USA",
totalValue: 100000000, // $100M
expectedYield: 8.5, // 8.5% annual
minimumInvestment: 1000
}
},
compliance: {
kycRequired: true,
accreditedOnly: false,
jurisdictions: ["US", "UK", "EU"],
lockupPeriod: 180 // days
}
};
Step 2: Deploy the Asset
try {
// Create the asset
const asset = await oas.assets.create(assetConfig);
console.log('Asset created successfully!');
console.log('Token Address:', asset.tokenAddress);
console.log('Asset ID:', asset.id);
// Set up distribution
await asset.setupDistribution({
startDate: new Date('2024-01-15'),
endDate: new Date('2024-02-15'),
softCap: 1000000, // $1M
hardCap: 10000000 // $10M
});
} catch (error) {
console.error('Asset creation failed:', error);
}
Step 3: Manage the Asset
// Check asset status
const status = await asset.getStatus();
console.log('Current status:', status);
// Distribute dividends
await asset.distributeDividends({
amount: 85000, // $85,000
currency: 'USDC',
description: 'Q1 2024 Dividend'
});
// Transfer ownership
await asset.transfer({
to: '0x123...abc',
amount: 100,
memo: 'Transfer to investor'
});
// Pause/Resume trading
await asset.pause(); // Emergency pause
await asset.resume(); // Resume trading
Testing
Test your integration using our testnet environment before deploying to production.
Testnet Configuration
// Configure for testnet
const testConfig = {
apiKey: 'test_key_xxx',
network: Network.TESTNET,
options: {
debug: true,
logLevel: 'verbose'
}
};
// Get test tokens
const faucet = await oas.faucet.request({
address: '0x123...abc',
amount: 10000 // 10,000 test tokens
});
Unit Tests
describe('Asset Creation', () => {
it('should create a new asset', async () => {
const asset = await oas.assets.create(testAssetConfig);
expect(asset.tokenAddress).toBeDefined();
expect(asset.symbol).toBe('TEST');
});
it('should handle KYC verification', async () => {
const verified = await oas.kyc.verify(userAddress);
expect(verified).toBe(true);
});
it('should distribute dividends', async () => {
const tx = await asset.distributeDividends(dividendConfig);
expect(tx.status).toBe('success');
});
});
Deployment
Deploy your tokenized assets to production with confidence.
Production Checklist
- ☐ Complete KYC/AML verification for your organization
- ☐ Review and sign legal agreements
- ☐ Audit smart contracts (automated via platform)
- ☐ Configure production API keys and webhooks
- ☐ Set up monitoring and alerts
- ☐ Implement proper error handling and logging
Go Live
// Production deployment
const prodConfig = {
apiKey: process.env.PROD_API_KEY,
secretKey: process.env.PROD_SECRET_KEY,
network: Network.MAINNET,
options: {
retryPolicy: {
maxRetries: 3,
backoffMultiplier: 2
},
timeout: 30000,
monitoring: {
enabled: true,
webhookUrl: 'https://your-app.com/webhooks/oas'
}
}
};
// Deploy with safety checks
const deployment = await oas.deploy({
config: prodConfig,
safeMode: true,
confirmations: 3
});
Next Steps
Now that you've set up your first asset, explore more advanced features: