RathRath Finance
How-To GuidesRelay Transactions

Near

Submit and track a relay transaction on NEAR.

NEAR is a sharded proof-of-stake blockchain with human-readable account names. Smart contracts are typically compiled to WebAssembly and called by specifying a method name and JSON arguments.

Follow these steps to submit and track a simple transaction on NEAR.

Import the SDK

import { Tachyon, ChainId } from '@rathfi/tachyon'

Initialize the Tachyon Client

const tachyon = new Tachyon({
  apiKey: 'API-KEY',
})

Submit a Transaction

const txId = await tachyon.relay({
  chainId: 7777777, // NEAR chain ID
  to: 'deeprice6887.near',
  value: '1', // 1 yoctoNEAR
  callData: '0x',
  label: 'My NEAR Transaction',
})

console.log('Transaction submitted with ID:', txId)

Check Transaction Status

const status = await tachyon.getRelayStatus(txId)
console.log('Transaction status:', status.status)

Wait for Execution

const executedTx = await tachyon.waitForExecutionHash(txId)
console.log('Execution hash:', executedTx.executionTxHash)

Call a Smart Contract

Create a JSON object containing the method name and arguments, then base64-encode it into callData.

import { Tachyon } from '@rathfi/tachyon'

const tachyon = new Tachyon({ apiKey: 'YOUR_API_KEY' })
const methodCall = {
  methodName: 'set_greeting',
  args: { greeting: 'Hello from Tachyon!' },
}

const callData = Buffer.from(JSON.stringify(methodCall)).toString('base64')

const txId = await tachyon.relay({
  chainId: 7777777,
  to: 'rathgreeting.near',
  value: '0',
  callData,
  label: 'contract-call-near',
})
curl -X POST https://tachyon.rath.fi/api/submit-tx \
  -H "api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": 7777777,
    "to": "rathgreeting.near",
    "value": "0",
    "callData": "eyJtZXRob2ROYW1lIjoic2V0X2dyZWV0aW5nIiwiYXJncyI6eyJncmVldGluZyI6IkhlbGxvIGZyb20gdGFjaHlvbiEifX0=",
    "label": "contract-call-near"
  }'

On this page