Sign Transaction SDK
Direct Authentication
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 signaturesignTransaction Parameters
Parameter
Description
Example Values
signTransaction Response
Last updated