Cardano: Generate Signature

Request body

Property
Type
Description

kind*

String

For Cardano, always Transaction

transaction*

Hex String

The unsigned hex encoded transaction as shown below

externalId

(Optional) String

A unique ID from your system. It can be leveraged to be used as an idempotency key (read more here)

Sample request body

{
  "kind": "Transaction",
  "transaction": "0x84a3008182582082544414292ededfa716ae42af007ecff823c58796cb9ba60330699fb4d55d7901018282581d60112f2721059581f2a8f9986638359b83c567a61d5486ed0e16c818621a000cf4ae82581d60112f2721059581f2a8f9986638359b83c567a61d5486ed0e16c818621b0000000253db20cd021a00028785a0f5f6"
}

200 response example

{
  "id": "sig-65s39-hsdh3-xxxxxxxxxxxxxxxx",
  "walletId": "wa-7nej2-e3o6d-xxxxxxxxxxxxxxxx",
  "network": "CardanoPreprod",
  "requester": {
    "tokenId": "to-7mkkj-c831n-xxxxxxxxxxxxxxxx",
    "userId": "us-3v1ag-v6b36-xxxxxxxxxxxxxxxx",
    "appId": "ap-341e6-12nj6-xxxxxxxxxxxxxxxx"
  },
  "requestBody": {
    "kind": "Transaction",
    "transaction": "0x84a3008182582082544414292ededfa716ae42af007ecff823c58796cb9ba60330699fb4d55d7901018282581d60112f2721059581f2a8f9986638359b83c567a61d5486ed0e16c818621a000cf4ae82581d60112f2721059581f2a8f9986638359b83c567a61d5486ed0e16c818621b0000000253db20cd021a00028785a0f5f6"
  },
  "status": "Signed",
  "signature": {
    "r": "0x92e520787d6ca35a3e412fa81890a5fd9299e4d8f9ad23dbff284d2e970dce18",
    "s": "0xe7721b4cc8b5a5190605f6e29833c8af1b9e3f5388927e4bd453f630a841bf08",
    "encoded": "0x92e520787d6ca35a3e412fa81890a5fd9299e4d8f9ad23dbff284d2e970dce18e7721b4cc8b5a5190605f6e29833c8af1b9e3f5388927e4bd453f630a841bf08"
  },
  "signedData": "0x84a3008182582082544414292ededfa716ae42af007ecff823c58796cb9ba60330699fb4d55d7901018282581d60112f2721059581f2a8f9986638359b83c567a61d5486ed0e16c818621a000cf4ae82581d60112f2721059581f2a8f9986638359b83c567a61d5486ed0e16c818621b0000000253db20cd021a00028785a10081825820b6332924a382b07808174ae732e8f7ffc32f9955197f25e8b92e93ac6924658a584092e520787d6ca35a3e412fa81890a5fd9299e4d8f9ad23dbff284d2e970dce18e7721b4cc8b5a5190605f6e29833c8af1b9e3f5388927e4bd453f630a841bf08f5f6",
  "dateRequested": "2024-05-09T16:21:36.949Z",
  "dateSigned": "2024-05-09T16:21:37.809Z"
}

Typescript Example with MeshJS SDK

First install the MeshJS SDK. You can find the full documentation here: https://docs.meshjs.dev/

You also need a service that tracks the account's UTXO, for example Blockfrost. The Dfns TypeScript SDK has an example demonstrating how to write a custom Blockfrost initiator plugin for MeshJS.

Here a code sample to generate a signature via the Dfns TypeScript SDK:

import { BlockfrostProvider, Transaction } from '@meshsdk/core'

const walletId = 'wa-6lbfv-9esgj-xxxxxxxxxxxxxxxx'
const wallet = await dfnsClient.wallets.getWallet({ walletId })

const provider = new BlockfrostProvider(process.env.BLOCKFROST_PROJECT_ID!)
const initiator = new CustomInitiator(wallet.address, provider)

const transaction = await new Transaction({ initiator })
  .sendLovelace('addr_test1vq5eele9enryyqkg4wrjyp7x4gpshvkr6rylkwtyau56g3qgrcks9', '1000000')
  .build()

const res = await dfnsClient.wallets.generateSignature({
  walletId,
  body: {
    kind: 'Transaction',
    transaction: `0x${transaction}`,
  },
})

Last updated