@minswap/cip113-sdk
v0.2.0
Published
TypeScript transaction builders for a CIP-113 programmable token on Cardano
Readme
@minswap/cip113-sdk
Transaction builders for one CIP-113 programmable token on Cardano. Every builder returns an unsigned transaction and the key hashes that must sign it. The SDK never holds a key and never submits.
Preprod only. The SDK targets the Cardano Foundation CIP-113 core deployment on Preprod. Cip113Constant throws
INVALID_CONFIG for any other network.
Install
pnpm add @minswap/cip113-sdk @minswap/internal-sdk@minswap/internal-sdk (0.1.16 or later) is a peer dependency: the builders take and return its Address,
Credential, Utxo and TxIn types. Node 24 or later.
You also need a Kupo, an Ogmios and a DBSync instance that follow Preprod.
Usage
import { NetworkEnvironment, RustModule, TxIn } from "@minswap/internal-sdk";
import {
Cip113Constant,
createDbSync,
DbSyncHistory,
deriveToken,
findDeployedReferenceScripts,
KupoClient,
KupoOgmiosProvider,
keyCredential,
OgmiosClient,
transfer,
} from "@minswap/cip113-sdk";
await RustModule.load();
const networkEnv = NetworkEnvironment.TESTNET_PREPROD;
const ogmios = new OgmiosClient(OGMIOS_URL);
const provider = new KupoOgmiosProvider(new KupoClient(KUPO_URL), ogmios);
const history = new DbSyncHistory(createDbSync(DBSYNC_URL), ogmios, networkEnv);
const deployment = Cip113Constant.get().deployment(networkEnv);
// The parameters you chose when the token was deployed.
const token = deriveToken(deployment, {
creatorPkh: "badf8e85…",
nonce: "91adaa6d13ccd9b5",
denylistSeed: TxIn.fromString("05a1567b…#1"),
assetName: "0014df104747",
});
const ctx = { provider, history, deployment, token };
token.referenceScripts = await findDeployedReferenceScripts(ctx);
const wallet = { changeAddress: feePayerAddress, utxos: await provider.getUtxosByAddress(feePayerAddress) };
const tx = await transfer(ctx, wallet, {
ownerPkh: senderPkh,
recipient: keyCredential(recipientPkh),
amount: 1_000_000n,
});
// Sign tx.cbor with the fee payer's key and every key in tx.requiredSigners, then submit.Amounts are bigint in base units.
Builders
| Builder | What it does | Signer |
|---|---|---|
| deployReferenceScripts | Publishes the token's four scripts as reference scripts | Fee payer |
| initDenylist | Creates the denylist origin node | Fee payer (spends denylistSeed) |
| registerCredentials | Registers the reward accounts the token's withdraw-zeros use | Creator, if its vote is not yet delegated |
| registerAndMint | Inserts the registry node and mints the full supply, with optional CIP-68 metadata | Creator |
| transfer | Moves tokens between smart wallets | Owner |
| freeze / unfreeze | Adds or removes a stake credential on the denylist | Creator |
| seize | Moves tokens out of a smart wallet without its owner | Creator (third-party key) |
| burn | Burns the owner's tokens | Owner |
| updateMetadata | Replaces the CIP-68 metadata | Creator |
| updateNode | Rewrites the mutable fields of the registry node | Creator |
A new token runs them in this order: deployReferenceScripts, initDenylist, registerCredentials,
registerAndMint.
Errors
Every failure throws Cip113Error. Narrow on error.code to get typed error.details.
try {
await transfer(ctx, wallet, input);
} catch (error) {
if (error instanceof Cip113Error && error.code === "SENDER_DENYLISTED") {
console.log(error.details.stakeHash);
}
}License
MIT
