> ## Documentation Index
> Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# HyperCore with embedded wallets

> Sign Hyperliquid HyperCore actions with a Dynamic embedded wallet using the @nktkas/hyperliquid SDK.

HyperCore is Hyperliquid's native L1, the order book where trading, transfers, and account actions happen. It isn't an EVM. Instead, every HyperCore action is a structured [EIP-712](https://eips.ethereum.org/EIPS/eip-712) message signed with your account's key and POSTed to the exchange API. There is no gas and no contract call.

That makes HyperCore compatible with Dynamic embedded wallets out of the box. A Dynamic embedded wallet signs EIP-712 typed data exactly like any other EVM account, so `@nktkas/hyperliquid` can drive it with no extra infrastructure and no changes to how signing works.

<Note>
  **HyperCore vs HyperEVM.** HyperCore is the signed-action L1 covered here (trading, transfers, agent approvals). HyperEVM is a separate, standard EVM chain (Chain ID `999`) for smart contracts. If you want to send EVM transactions or interact with contracts on HyperEVM instead, use the [Hyperliquid SDK integration](/recipes/integrations/hyperliquid) recipe.
</Note>

## Prerequisites

* The JavaScript SDK with the [EVM extension](/javascript/reference/evm/adding-evm-extensions) added.
* A Dynamic embedded EVM wallet (see [creating WaaS wallet accounts](/javascript/reference/waas/creating-waas-wallet-accounts)).

<Warning>
  The wallet must be funded on HyperCore before it can trade or approve agents. Fund it through the [Hyperliquid app](https://app.hyperliquid.xyz) (mainnet) or [testnet app](https://app.hyperliquid-testnet.xyz).
</Warning>

## Install

<CodeGroup>
  ```bash npm theme={"system"}
  npm install @nktkas/hyperliquid
  ```

  ```bash yarn theme={"system"}
  yarn add @nktkas/hyperliquid
  ```

  ```bash pnpm theme={"system"}
  pnpm add @nktkas/hyperliquid
  ```

  ```bash bun theme={"system"}
  bun add @nktkas/hyperliquid
  ```
</CodeGroup>

## Create the exchange client and place an order

Turn the embedded wallet account into a Viem [WalletClient](https://viem.sh/docs/clients/wallet) with [`createWalletClientForWalletAccount`](/javascript/reference/evm/getting-viem-wallet-client), then hand its `account` to the Hyperliquid `ExchangeClient`. It signs every HyperCore action with that account's `signTypedData`.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={"system"}
    import * as hl from '@nktkas/hyperliquid';
    import { createWalletClientForWalletAccount } from '@dynamic-labs-sdk/evm/viem';

    const placeOrder = async (walletAccount) => {
      // The embedded wallet's viem account signs the EIP-712 HyperCore action.
      const { account } = await createWalletClientForWalletAccount({
        walletAccount,
      });

      const exchangeClient = new hl.ExchangeClient({
        transport: new hl.HttpTransport(), // { isTestnet: true } for testnet
        wallet: account,
      });

      const result = await exchangeClient.order({
        orders: [
          {
            a: 0, // asset index (Hyperliquid universe index, e.g. 0 for BTC-USD perp)
            b: true, // is_buy
            p: '95000', // limit price
            s: '0.001', // size
            r: false, // reduce_only
            t: { limit: { tif: 'Gtc' } }, // good-'til-cancelled
          },
        ],
        grouping: 'na',
      });

      console.log('Order placed:', result);
      return result;
    };
    ```
  </Tab>

  <Tab title="React">
    ```tsx theme={"system"}
    import * as hl from '@nktkas/hyperliquid';
    import { createWalletClientForWalletAccount } from '@dynamic-labs-sdk/evm/viem';
    import { isEvmWalletAccount } from '@dynamic-labs-sdk/evm';
    import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';

    function PlaceOrderButton() {
      const { data: walletAccounts = [] } = useGetWalletAccounts();
      const walletAccount = walletAccounts.find(isEvmWalletAccount);

      const handlePlaceOrder = async () => {
        if (!walletAccount) return;

        const { account } = await createWalletClientForWalletAccount({
          walletAccount,
        });

        const exchangeClient = new hl.ExchangeClient({
          transport: new hl.HttpTransport(),
          wallet: account,
        });

        const result = await exchangeClient.order({
          orders: [
            {
              a: 0,
              b: true,
              p: '95000',
              s: '0.001',
              r: false,
              t: { limit: { tif: 'Gtc' } },
            },
          ],
          grouping: 'na',
        });

        console.log('Order placed:', result);
      };

      return (
        <button onClick={handlePlaceOrder} disabled={!walletAccount}>
          Place order
        </button>
      );
    }
    ```
  </Tab>
</Tabs>

## Read account state

Use an `InfoClient` with the wallet address to fetch balances and open positions.

```javascript theme={"system"}
import * as hl from '@nktkas/hyperliquid';

const getAccountState = async (address) => {
  const infoClient = new hl.InfoClient({ transport: new hl.HttpTransport() });
  const state = await infoClient.clearinghouseState({ user: address });

  console.log('Account value:', state.marginSummary.accountValue);
  return state;
};
```

## Related

* [Hyperliquid SDK integration](/recipes/integrations/hyperliquid) for connected/external EVM wallets and HyperEVM (Chain ID 999).
* [Getting a Viem WalletClient](/javascript/reference/evm/getting-viem-wallet-client)
* [Sign Typed Data (EIP-712)](/javascript/reference/evm/sign-typed-data)
* [Hyperliquid SDK repository](https://github.com/nktkas/hyperliquid)
* [Hyperliquid API documentation](https://hyperliquid.gitbook.io/hyperliquid-docs)
