Cloud SDK
Gas and transactions
Estimate fees, then prepare, simulate, broadcast, and confirm transactions with @gray3/cloud.
Gas
const fees = await gray.gas.fees({ chainId: "ethereum" });
// { slow, average, fast, unit: "wei", … } — unit is "sat/vB" on UTXO, "piconero/byte" on Monero
const estimate = await gray.gas.estimate({
chainId: "ethereum",
from: "0xSender",
to: "0xRecipient",
value: "10000000000000000",
});
// { gasLimit, estimatedFeeWei, fees, … }Gas estimates are available on EVM chains only.
Prepare and simulate
const intent = {
kind: "token_transfer",
chainId: "ethereum",
from: "0xSender",
to: "0xRecipient",
token: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
amount: "25000000", // 25 USDC in base units
} as const;
const sim = await gray.transactions.simulate(intent); // EVM chains and Solana
if (!sim.ok) throw new Error(sim.error?.message);
const prepared = await gray.transactions.prepare(intent);
// Send `prepared` to the device for signing.Intent kinds are transfer, token_transfer, nft_transfer, contract_call, and from_request. See Token, NFT, and contract intents.
Broadcast and receipt
// signedPayload comes from account.signPreparedTransaction(prepared) on the device
const result = await gray.transactions.broadcast({
chainId: "ethereum",
signedPayload,
ledgerTxId, // optional: link to a Ledger API record
});
// result.status: "broadcast" | "submitted"; result.txHash: string | null
if (result.txHash) {
const receipt = await gray.transactions.getReceipt({
chainId: "ethereum",
hash: result.txHash,
}); // EVM chains only
}Gram (TON) and Monero may return status: "submitted" with a null txHash when the broadcast input has no hash. Treat the transaction as sent and confirm it through activity. Pass the locally computed hash as txHash (64 hexadecimal characters, no 0x): for Gram it is the txHash returned by signPreparedTransaction, for Monero the txHash of the signed transfer.
If the broadcast succeeded but the linked Ledger API record could not be updated, the response includes warnings: ["ledger_write_failed"]. The transaction is on its way; update the record yourself with gray.ledger.updateTransaction.