# Install and signers

Set up the TypeScript SDK. It is `@maxy-labs/sdk`, under the MIT licence, installed from maxy.co rather than the npm registry; it is ESM only and runs on Node 18+ and in browsers.

1. Make a project: `mkdir first && cd first && npm init -y && npm pkg set type=module`
2. Install it: `npm install https://maxy.co/sdk/maxy-labs-sdk-latest.tgz viem` (the SHA-256 of each file is in https://maxy.co/sdk/SHA256SUMS; to upgrade, install the same URL again)
3. Set your test key: `export MAXY_API_KEY=mxk_test_…`

Put this in `first.mjs` and run `node first.mjs`:

```js
import { createMaxyClient } from '@maxy-labs/sdk';

const maxy = createMaxyClient(); // reads MAXY_API_KEY

const price = await maxy.swap.price({ from: 'ETH on base', to: 'BTC', amount: '0.01' });
console.log(price.formatted);
// { send: '0.01 ETH on Base', receive: '0.00029 BTC', pair: 'ETH on Base → BTC' }

console.log((await maxy.swap.pairs()).map((p) => p.label));
// [ 'ETH on Base → BTC', 'USDC on Base → BTC', …, 'SOL → BTC', 'BTC → SOL' ]
```

| Import | Gives |
| --- | --- |
| `@maxy-labs/sdk/core` | The client, flow helpers and error classes. `fetch` only, 17 kB |
| `@maxy-labs/sdk/evm`, `/solana`, `/bitcoin` | One helper per chain |
| `@maxy-labs/sdk/server` | `verifyWebhook`, for Node and edge servers |
| `@maxy-labs/sdk/testing` | Mocks and fixtures |
| `@maxy-labs/sdk` | All of it, plus `swap`, `borrow`, `mint`, `auth` |

Every method is one route. Each failure is a `MaxyError` subclass with `code`, `status`, `requestId` and `retryable`.

## Signers

A signer is your wallet, in the shape the SDK takes. Keys stay in your wallet or your own key system: the SDK never holds one.

```ts
import { bitcoinSignerFromKey, evmSignerFromEip1193, evmSignerFromPrivateKey, evmSignerFromWalletClient } from '@maxy-labs/sdk';

const fromBrowser = evmSignerFromEip1193(window.ethereum);        // an injected wallet, once connected
const fromViem = evmSignerFromWalletClient(walletClient);         // a viem wallet client
const fromKey = evmSignerFromPrivateKey(process.env.EVM_PRIVATE_KEY!);     // a server; follows the SDK to every Maxy chain
const bitcoin = bitcoinSignerFromKey(process.env.BTC_PRIVATE_KEY!);        // a server
```

| Chain | Takes |
| --- | --- |
| EVM | A viem wallet client, an EIP-1193 provider, or a key-backed signer |
| Bitcoin | A browser wallet adapter, or a key-backed signer |
| Solana | The provider shape browser wallets inject |

A wallet that could not switch chains throws `wrong_chain`: ask the user to switch. One that cannot sign what the order needs throws `signer_unsupported`: use another wallet. Each interface, with its adapters: the [integration guide PDF](https://maxy.co/guides/maxy-integration-guide.pdf).

---
Source: https://maxy.co/docs/install-and-signers (Maxy Docs › SDK › Set up)
