Non-Custodial Transactions
Execute non-custodial transactions on Tachyon using quote and submit-signed-tx endpoints with NEAR Chain Signatures for accurate cost estimates and secure execution.
Overview
The Tachyon API provides a powerful combination of the /quote endpoint and /submit-signed-tx endpoint that works seamlessly with NEAR's Chain Signatures technology. This approach allows users to get accurate cost estimates upfront and then submit pre-signed transactions that can be funded and executed efficiently.
Workflow Overview
Step-by-Step Integration
Get Transaction Quote
First, obtain a quote for your transaction to understand the costs and gas requirements:
const quoteRequest = {
to: "0x1234567890abcdef1234567890abcdef12345678",
callData: "0xa9059cbb000000000000000000000000742d35cc...", // ERC20 transfer data
value: "0",
chainId: 1, // Ethereum mainnet
maxFeePerGas: "20000000000",
maxPriorityFeePerGas: "2000000000",
gasLimit: "21000",
};
const quoteResponse = await fetch('https://tachyon.rath.fi/api/quote', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'your-api-key'
},
body: JSON.stringify(quoteRequest)
});
const quote = await quoteResponse.json();
console.log('Estimated cost:', quote.costUSD);
console.log('Min Balance Required:', quote.minBalanceRequired);Sign Transaction with Chain Signatures
Use NEAR's Chain Signatures to sign the transaction. This can be done through:
- Direct NEAR Integration: Use NEAR wallet or account to call the MPC service
- Tachyon's Chain Signature Integration: For users who have configured Tachyon with NEAR accounts
// Example using NEAR wallet selector
const signTransaction = async (transactionData, derivationPath) => {
const wallet = await selector.wallet();
// Prepare transaction for signing
const unsignedTx = {
to: transactionData.to,
value: BigInt(transactionData.value),
data: transactionData.callData,
gasLimit: BigInt(transactionData.gasLimit),
maxFeePerGas: BigInt(transactionData.maxFeePerGas),
maxPriorityFeePerGas: BigInt(transactionData.maxPriorityFeePerGas)
};
// Sign with MPC
const signature = await wallet.signAndSendTransaction({
receiverId: 'v1.signer',
actions: [{
type: 'FunctionCall',
params: {
methodName: 'sign',
args: {
payload: [hashToSign],
path: derivationPath,
key_type: 'Ecdsa'
},
gas: '300000000000000',
deposit: '1'
}
}]
});
return signature;
};Submit Signed Transaction
Submit the signed transaction along with funding requirements:
const submitSignedRequest = {
signedTx: "0x02f8b20180843b9aca0085174876e800825208942c169...", // Your signed tx
chainId: 1,
fromAddress: "0xYourDerivedAddress", // Address derived from Chain Signatures
minBalanceRequired: "${quote.minBalanceRequired}", // Minimum balance needed
// Optional: Reference the quote for cost tracking
quoteReference: quote.id,
estimatedCost: quote.estimatedCost
};
const submitResponse = await fetch('https://tachyon.rath.fi/api/submit-signed-tx', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'your-api-key'
},
body: JSON.stringify(submitSignedRequest)
});
const result = await submitResponse.json();
console.log('Transaction submitted:', result.transactionId);Authenticated Transaction Feature
Enable cross-chain transaction signing using NEAR Protocol's Chain Signatures technology with Tachyon's authenticated transaction feature.
Nano payments and x402
Use Circle Gateway Nanopayments and x402 to pay Tachyon transaction relay costs in USDC with gasless, batched payment authorization.