---
title: kingpin-apps/swift-cardano-token-registry
framework: Swift Package Catalog
role: article
path: packages/kingpin-apps/swift-cardano-token-registry
---

# kingpin-apps/swift-cardano-token-registry

Swift port of input-output-hk's [`token-metadata-creator`](https://github.com/input-output-hk/offchain-metadata-tools/tree/master/token-metadata-creator) — build, sign, validate, and look up off-chain metadata entries for the [Cardano Token Registry](https://github.com/cardano-fo

## What's in the box

| Product | What it is | |---|---| | `SwiftCardanoTokenRegistry` | Library: types, validators, attestation, policy evaluation, file I/O | | `SwiftCardanoTokenRegistryClient` | Library: read-only HTTP client over the `metadata-server` API | | `token-metadata` | Executable: standalone CLI (`create` / `validate` / `query`) |

## Install

### Swift Package Manager

```swift .package(url: "https://github.com/Kingpin-Apps/swift-cardano-token-registry.git", from: "0.1.0") ```

Target dependencies:

```swift .product(name: "SwiftCardanoTokenRegistry", package: "swift-cardano-token-registry"), .product(name: "SwiftCardanoTokenRegistryClient", package: "swift-cardano-token-registry"), ```

### CLI

```sh git clone https://github.com/Kingpin-Apps/swift-cardano-token-registry.git cd swift-cardano-token-registry swift build -c release cp .build/release/token-metadata ~/.local/bin/ ```

## Library usage

```swift import SwiftCardanoTokenRegistry import SwiftCardanoCore

let subject = try Subject("19309eb9c066253cede617dc635223ace320ae0bbdd5bd1968439cd0") let policyHex = "82008201818200581c2b0c33e73d2a70733edc971d19e2cafbada1692db2d35e7dc9453df2"

var entry = GoguenRegistryEntry(     subject: subject,     policy: try WellKnown.Policy(hex: policyHex),     name: Attested(value: try WellKnown.Name("ギル")),     description: Attested(value: try WellKnown.Description("Final Fantasy currency.")) )

let key: PaymentExtendedSigningKey = try .load(from: "policy.skey") try entry.name?.sign(subject: subject, with: key) try entry.description?.sign(subject: subject, with: key)

let issues = entry.validate(options: .finalize) guard issues.isEmpty else { /* handle */ }

let url = RegistryFile.canonicalURL(for: subject, in: URL(fileURLWithPath: ".")) try RegistryFile.save(entry, to: url) ```

Server-side lookups use the same types:

```swift import SwiftCardanoTokenRegistryClient

let client = RegistryClient()  // defaults to mainnet if let entry = try await client.fetchEntry(subject: subject) {     let issues = entry.validate(options: .lenient) } ```

## CLI usage

```sh # Build + sign + finalise an entry. token-metadata create $SUBJECT --init token-metadata create $SUBJECT --name "ADA" --description "..." --policy <hex> token-metadata create $SUBJECT --attest policy.skey token-metadata create $SUBJECT --finalize

# Validate a single entry or an update pair. token-metadata validate entry.json token-metadata validate new.json old.json

# Fetch from the live metadata-server. token-metadata query $SUBJECT                   # mainnet by default token-metadata query $SUBJECT --endpoint preprod ```

Run `token-metadata <subcommand> --help` for the full flag list, or see the in-package DocC.

## Documentation

Library and client API reference, plus walkthroughs:

- [`SwiftCardanoTokenRegistry`](https://swiftpackageindex.com/Kingpin-Apps/swift-cardano-token-registry/documentation/swiftcardanotokenregistry) — core library - [`SwiftCardanoTokenRegistryClient`](https://swiftpackageindex.com/Kingpin-Apps/swift-cardano-token-registry/documentation/swiftcardanotokenregistryclient) — HTTP client - CLI usage lives inside the executable's DocC catalog (`Sources/token-metadata/token-metadata.docc/`)

To preview the docs locally:

```sh swift package --disable-sandbox preview-documentation --target SwiftCardanoTokenRegistry ```

## Platform support

iOS 16+ · macOS 14+ · watchOS 8+ · tvOS 15+ · visionOS 1+ · macCatalyst 15+ · Linux.

## Status

Functional but pre-1.0. Wire format matches the upstream Haskell tool's output against the upstream `offchain-metadata-tools/token-metadata-creator/test` fixture vectors (alice + carole key fixtures, alice's all-of(sig) policy).

## Acknowledgements

This is a direct port of [`input-output-hk/offchain-metadata-tools/token-metadata-creator`](https://github.com/input-output-hk/offchain-metadata-tools/tree/master/token-metadata-creator). Wire-format details, validation rules, and the attestation digest scheme are theirs; the Swift implementation is ours.

## License

Apache-2.0.

## Package Metadata

Repository: kingpin-apps/swift-cardano-token-registry

Default branch: main

README: README.md
