Quickstart Guide
The Tachyon SDK is a TypeScript/JavaScript library that provides a simple interface to interact with the Tachyon API. It allows you to relay transactions, check their status, and manage account information across multiple blockchain networks.
Getting Your API Key
To use Tachyon, you’ll need an API key:
- Apply for the API KEY
- Sign up or log in to your Tachyon account
Installation
SDK
Install the Tachyon SDK using your preferred package manager:
npm
npm install @rathfi/tachyon ethersRequirements: Node.js 16+, TypeScript 4.5+
Complete Example
SDK
example.ts
import { Tachyon, ChainId } from '@rathfi/tachyon';
import { ethers } from 'ethers';
async function relayTransaction() {
// Initialize SDK
const tachyon = new Tachyon({
apiKey: process.env.TACHYON_API_KEY!
});
// Encode contract call
const abi = ["function transfer(address to, uint256 amount)"];
const iface = new ethers.Interface(abi);
const callData = iface.encodeFunctionData("transfer", [
"0x742d35cc6634C0532925a3b8D1C9b53e6aC3",
ethers.parseUnits("10", 18) // 10 tokens with 18 decimals
]);
// Submit transaction
const txId = await tachyon.relay({
chainId: ChainId.BASE, // or use 8453
to: "0xA7A833e6641D7901F30EaD6f27d4Ee2C9bb670a7",
value: "0",
callData,
label: "Token Transfer"
});
console.log('Transaction ID:', txId);
// Check status
const status = await tachyon.getRelayStatus(txId);
console.log('Status:', status.status);
// Wait for execution
const result = await tachyon.waitForExecutionHash(txId);
console.log('Executed:', result.executionTxHash);
}
relayTransaction().catch(console.error);Key Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
chainId | number | Yes | Target blockchain network | 8453 (Base) |
to | string | Yes | Contract/recipient address | "0xA7A8..." |
value | string | Yes | Amount in wei | "0" |
callData | string | Yes | Encoded function call | "0x..." |
label | string | No | Custom label for tracking | "My Transfer" |
gasLimit | string | No | Gas limit override | "100000" |
Transaction Lifecycle
- Submit → Returns a unique
txId - Queue → Transaction enters relay queue (
NOT_PICKED_UP) - Process → Relay node broadcasts to blockchain
- Execute → Transaction confirmed on-chain with execution hash
Last updated on