Defly Wallet

This documentation outlines the steps to integrate Defly Wallet for signing "Sign In With Algorand" (SIWA) messages.

Get started quickly w/ SIWA Connect

Prerequisites

  1. Install the Defly Wallet library:

    npm install @blockshake/defly-connect
  2. Import required modules:

    import { DeflyWalletConnect } from "@blockshake/defly-connect";
    import algosdk from "algosdk";
    import { getMessageBytes, hashMessage, initializeAlgodClient } from "@/utils/siwaUtils";

Overview

Defly wallet uses a transaction-based approach for signing SIWA messages, similar to Lute wallet. Here's how it works:

  1. Create a zero-amount payment transaction

  2. Set the transaction's note field to the encoded SIWA message

  3. Sign the transaction using Defly wallet

  4. Extract the signature from the signed transaction

Implementation

1. Connecting to Defly Wallet

To connect to Defly wallet, use the DeflyWalletConnect class:

2. Signing a SIWA Message

To sign a SIWA message with Defly wallet:

  1. Create a payment transaction with the SIWA message in the note field

  2. Sign the transaction using Defly wallet

  3. Extract the signature from the signed transaction

Here's the code to accomplish this:

Verification

When verifying the SIWA message signature for Defly wallet, the process is similar to Lute wallet due to the transaction-based approach. Here's how it works:

  1. The verification function receives the following parameters:

  2. message: The original SIWA message

  3. signature: The signature in base64 format

  4. provider: The wallet provider (in this case, "Defly")

  5. encodedTransaction: The encoded transaction in Base64 format

  6. The verification process for Defly wallet:

  1. The verifySignedTransaction function is used to validate the transaction:

This verification process ensures that:

  1. The transaction is properly signed

  2. The signature in the transaction matches the provided signature

  3. The transaction is valid according to Algorand's rules

Remember to handle any potential errors during the verification process and ensure that all required parameters are provided.

Last updated