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

# Canton

> Create Canton wallets, register parties with a validator, and sign topology transactions with Privy

Privy supports Canton at [Tier 1](https://docs.privy.io/wallets/overview/chains.md). You can create Canton wallets, produce
raw Ed25519 signatures, and export private keys. Your application is responsible for registering
the wallet as an external party and interacting with the Canton network.

> [!WARNING]
>
> Creating a Privy wallet does not register a party on Canton. You must complete the validator's
> external-party topology flow before the wallet can interact with the network.

## Create a wallet

Create a wallet with `chain_type` set to `canton`. Run these examples on the server to keep the
app secret private.

> [tab] Node.js
>
> ```typescript theme={"system"}
> import {PrivyClient} from '@privy-io/node';
>
> const client = new PrivyClient({
>   appId: process.env.PRIVY_APP_ID!,
>   appSecret: process.env.PRIVY_APP_SECRET!
> });
>
> const wallet = await client.wallets().create({
>   chain_type: 'canton',
>   owner: {user_id: 'privy:did:your-user-id'}
> });
>
> console.log(wallet.id, wallet.address, wallet.public_key);
> ```

> [tab] REST API
>
> Call the [wallet creation endpoint](https://docs.privy.io/api-reference/wallets/create.md) directly:
>
> ```typescript theme={"system"}
> const appId = process.env.PRIVY_APP_ID!;
> const appSecret = process.env.PRIVY_APP_SECRET!;
>
> const createResponse = await fetch('https://api.privy.io/v1/wallets', {
>   method: 'POST',
>   headers: {
>     Authorization: `Basic ${Buffer.from(`${appId}:${appSecret}`).toString('base64')}`,
>     'Content-Type': 'application/json',
>     'privy-app-id': appId
>   },
>   body: JSON.stringify({
>     chain_type: 'canton',
>     owner: {user_id: 'privy:did:your-user-id'}
>   })
> });
>
> if (!createResponse.ok) {
>   throw new Error(`Failed to create Canton wallet: ${await createResponse.text()}`);
> }
>
> const wallet = (await createResponse.json()) as {
>   id: string;
>   address: string;
>   public_key: string;
> };
>
> console.log(wallet.id, wallet.address, wallet.public_key);
> ```

The wallet uses Ed25519 and EdDSA. Its `address` is the fingerprint of its public key, formatted as
`1220` followed by a 32-byte SHA-256 digest. Canton party IDs add a party hint to this fingerprint:
`<party-hint>::<wallet.address>`.

## Register the party

Canton is a permissioned network. Register each new wallet through a validator that is connected to
your target network. The validator constructs the topology transactions; Privy signs their hashes;
the validator then submits them to the network.

Your validator operator must provide:

* The validator API base URL
* A bearer token authorized to call the validator admin API
* A unique party hint

The example below uses the validator's `external-party/topology/generate` and
`external-party/topology/submit` endpoints. Validator authentication is deployment-specific, so
fetch the bearer token according to your operator's instructions.

**1. Generate topology transactions**

Privy returns the Ed25519 public key as a `00` prefix followed by the 32-byte key. Canton expects
only the raw 32-byte key, so remove the first byte.

```typescript theme={"system"}
const validatorUrl = process.env.CANTON_VALIDATOR_URL!;
const validatorToken = process.env.CANTON_VALIDATOR_TOKEN!;
const partyHint = 'your-unique-party-hint';

const rawPublicKey = wallet.public_key!.slice(2);

const generateResponse = await fetch(
  `${validatorUrl}/api/validator/v0/admin/external-party/topology/generate`,
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${validatorToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      party_hint: partyHint,
      public_key: rawPublicKey
    })
  }
);

if (!generateResponse.ok) {
  throw new Error(`Failed to generate topology: ${await generateResponse.text()}`);
}

const topology = await generateResponse.json() as {
  party_id: string;
  topology_txs: Array<{topology_tx: string; hash: string}>;
};
```

**2. Verify the party ID**

Check that the validator derived the same fingerprint as Privy before signing anything.

```typescript theme={"system"}
const fingerprint = topology.party_id.split('::').at(-1);
if (fingerprint !== wallet.address) {
  throw new Error('The validator party ID does not match the Privy wallet');
}
```

**3. Sign the topology transactions**

Sign each transaction hash directly. Do not hash it again or add a prefix.

```typescript theme={"system"}
import {PrivyClient} from '@privy-io/node';

const privy = new PrivyClient({
  appId: process.env.PRIVY_APP_ID!,
  appSecret: process.env.PRIVY_APP_SECRET!
});

const signedTopologyTxs = await Promise.all(
  topology.topology_txs.map(async ({topology_tx, hash}) => {
    const {signature} = await privy.wallets().rawSign(wallet.id, {
      params: {hash: `0x${hash}`}
    });

    return {
      topology_tx,
      signed_hash: signature.slice(2)
    };
  })
);
```

**4. Submit the signed topology**

Submit the original topology transactions with their signatures. Store the returned `party_id`;
applications use the full party ID, not the fingerprint alone, when interacting with Canton.

```typescript theme={"system"}
const submitResponse = await fetch(
  `${validatorUrl}/api/validator/v0/admin/external-party/topology/submit`,
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${validatorToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      public_key: rawPublicKey,
      signed_topology_txs: signedTopologyTxs
    })
  }
);

if (!submitResponse.ok) {
  throw new Error(`Failed to register party: ${await submitResponse.text()}`);
}

const {party_id: partyId} = await submitResponse.json() as {party_id: string};
```

After registration, use your validator's APIs and Canton application libraries to construct and
submit application-specific transactions. When Canton requires an Ed25519 signature over a
32-byte hash, sign that hash with Privy's [`raw_sign`](https://docs.privy.io/wallets/using-wallets/other-chains) method.

> [!NOTE]
>
> Canton support does not include transaction construction, submission, validator authentication, or
> party registration as managed Privy operations.
