Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions docs/hyperliquid-debugging-signature-errors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ Hyperliquid L1 actions require signing with **chainId 1337**, but your wallet is

```typescript
import { ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
import { PrivateKeySigner } from "@nktkas/hyperliquid/signing";
import { privateKeyToAccount } from "viem/accounts";

// Agent wallet signs with chainId 1337 automatically
const agentSigner = new PrivateKeySigner({ privateKey: AGENT_PRIVATE_KEY });
const agentAccount = privateKeyToAccount(AGENT_PRIVATE_KEY);
const client = new ExchangeClient({
transport: new HttpTransport(),
wallet: agentSigner
wallet: agentAccount
});

// User's browser wallet only signs approveAgent (chainId 0x66eee)
Expand Down Expand Up @@ -220,15 +220,15 @@ For production applications, use this two-wallet pattern:

```typescript
import { ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
import { PrivateKeySigner } from "@nktkas/hyperliquid/signing";
import { privateKeyToAccount } from "viem/accounts";

// First: user approves agent via browser wallet (one-time)
const agentAddress = await approveAgentWithBrowserWallet();

// Then: agent handles all trading
const agentClient = new ExchangeClient({
transport: new HttpTransport(),
wallet: new PrivateKeySigner({ privateKey: agentPrivateKey })
wallet: privateKeyToAccount(agentPrivateKey)
});

// No chainId conflicts because browser wallet never signs L1 actions
Expand All @@ -240,7 +240,7 @@ Hyperliquid has two community TypeScript SDKs:

| SDK | Maintainer | Features |
|-----|------------|----------|
| [@nktkas/hyperliquid](https://github.com/nktkas/hyperliquid) | nktkas | Full API coverage, PrivateKeySigner, viem/ethers support |
| [@nktkas/hyperliquid](https://github.com/nktkas/hyperliquid) | nktkas | Full API coverage, viem/ethers wallet support |
| [nomeida/hyperliquid](https://github.com/nomeida/hyperliquid) | nomeida | Simpler API, good for quick integrations |

### @nktkas/hyperliquid examples
Expand All @@ -256,7 +256,7 @@ npm install @nktkas/hyperliquid viem
import { ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80");
const account = privateKeyToAccount("0x..."); // your private key
const client = new ExchangeClient({
transport: new HttpTransport(),
wallet: account
Expand All @@ -275,14 +275,14 @@ const result = await client.order({
});
```

```typescript With PrivateKeySigner (no viem dependency)
```typescript With an ethers account
import { ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
import { PrivateKeySigner } from "@nktkas/hyperliquid/signing";
import { Wallet } from "ethers";

const signer = new PrivateKeySigner({ privateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" });
const wallet = new Wallet("0x..."); // your private key
const client = new ExchangeClient({
transport: new HttpTransport(),
wallet: signer
wallet
});

// Same API as with viem
Expand Down
27 changes: 25 additions & 2 deletions docs/hyperliquid-methods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ HyperEVM methods listed as `/evm` are also reachable on `/nanoreth`. See [Hyperl
| perpDexStatus | /info | HyperCore | <Icon icon="square-check" iconType="solid" /> |
| spotPairDeployAuctionStatus | /info | HyperCore | <Icon icon="square-check" iconType="solid" /> |
| marginTable | /info | HyperCore | <Icon icon="square-check" iconType="solid" /> |
| alignedQuoteTokenInfo | /info | HyperCore | <Icon icon="square-check" iconType="solid" /> |
| gossipPriorityAuctionStatus | /info | HyperCore | <Icon icon="square-check" iconType="solid" /> |
| subAccounts2 | /info | HyperCore | <Icon icon="square-check" iconType="solid" /> |
| approvedBuilders | /info | HyperCore | <Icon icon="square-check" iconType="solid" /> |
| perpConciseAnnotations | /info | HyperCore | <Icon icon="square-check" iconType="solid" /> |
| settledOutcome | /info | HyperCore | <Icon icon="square-check" iconType="solid" /> |
| allMids | /info | HyperCore | Hyperliquid public RPC |
| userFills | /info | HyperCore | Hyperliquid public RPC |
| userFillsByTime | /info | HyperCore | Hyperliquid public RPC |
| orderStatus | /info | HyperCore | Hyperliquid public RPC |
| l2Book | /info | HyperCore | Hyperliquid public RPC |
| batchClearinghouseStates | /info | HyperCore | Hyperliquid public RPC |
| candleSnapshot | /info | HyperCore | Hyperliquid public RPC |
| historicalOrders | /info | HyperCore | Hyperliquid public RPC |
| userTwapSliceFills | /info | HyperCore | Hyperliquid public RPC |
Expand All @@ -81,6 +84,13 @@ HyperEVM methods listed as `/evm` are also reachable on `/nanoreth`. See [Hyperl
| spotMetaAndAssetCtxs | /info | HyperCore | Hyperliquid public RPC |
| outcomeMeta | /info | HyperCore | Hyperliquid public RPC |
| tokenDetails | /info | HyperCore | Hyperliquid public RPC |
| isVip | /info | HyperCore | Hyperliquid public RPC |
| legalCheck | /info | HyperCore | Hyperliquid public RPC |
| preTransferCheck | /info | HyperCore | Hyperliquid public RPC |
| twapHistory | /info | HyperCore | Hyperliquid public RPC |
| userBorrowLendInterest | /info | HyperCore | Hyperliquid public RPC |
| userTwapSliceFillsByTime | /info | HyperCore | Hyperliquid public RPC |
| validatorSummaries | /info | HyperCore | Hyperliquid public RPC |
| order | /exchange | HyperCore | Hyperliquid public RPC |
| cancel | /exchange | HyperCore | Hyperliquid public RPC |
| cancelByCloid | /exchange | HyperCore | Hyperliquid public RPC |
Expand Down Expand Up @@ -121,6 +131,19 @@ HyperEVM methods listed as `/evm` are also reachable on `/nanoreth`. See [Hyperl
| validatorL1Stream | /exchange | HyperCore | Hyperliquid public RPC |
| noop | /exchange | HyperCore | Hyperliquid public RPC |
| reserveRequestWeight | /exchange | HyperCore | Hyperliquid public RPC |
| userOutcome | /exchange | HyperCore | Hyperliquid public RPC |
| borrowLend | /exchange | HyperCore | Hyperliquid public RPC |
| createVault | /exchange | HyperCore | Hyperliquid public RPC |
| vaultModify | /exchange | HyperCore | Hyperliquid public RPC |
| vaultDistribute | /exchange | HyperCore | Hyperliquid public RPC |
| subAccountModify | /exchange | HyperCore | Hyperliquid public RPC |
| setDisplayName | /exchange | HyperCore | Hyperliquid public RPC |
| registerReferrer | /exchange | HyperCore | Hyperliquid public RPC |
| finalizeEvmContract | /exchange | HyperCore | Hyperliquid public RPC |
| gossipPriorityBid | /exchange | HyperCore | Hyperliquid public RPC |
| linkStakingUser | /exchange | HyperCore | Hyperliquid public RPC |
| stakingLinkDisableTradingUser | /exchange | HyperCore | Hyperliquid public RPC |
| userPortfolioMargin | /exchange | HyperCore | Hyperliquid public RPC |
| net_version | /evm | HyperEVM | <Icon icon="square-check" iconType="solid" /> |
| web3_clientVersion | /evm | HyperEVM | <Icon icon="square-check" iconType="solid" /> |
| eth_blockNumber | /evm | HyperEVM | <Icon icon="square-check" iconType="solid" /> |
Expand Down
6 changes: 3 additions & 3 deletions docs/hyperliquid-tooling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ Use the SDK:
<CodeGroup>
```typescript TypeScript
import { InfoClient, ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
import { PrivateKeySigner } from "@nktkas/hyperliquid/signing";
import { privateKeyToAccount } from "viem/accounts";

// 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 wallet = privateKeyToAccount("0x..."); // viem or ethers account
const exchange = new ExchangeClient({
transport: new HttpTransport(),
wallet: signer
wallet
});

const result = await exchange.order({
Expand Down