Docs / SDK

Send and time

sendTimed(): one round trip, real ms.

sendTimed(rawTx) sends a signed transaction with eth_sendRawTransactionSync, which returns the receipt in the same call. If the node lacks that method it falls back to sending and polling every 20 ms.

With viem

import { privateKeyToAccount } from "viem/accounts";
import { createClient, ELYSIUM } from "clockd";

const account = privateKeyToAccount(process.env.KEY);
const elysium = createClient();

const raw = await account.signTransaction({
  chainId: ELYSIUM.chainId, type: "eip1559",
  to: "0x…", value: 0n, nonce, gas: 21000n,
  maxFeePerGas: 1_000_000_000n, maxPriorityFeePerGas: 0n,
});

const sent = await elysium.sendTimed(raw);
console.log(sent.ms, "ms, block", sent.blockNumber, sent.explorer);

What you get back

  • hash, blockNumber, success, the full receipt.
  • ms: send to receipt as measured from your process, network included.
  • method: sync or poll.
  • explorer: a link to the transaction.

Why it is faster

A normal send needs at least two round trips: send, then ask for the receipt, often several times. The sync method needs one. On a chain that seals blocks in about 100 ms, the extra round trips are most of the wait.