Batch Transactions
Combine multiple transaction calls into a single on-chain transaction using Tachyon's multicall feature to reduce gas costs and ensure atomic execution.
Batch Transactions
Combine multiple transaction calls into a single on-chain transaction using Tachyon's multicall feature. Reduce gas costs, improve efficiency, and ensure atomic execution of related operations.
Overview
Batch Transactions allow you to group multiple contract calls into a single transaction using the shouldBatchInMulticall parameter. Tachyon automatically optimizes compatible transactions for gas savings.
How It Works
When you enable batching, Tachyon groups your transaction with other compatible transactions and executes them together using a multicall contract, providing:
- Gas Optimization: Significant savings by reducing per-transaction overhead
- Automatic Grouping: Tachyon intelligently batches compatible transactions
Usage
curl -X POST "https://tachyon.rath.fi/api/submit-tx" \
-H "Content-Type: application/json" \
-H "api-key: YOUR_API_KEY" \
-d '{
"chainId": 8453,
"to": "0x3dbE34f2C21b3B2980d4dc53f3c7E51e39663F49",
"value": "1",
"callData": "0x",
"shouldBatchInMulticall": true,
"gasLimit": "30000",
"label": "Batched Transfer"
}'import { Tachyon, ChainId } from '@rathfi/tachyon';
const tachyon = new Tachyon({
apiKey: process.env.TACHYON_API_KEY!
});
// Submit multiple transactions for batching
const transfers = [
{
chainId: ChainId.BASE,
to: '0x3dbE34f2C21b3B2980d4dc53f3c7E51e39663F49',
value: '1',
callData: '0x',
shouldBatchInMulticall: true,
gasLimit: "30000",
label: 'Transfer 1'
},
{
chainId: ChainId.BASE,
to: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
value: '1',
callData: '0x',
shouldBatchInMulticall: true,
gasLimit: "30000",
label: 'Transfer 2'
}
];
// Tachyon automatically batches compatible transactions
const txIds = await Promise.all(
transfers.map(tx => tachyon.relay(tx))
);
console.log('Batched transactions submitted:', txIds);Use Cases
- DeFi Operations: Approve + swap, multiple token transfers
- NFT Operations: Batch minting, bulk transfers
- Multi-token Actions: Distribute tokens to multiple recipients
- Contract Interactions: Execute multiple contract calls atomically
Benefits
- Gas Savings: Typically 10-20% reduction in gas costs
- Atomic Execution: All operations succeed or fail together
- Simplified Flow: Single transaction for multiple operations
- Automatic Optimization: Tachyon handles the batching logic
Key Parameters
| Parameter | Description |
|---|---|
shouldBatchInMulticall: true | Enable transaction batching |
Same chainId | All batched transactions must be on same network |
EIP-7702 Authorization
Enable account abstraction and smart account capabilities using EIP-7702 authorization lists with Tachyon's transaction relay.
Authenticated Transaction Feature
Enable cross-chain transaction signing using NEAR Protocol's Chain Signatures technology with Tachyon's authenticated transaction feature.