import { InfoClient, ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
import { PrivateKeySigner } from "@nktkas/hyperliquid/signing";
// Query market data (no authentication required)
const info = new InfoClient({ transport: new HttpTransport() });
const meta = await info.meta();
console.log(meta);
// Trading operations (requires authentication)
const signer = new PrivateKeySigner({ privateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" });
const exchange = new ExchangeClient({
transport: new HttpTransport(),
wallet: signer
});
const result = await exchange.order({
orders: [{
a: 0, // Asset index (0 = BTC)
b: true, // is_buy
p: "50000", // price
s: "0.001", // size
r: false, // reduce_only
t: { limit: { tif: "Gtc" } }
}],
grouping: "na"
});