> For the complete documentation index, see [llms.txt](https://docs.0xpass.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.0xpass.io/wallet-operations/doa-signer/sign-transaction/sign-transaction-sdk.md).

# 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](/authentication/developer-owned-auth/registration/register-using-sdk.md) 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:

```javascript
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

<table><thead><tr><th>Parameter</th><th>Description</th><th>Example Values</th></tr></thead><tbody><tr><td><code>transaction</code></td><td>The transaction object to be signed, can be a Legacy, EIP2930, or EIP1559 transaction type</td><td><pre class="language-json"><code class="lang-json">{
  "nonce": "0",
  "maxPriorityFeePerGas": "0x9184E72A", 
  "maxFeePerGas": "0x9184E72A",
  "to": "0xb89FF4E9AD6B33F69153fa710F9849f51712eEc4",
  "gas": "0x7530", 
  "value": "0x2386F26FC10000", 
  "chainId": "0x7A69",
  "type": "0x02"
}
</code></pre></td></tr></tbody></table>

#### 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.

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.0xpass.io/wallet-operations/doa-signer/sign-transaction/sign-transaction-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
