Passport
  • 👩‍💻Welcome
  • How Passport Works
    • Overview
    • Background
      • Threshold Cryptography
      • Secure Multi-Party Computation
      • Distributed Architecture
      • Secure Enclaves
    • In Depth
      • Under the Hood
      • User Flows and Account Controls
      • The Halides Model
      • End-to-End Encryption
      • Security
      • Node Operation
  • guides and examples
    • Getting Started
    • Quickstarts and Examples
      • Passkey Account
      • Clerk Auth
      • Lambda Quickstart
  • Authentication
    • Overview
    • Configuring your scope
    • Passkeys
      • Registration
        • Register using SDK
        • Register using API
          • Initiate Registration
          • Complete Registration
      • Authentication
        • Authenticating with SDK
        • Authenticating with API
          • Initiate Authentication
          • Complete Authentication
    • Developer Owned Auth
      • Registration
        • Register using SDK
        • Register using API
          • Delegate Registration
  • Wallet Operations
    • Overview
    • Passkeys Signer
      • Sign Message
        • Sign Message SDK
        • Sign Message API
      • Sign Transaction
        • Sign Transaction SDK
        • Sign Transaction API
    • DOA Signer
      • Sign Message
        • Sign Message SDK
        • Sign Message API
      • Sign Transaction
        • Sign Transaction SDK
        • Sign Transaction API
    • Viem Support
  • Programmability
    • Overview
    • Passport Lambda
    • Lambda Functions
      • Create Lambda
        • Create Lambda SDK
        • Create Lambda API
      • Execute Lambda
        • Execute Lambda SDK
        • Execute Lambda API
      • List Lambda
        • List Lambda SDK
        • List Lambda API
  • Appendix
    • Moving to Mainnet
    • State Of The Network
    • Generating DOA Keys
    • API Request Setup
      • Unauthenticated Requests
      • Authenticated Requests
Powered by GitBook
On this page
  • Direct Authentication
  • signTransaction Parameters
  1. Wallet Operations
  2. DOA Signer
  3. Sign Transaction

Sign Transaction SDK

To sign a transaction a user / an account would need to have to have been register and authenticated by going through Register using SDK flow.

Direct Authentication

Since you will be directly authenticating with DOA here, you don't need to go through authentication step. Here is a code sample:

import { Passport } from "@0xpass/passport";
import { stringToHex } from "viem";
import { Passport } from "@0xpass/passport";
import { KeySigner } from "@0xpass/key-signer";

const signer = new KeySigner(process.env.PRIVATE_KEY!, true);

const passport = new Passport({
    scopeId: "insert_your_scope_id",
    signer: signer
});

const userInput {
   username: "insert_registered_username_here"
   userDisplayName: "insert_registered_user_display_name_here"
}

await passport.setupEncryption();
//This step is different for direct authentication
passport.setUserData(userInput)

// Transaction Can be of type legacy (0x0),
// EIP2930 (0x01) or EIP1559 (0x02)
const transaction = {
  nonce: "0",
  maxPriorityFeePerGas: "0x9184E72A", 
  maxFeePerGas: "0x9184E72A",
  to: "0xb89FF4E9AD6B33F69153fa710F9849f51712eEc4",
  gas: "0x7530", 
  value: "0x2386F26FC10000", 
  chainId: "0x7A69",
  type: "0x02"
}

// Generate a threshold signature
const signature = await passport.signTransaction(transaction);
console.log(signature); // This is an rlp encoded transaction signature

signTransaction Parameters

Parameter
Description
Example Values

transaction

The transaction object to be signed, can be a Legacy, EIP2930, or EIP1559 transaction type

signTransaction Response

A successful response will return the following, an RLP encoded transaction signature from the authenticated account that can be executed as a raw transaction.

{
    "jsonrpc": "2.0",
    "result": "signed_transaction_here",
    "id": 1
}

PreviousSign TransactionNextSign Transaction API

Last updated 11 months ago

{
  "nonce": "0",
  "maxPriorityFeePerGas": "0x9184E72A", 
  "maxFeePerGas": "0x9184E72A",
  "to": "0xb89FF4E9AD6B33F69153fa710F9849f51712eEc4",
  "gas": "0x7530", 
  "value": "0x2386F26FC10000", 
  "chainId": "0x7A69",
  "type": "0x02"
}