Skip to main content
Import and initialize the client, authorize via wallet signature and make a test call:
import { Ed25519Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";

import { EkidenClient, TESTNET } from "@ekiden/ts-sdk";

const ekiden = new EkidenClient(TESTNET);

const privateKey = new Ed25519PrivateKey(ENV.PRIVATE_KEY);
const account = new Ed25519Account({ privateKey });

const publicKey = account.publicKey.toString();

const nowMs = Date.now();
const nonce = crypto.getRandomValues(new Uint8Array(16))
  .reduce((acc, b) => acc + String.fromCharCode(b), "");
const nonceB64Url = btoa(nonce).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
const signed = `AUTHORIZE|${nowMs}|${nonceB64Url}`;
const messageBytes = new TextEncoder().encode(signed);
const signature = account.sign(messageBytes).toString();


// Authorize (get JWT)
const { token } = await ekiden.authorize({
  signature,
  public_key: publicKey,
  timestamp_ms: nowMs,
  nonce: nonceB64Url
});

// Fetch user orders
const orders = await ekiden.getUserOrders({ market_addr: "0x..." });

// Fetch user vaults
const vaults = await ekiden.getUserVaults();

// Fetch user positions
const positions = await ekiden.getUserPositions();