Sign Transaction

Signing a transaction is a critical step that authorizes the movement of funds or interaction with smart contracts on the Cardano blockchain. This guide covers the primary methods for signing: on the frontend using a browser-based wallet, and on the backend using a server-side script.

Frontend (Client-Side) Signing

Frontend signing is the most common method for user-centric applications. It leverages the user's installed browser wallet (like Eternl or Lace) to request a signature, ensuring that the user's private keys never leave their secure environment.

Using Weld

We recommend using our Weld library to simplify interaction with browser wallets. Weld provides a unified API to connect to various wallets and request transaction signatures.

Using the Browser Developer Console

For quick testing, you can directly use the CIP-30 wallet API exposed in the browser's developer console.

  1. Go to any website with a connected Cardano wallet (e.g., https://ada-anvil.io).

  2. Open the Developer Console.

  3. Execute the following JavaScript to enable the wallet and request a signature:

    // Example using Eternl wallet
    const w = await window.cardano.eternl.enable();
    
    // Replace with your actual transaction CBOR
    const signedTx = await w.signTx("Your unsigned transaction CBOR", true);
    
    console.log(signedTx);
  4. Some wallets will prompt you to authorize your dApp to interact with the wallet.

  5. Your wallet will then prompt you to sign the transaction.

  6. The signed transaction CBOR, including the witness set, will be printed to the console.

Last updated

Was this helpful?