Ledger¶
The ledger namespace is used for preparing, signing, and executing transactions and other Ledger API operations.
Availability¶
The ledger namespace is always available as part of the basic SDK interface. It’s initialized automatically when you create an SDK instance and doesn’t require additional configuration via extend().
import { localNetStaticConfig, SDK } from '@canton-network/wallet-sdk'
export default async function () {
const sdk = await SDK.create({
auth: global.TOKEN_PROVIDER_CONFIG_DEFAULT,
ledgerClientUrl: localNetStaticConfig.LOCALNET_APP_USER_LEDGER_URL,
amulet: global.AMULET_NAMESPACE_CONFIG,
})
const partyId = EXISTING_PARTY_1
const privateKey = EXISTING_PARTY_1_KEYS.privateKey
const [commands, disclosedContracts] = await sdk.amulet.tap(partyId, '200')
// ledger namespace is immediately available
await sdk.ledger
.prepare({ partyId, commands, disclosedContracts })
.sign(privateKey)
.execute({ partyId })
}
Key changes from v0 to v1¶
v0 used the userLedger or adminLedger controller with implicit party context set via sdk.setPartyId().
v1 uses the ledger namespace where you:
Pass
partyIdexplicitly to each operationHave an explicit lifecycle with
prepare/sign/executechain instead of a single methodAccess operations through logical groupings (
external,internal,dar, andacs)
Prepare, signing, and executing transactions
Previously, a single method would handle everything.
Each step in lifecycle is clearer, workflowIds are generated automatically and there is better typesafety at each step.
The below example demonstrates how offline signing works.
Active Contract Set (ACS) queries
No need to manually enter get the ledger end for the offset and there is direct extraction of the activeContracts. However, we still have an acs.readRaw method for unfiltered results.
DAR management
Migration reference¶
v0 method |
v1 method |
|---|---|
|
|
|
|
|
|
|
|
See also¶
Wallet SDK Configuration - SDK configuration
Preparing and Signing Transactions Using External Party - Transaction lifecycle