Skip to content
CCPEDIAby Unity Nodes
App Development

How to decode transaction.preparedTransaction?

2 posts43 viewsLast activity Dec 2025

  1. stanley_nieOP

    import {

    WalletSDKImpl,
    

    localNetAuthDefault,

    localNetLedgerDefault,

    localNetTopologyDefault,

    localNetTokenStandardDefault,

    localNetStaticConfig,

    } from ‘@canton-network/wallet-sdk’

    import { pino } from ‘pino’

    import { v4 } from ‘uuid’

    const onlineLogger = pino({ name: ‘online-localnet’, level: ‘info’ })

    const onlineSDK = new WalletSDKImpl().configure({

    logger: onlineLogger,

    authFactory: localNetAuthDefault,

    ledgerFactory: localNetLedgerDefault,

    topologyFactory: localNetTopologyDefault,

    tokenStandardFactory: localNetTokenStandardDefault,

    })

    await onlineSDK.connect()

    onlineLogger.info(‘Connected to ledger’)

    await onlineSDK.connectAdmin()

    onlineLogger.info(‘Connected as admin’)

    await onlineSDK.connectTopology(

    localNetStaticConfig.LOCALNET_SCAN_PROXY_API_URL

    )

    onlineLogger.info(

    `Connected to topology: ${localNetStaticConfig.LOCALNET_SCAN_PROXY_API_URL}`

    )

    onlineSDK.tokenStandard?.setTransferFactoryRegistryUrl(

    localNetStaticConfig.LOCALNET_REGISTRY_API_URL

    )

    onlineLogger.info(

    `defined registry url: ${localNetStaticConfig.LOCALNET_REGISTRY_API_URL}`

    )

    const senderParty = {partyId: ‘hello::1220202f91180f02d7dda6e5e10200b16b904542691e3a5c35b88b5e935b72f85fb2’}

    const receiverParty = {partyId: ‘world::1220cfad1a13b5c0d9376ad60821fd13aaefb636b8f291f54dea3c857c3ed8fb0027’}

    await onlineSDK.setPartyId(senderParty.partyId)

    const instrumentAdminPartyId =

    (await onlineSDK.tokenStandard?.getInstrumentAdmin()) || ''
    

    const userToken = await localNetAuthDefault().getUserToken()

    console.log(‘User Token:’, userToken)

    const adminToken = await localNetAuthDefault().getAdminToken()

    console.log(‘Admin Token:’, adminToken)

    const [transferCommand, disclosedContracts] = await onlineSDK.tokenStandard.createTransfer(

    senderParty.partyId,

    receiverParty.partyId,

    ‘1999’,

    {

    instrumentId: ‘Amulet’,

    instrumentAdmin: instrumentAdminPartyId,

    },

    ,

    ‘memo-curl-test’

    )

    const transaction = await onlineSDK.userLedger?.prepareSubmission(

    transferCommand, //the prepared ping command

    v4(), //a unique deduplication id for this transaction

    disclosedContracts //contracts that needs to be disclosed in our to execute the command

    )

    onlineLogger.info(`Prepared transfer: ${transaction.preparedTransaction}`)

    onlineLogger.info(`Prepared transfer with hash: ${transaction.preparedTransactionHash}`)

    how to decode transaction.preparedTransaction so i can view detail of this transaction?

  2. Phillip_Olesen

    you should follow this part of the integration guide:

    docs.digitalasset.com

    Signing Transactions from third party dApps — Digital Asset’s platform...