Skip to main content

Other Chains Integration

Supported Non-EVM Chains​

Solana​

solana-connector.ts
import { Connection, PublicKey } from '@solana/web3.js';

class SolanaConnector {
private connection: Connection;

constructor(endpoint: string) {
this.connection = new Connection(endpoint);
}

async subscribeProgramAccount(programId: string) {
const publicKey = new PublicKey(programId);

this.connection.onProgramAccountChange(
publicKey,
(accountInfo, context) => {
// Process account changes
this.processAccountChange(accountInfo);
}
);
}
}

Near​

near-connector.ts
import { connect, keyStores, Near } from 'near-api-js';

class NearConnector {
private near: Near;

async initialize() {
this.near = await connect({
networkId: 'mainnet',
keyStore: new keyStores.InMemoryKeyStore(),
nodeUrl: 'https://rpc.mainnet.near.org'
});
}

async subscribeToEvents(contractId: string) {
const account = await this.near.account(contractId);
// Subscribe to contract events
}
}

Chain-Specific Considerations​

Solana​

  • Account model vs UTXO
  • Program Derived Addresses (PDAs)
  • Transaction confirmation strategies

Near​

  • Account structure
  • Gas fee model
  • State access patterns

Best Practices​

  1. Chain-Specific Optimizations

    • Use native APIs when available
    • Implement proper retry logic
    • Handle chain-specific error cases
  2. Data Consistency

    • Validate transaction finality
    • Handle chain reorganizations
    • Implement proper checkpointing
  3. Resource Management

    • Monitor RPC usage
    • Implement connection pooling
    • Handle rate limiting

Next Steps​