---
title: "Getting Started"
description: "Install the package. Load a chain. Get a wallet out in five lines."
canonical_url: "https://keys.agntn.dev/guide"
---
# Getting Started

> Install the package. Load a chain. Get a wallet out in five lines.

<warning title="Still experimental">

Package name, public API, the lazy loader, and the tool surface can all change before 1.0. Pin exact versions if you build on it now.

</warning>

<caution title="Not audited">

This code has never had a security audit. Do not use it in production, with real funds or with sensitive data. It is meant for puzzles, learning and local experiments only. It comes as is, without warranty of any kind, and the authors are not liable for any loss, as the MIT license states. Anything that matters wants an audited library.

</caution>

<caution title="Never point this at real funds">

Every key that passes through the library, the explorer, or an MCP server is plaintext in a process, a log, or an agent transcript. Treat it as burned the moment it exists. Real money belongs on a hardware wallet.

</caution>

## Why this exists

Every chain has its own idea of a key, an address, and a signature. Bitcoin hashes twice and encodes in base58, Ethereum takes the tail of a Keccak hash, Solana just base58 encodes the public key, Cardano wants bech32 with a header byte. Pulling one library per chain into a project means five APIs, five option shapes, and five ways to get an address wrong.

`@agntn/keys` puts every chain it ships behind one class shape. Same calls, same option object, same wallet type. The chain decides the rules, you decide the key.

## Install

```bash
pnpm add @agntn/keys
```

Node.js 26 or newer. Pure JavaScript all the way down, nothing to compile, and no `node:` import anywhere, so a browser bundle needs no shim. The [Keyspace](https://keys.agntn.dev/keyspace) explorer is exactly that bundle.

## First wallet

```js [my-wallet.js]
import { useBlockchain, blockchains } from "@agntn/keys";

// Concrete classes load on demand. First call takes options, second call imports and constructs.
const bitcoin = await blockchains.bitcoin()();
const ethereum = await blockchains.ethereum()();

const bitcoinChain = useBlockchain(bitcoin);
const ethereumChain = useBlockchain(ethereum);

const btcWallet = bitcoinChain.generateWallet();
const ethWallet = ethereumChain.generateWallet();

console.log(btcWallet.address); // 1...
console.log(ethWallet.address); // 0x...
```

The double call looks odd the first time. It's deliberate: `blockchains.bitcoin({ network: "testnet" })` only records the options, and the second `()` is the moment the chain module actually gets imported. Nothing you never call ends up in your bundle.

## What ships

<table>
<thead>
  <tr>
    <th>
      Chain
    </th>
    
    <th>
      Curve
    </th>
    
    <th>
      Addresses
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Bitcoin
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      legacy, p2sh, segwit, p2wsh, taproot
    </td>
  </tr>
  
  <tr>
    <td>
      Bitcoin Cash
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      Bitcoin's P2PKH hash in CashAddr, starts with <code>
        bitcoincash:q
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Bitcoin Gold
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      four of Bitcoin's five, with <code>
        G
      </code>
      
      , <code>
        A
      </code>
      
       and <code>
        btg1q
      </code>
      
       prefixes, no taproot
    </td>
  </tr>
  
  <tr>
    <td>
      Bitcoin SV
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      legacy P2PKH, the same <code>
        1
      </code>
      
       address Bitcoin gives
    </td>
  </tr>
  
  <tr>
    <td>
      Litecoin
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      the same five, with <code>
        L
      </code>
      
      , <code>
        M
      </code>
      
       and <code>
        ltc1
      </code>
      
       prefixes
    </td>
  </tr>
  
  <tr>
    <td>
      Dash
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      legacy P2PKH, starts with <code>
        X
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Decred
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      legacy ECDSA P2PKH, starts with <code>
        Ds
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Dogecoin
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      legacy P2PKH, starts with <code>
        D
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Zcash
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      transparent P2PKH, starts with <code>
        t1
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      eCash
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      Bitcoin's P2PKH hash in CashAddr, starts with <code>
        ecash:q
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Ethereum
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      EIP-55 hex
    </td>
  </tr>
  
  <tr>
    <td>
      Base
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      EIP-55 hex, same as Ethereum
    </td>
  </tr>
  
  <tr>
    <td>
      TRON
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      base58check, starts with <code>
        T
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Solana
    </td>
    
    <td>
      ed25519
    </td>
    
    <td>
      base58 public key
    </td>
  </tr>
  
  <tr>
    <td>
      Stellar
    </td>
    
    <td>
      ed25519
    </td>
    
    <td>
      <code>
        G
      </code>
      
       StrKey, base32 with a checksum
    </td>
  </tr>
  
  <tr>
    <td>
      Aptos
    </td>
    
    <td>
      ed25519
    </td>
    
    <td>
      <code>
        0x
      </code>
      
       hex, SHA3-256
    </td>
  </tr>
  
  <tr>
    <td>
      Sui
    </td>
    
    <td>
      ed25519 or secp256k1
    </td>
    
    <td>
      <code>
        0x
      </code>
      
       hex, Blake2b
    </td>
  </tr>
  
  <tr>
    <td>
      Cardano
    </td>
    
    <td>
      ed25519
    </td>
    
    <td>
      bech32 base, enterprise, stake
    </td>
  </tr>
  
  <tr>
    <td>
      XRP Ledger
    </td>
    
    <td>
      secp256k1 or ed25519
    </td>
    
    <td>
      classic <code>
        r
      </code>
      
       address, base58check in XRPL's alphabet
    </td>
  </tr>
  
  <tr>
    <td>
      NEAR
    </td>
    
    <td>
      ed25519
    </td>
    
    <td>
      implicit account, the public key in hex
    </td>
  </tr>
  
  <tr>
    <td>
      Cosmos
    </td>
    
    <td>
      secp256k1
    </td>
    
    <td>
      bech32 under the chain's prefix, <code>
        cosmos
      </code>
      
       by default
    </td>
  </tr>
  
  <tr>
    <td>
      Polkadot
    </td>
    
    <td>
      sr25519 or ed25519
    </td>
    
    <td>
      SS58 under the network prefix, <code>
        0
      </code>
      
       by default and <code>
        42
      </code>
      
       on testnet
    </td>
  </tr>
  
  <tr>
    <td>
      Monero
    </td>
    
    <td>
      ed25519
    </td>
    
    <td>
      standard, subaddress and integrated, both public keys in block base58
    </td>
  </tr>
  
  <tr>
    <td>
      TON
    </td>
    
    <td>
      ed25519
    </td>
    
    <td>
      the account of a v3r2, v4r2 or v5r1 wallet contract, <code>
        UQ
      </code>
      
       or <code>
        EQ
      </code>
      
       in base64url
    </td>
  </tr>
</tbody>
</table>

Each chain has its own page under [Blockchains](https://keys.agntn.dev/blockchains) with the exact rules and the gotchas. Three of them refuse `deriveHDWallet` on purpose, Decred, Cardano and Monero, and their pages say why.

## The three steps

Every chain does the same three things, with different rules for each.

### 1. A private key is 32 random bytes

```js
const privateKey = bitcoinChain.generateKeyPrivate();
```

A 64 character hex string. Both curves ask `@noble/curves` for it, `randomSecretKey()` on secp256k1 and on ed25519, and noble reads `globalThis.crypto` underneath. Same code in Node and in the browser.

### 2. The public key comes from the curve

```js
const publicKey = bitcoinChain.getKeyPublic(privateKey);
const keys = bitcoinChain.generateKeys(); // both at once
```

secp256k1 chains give you a compressed 33 byte key by default. Pass `{ compressed: false }` for the 65 byte one. ed25519 keys are always 32 bytes.

### 3. The address is a hash, then an encoding

```js
const address = bitcoinChain.getAddress(publicKey);
const segwit = bitcoinChain.getAddress(publicKey, "segwit");
```

The second argument is the address type. Chains with one format ignore it, chains with several use it to pick, and Decred throws if you ask for one it doesn't have.

`generateWallet()` runs all three and hands back `{ keys: { private, public }, address }`.

## Checking an address

```js
bitcoinChain.validateAddress("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"); // true
```

Every built in chain validates its own formats, including checksums where the format has one. It's a format check, not a lookup: a valid address can still have zero history on chain.

## Which curve am I on

```js
bitcoinChain.curve; // 'secp256k1'
solanaChain.curve; // 'ed25519'
suiChain.curve; // ['ed25519', 'secp256k1']
xrpChain.curve; // ['secp256k1', 'ed25519']
```

Sui and the XRP Ledger answer with a list. Their pages say how to pick.

## Agents

The same code runs as an MCP server over stdio, every tool from `keys_electrum_wallet_derive` through `keys_bip44_generate`:

```bash
npx -y @agntn/keys mcp
pi install npm:@agntn/keys
omp install @agntn/keys
```

```json
{
  "mcpServers": {
    "keys": { "command": "npx", "args": ["-y", "@agntn/keys", "mcp"] }
  }
}
```

Wallets, HD derivation, addresses, signing, BIP44 paths, mnemonics in all ten BIP39 lists, WIF both ways and public key conversion, with the same parameters the library takes. The Pi and OMP extensions in [`extensions`](https://github.com/agntn/keys/tree/main/extensions) run the exact same executors, installed from npm or from a checkout. A generated mnemonic comes back with a line saying it's in the transcript now. That line isn't decoration, it's the whole security model: public puzzle material and throwaway keys only.

## AI SDK

Ready to hand your model every key tool?

```bash
pnpm add @agntn/keys ai @ai-sdk/anthropic
```

```ts
import { anthropic } from "@ai-sdk/anthropic";
import { keysAiTools } from "@agntn/keys/ai";
import { generateText, isStepCount } from "ai";

const { text } = await generateText({
  model: anthropic("claude-sonnet-5-5"),
  tools: keysAiTools,
  stopWhen: isStepCount(5),
  prompt: "Is 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2 a valid Bitcoin address?",
});
```

The model reads the text an MCP client reads. Word for word. Your app gets it as `text`, right next to the structured details.

Four tools ask first: `keys_wallet_generate`, `keys_bip39_generate`, `keys_message_sign` and `keys_bip322_sign`. Everything else runs straight away. A mnemonic shouldn't show up just because a model felt like it. Want to approve one? Pass `toolApproval` to `generateText`.

```ts
await generateText({
  model: anthropic("claude-sonnet-5-5"),
  tools: keysAiTools,
  toolApproval: { keys_wallet_generate: "approved" },
  stopWhen: isStepCount(5),
  prompt: "Make me a throwaway Solana wallet.",
});
```

The keys are typed. Write `keysAiTools.keys_adress_validate` and `tsc` suggests `keys_address_validate`. One missing letter, caught.

Only `@agntn/keys/ai` needs the optional `ai` peer, version 7. The executors load on the first call. Nothing touches the network.

## Remote MCP

No Node on your side? This site runs the same tools over Streamable HTTP, at `https://keys.agntn.dev/mcp`. Give it to any MCP client that takes a URL.

```bash
claude mcp add --transport http keys https://keys.agntn.dev/mcp
```

```json
{
  "mcpServers": {
    "keys": { "type": "http", "url": "https://keys.agntn.dev/mcp" }
  }
}
```

It's the Docus MCP server with the key tools added to it. Not copies, though. `toToolkitTools` from `@agntn/tools/toolkit` hands Docus the very definitions `keys mcp` serves. So every call answers exactly like `keys mcp`, the refusals too. Misspell an option and both turn it down in the same words, with any sneaky bidi character flattened to a space. A new tool? It's here after the next deploy, since the site keeps no list of its own to forget it on. Two more come from Docus. `list-pages` lists the pages of this site and `get-page` returns one as Markdown.

Only one thing differs. A web page on another origin gets a 403. Clients that call from their own process, like Claude Code or Cursor, send no origin and get in.

The part that matters more: every argument goes to a Cloudflare worker. Nothing on the site logs or stores it, but that's a promise, not something you can check from your side. A private key sent here has left your machine, one hop further than the transcript. Same rule, so puzzle material and throwaway keys only. Want one hop less? `npx -y @agntn/keys mcp` runs the tools on your machine.


## Sitemap

See the full [sitemap](https://keys.agntn.dev/sitemap.md) for all pages.
