SDK Reference
Quickstart
Get started with the Tachyon SDK in minutes
Quickstart
Get started with the Tachyon SDK and submit your first transaction in minutes.
Installation
Install the Package
Install the Tachyon SDK using your preferred package manager:
npm install @rathfi/tachyonyarn add @rathfi/tachyonpnpm add @rathfi/tachyonRequirements:
- Node.js 16 or higher
- TypeScript 4.5 or higher (if using TypeScript)
Get Your API Key
To use the Tachyon SDK, you'll need an API key:
- Apply for the API KEY
- Sign up or log in to your Tachyon account
Basic Setup
Create a new Tachyon instance with your API key:
import { Tachyon } from '@rathfi/tachyon';
const tachyon = new Tachyon({
apiKey: process.env.TACHYON_API_KEY!, // Store your API key securely
});Quick Start Guide
Import the SDK
import { Tachyon, ChainId } from '@rathfi/tachyon';Import the Tachyon class and ChainId enum from the package. The ChainId enum provides type-safe chain identifiers for supported networks.
Initialize the SDK
const tachyon = new Tachyon({
apiKey: process.env.TACHYON_API_KEY!, // Store your API key securely
});Create a new Tachyon instance with your API key. Always store your API key in environment variables for security.
Submit a Transaction
const txId = await tachyon.relay({
chainId: ChainId.BASE,
to: '0x742d35cc6634C0532925a3b8D1C9b53e6aC3',
value: '1', // 1 wei
callData: '0x',
label: 'My Transaction' // Optional label for tracking
});
console.log('Transaction ID:', txId);Call the relay() method with your transaction parameters:
chainId: The target blockchain networkto: The recipient addressvalue: Amount in wei (use '0' for contract calls without value transfer)callData: Encoded transaction data ('0x' for simple transfers)label: Optional custom label for tracking
Check Transaction Status
const status = await tachyon.getRelayStatus(txId);
console.log('Transaction status:', status);Use the returned txId to check the current status of your transaction.
Wait for Execution
const executedTx = await tachyon.waitForExecutionHash(txId);
console.log('Execution hash:', executedTx.executionTxHash);Wait for the transaction to be executed on-chain and get the execution hash.