Quick Access
Coin Methods
Cardano
Miscellaneous
Methods
Cardano
cardanoComposeTransaction

Cardano: Compose transaction

Composes a transaction from the given account information and outputs.

const result = await TrezorConnect.cardanoComposeTransaction(params);

Params

Including CommonParams

path

String | Array<Number>

Optional

Derivation Path (BIP32).

Examples

// Get account info
const accountInfo = await TrezorConnect.getAccountInfo({
    path: "m/1852'/1815'/0'/0/0",
    coin: 'cardano',
    details: 'txs',
});
const account = accountInfo.payload;
 
// Find an unused change address
const changeAddress = account.addresses.change.find(a => a.transfers === 0);
 
TrezorConnect.cardanoComposeTransaction({
    account: {
        descriptor: account.descriptor,
        utxo: account.utxo,
    },
    changeAddress,
    addressParameters: {
        addressType: CardanoAddressType.BASE,
        path: changeAddress.path,
    },
    outputs: [
        {
            format: CardanoTxOutputSerializationFormat.ARRAY_LEGACY,
            address:
                'addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r',
            amount: '1',
        },
    ],
    feeLevels: [{ feePerUnit: '1' }, { feePerUnit: '5' }, { feePerUnit: '30' }],
    testnet: false,
});

Result

PrecomposedTransactionCardano[] type

PrecomposedTransactionFinalCardano

{
    success: true,
    payload: {
        type: 'final';
        max?: string;
        totalSpent: string; // all the outputs, no fee, no change
        fee: string;
        feePerByte: string;
        bytes: number;
        deposit?: string;
        ttl?: number;
        inputs: CardanoInput[];
        outputs: CardanoOutput[];
        unsignedTx: {
            body: string;
            hash: string;
        };
    }
}

PrecomposedTransactionNonFinalCardano

{
    success: true,
    payload: {
        type: 'nonfinal';
        max?: string;
        totalSpent: string; // all the outputs, no fee, no change
        fee: string;
        feePerByte: string;
        bytes: number;
        deposit?: string;
    }
}

Error

{
    success: false,
    payload: {
        error: string // error message
    }
}