Code against Leyora.
One open JSON API covers balances, payments, markets, launches and perps. Anything can read it, and any EVM wallet or an agent key can write to it.
Read the chain
No key is needed for the public routes. Requests and responses are JSON. Amounts travel as strings of base units, 9 decimals for HYPE (nano HYPE) and 6 for coins, and prices are decimal strings.
AI agents
The repository ships an MCP server. Point Claude, ChatGPT or any MCP client at it and the agent gets seventeen tools: blocks, receipts, coins, clears and perps markets to read, plus transactions to send under its own key. One config block:
{
"mcpServers": {
"leyora": {
"command": "node",
"args": ["/path/to/leyora/mcp/dist/cli.js"],
"env": { "LEYORA_API": "https://leyora.xyz", "LEYORA_AGENT_KEY": "<agent key>" }
}
}
}Private data
Routes under /api/me answer only the account they belong to. Prove it with three headers carrying a signed timestamp. A session key is allowed to sign them, which is why a wallet signs once a day rather than every five minutes.
x-l2-pubkey: <the account, a lowercase 0x address>
x-l2-ts: <unix seconds>
x-l2-sig: <personal_sign by the account of "LEYORA auth v1\n" + address + "\n" + ts, as 0x hex,
or the base58 ed25519 signature of the same text by an active session key>Send a transaction
The message is five fields, chainId, from, nonce, type and body, serialized with sorted keys and no whitespace, and hashed with SHA256. Everything signs the same bytes: the string "LEYORA tx v1", a newline and the canonical JSON. A wallet signs them with personal_sign and the chain recovers its address. Session keys sign them with ed25519. The SDK builds either one.
import { LeyoraClient, SessionKey, buildTx, signEvmEnvelope, signMessageEnvelope } from "@leyora/sdk";
const client = new LeyoraClient({ baseUrl: "https://leyora.xyz" });
const chain = await client.chain();
// Any EVM wallet (viem, Privy, MetaMask). Leyora accounts are lowercase.
const from = walletClient.account.address.toLowerCase();
const wallet = {
address: from,
signMessage: (bytes) => walletClient.signMessage({ message: { raw: bytes } }),
};
// 1. One wallet signature opens a session: a browser key with a spend cap.
const session = SessionKey.generate();
const grant = buildTx(chain.chainId, from, await client.nonce(from), "session.grant", {
sessionKey: session.publicKey,
expiresAt: Math.floor(Date.now() / 1000) + 3600,
maxSpend: "5000000000",
allowedTypes: ["coin.buy", "coin.sell", "pay.transfer"],
});
await client.submit(await signEvmEnvelope(grant, wallet));
// 2. Everything after that is signed by the session key, no prompt.
const buy = buildTx(chain.chainId, from, await client.nonce(from), "coin.buy", {
coinId, solIn: "500000000", minTokensOut: "1",
});
const { hash } = await client.submit(await signMessageEnvelope(buy, session.signer));
// 3. Private reads are signed by the session key too.
const me = client.me(from, session.signer);
console.log(await me.balances(), hash);// An agent or a script signs with its own EVM key and never needs a browser wallet.
import { LeyoraClient, buildTx, evmKeySigner, signEvmEnvelope } from "@leyora/sdk";
const agent = evmKeySigner(process.env.AGENT_PRIVATE_KEY); // 0x hex secp256k1 key
const client = new LeyoraClient({ baseUrl: "https://leyora.xyz" });
const tx = buildTx("leyora-hype-1", agent.address, await client.nonce(agent.address), "pay.transfer", {
to: "0x...", amount: "100000000", // 0.1 HYPE in nano HYPE
});
await client.submit(await signEvmEnvelope(tx, agent));Transaction types
Four types are produced by the sequencer itself and carry no user signature: bridge.deposit, bridge.refund, perps.price and chain.quiet.
Private endpoints
Deposits
Getting HYPE in is a call to depositFor(account) on the door contract on Elysium, from the app or from any EVM wallet, and the credit shows up once the deposit is confirmed. Plain transfers to the contract are refused. From that point every action, a payment, a trade, a launch, a perps position or a withdrawal, is a Leyora transaction that your code can build and send itself.
Verify
The verifier in the repository walks every block, checks hashes, roots and the producer signature, rebuilds the checkpoint chain and compares it with the events the settlement contract logged on Elysium. Every block page in the explorer does the header check in your browser.
Limits
The API allows 300 requests a minute per address and 60 submitted transactions a minute. A block holds at most 500 transactions.