Create Lambda SDK

To register a lambda, a user / an account would need to have to have been created ( Registration) and have an associated session by going through the Authenticating with SDK flow. Once you have the required details you can call the sign method by instantiating a Passport instance from the SDK as shown below.

import { Passport } from "@0xpass/passport";
import { WebauthnSigner } from "@0xpass/webauthn-signer";

const signer = new WebauthnSigner({
      rpId: window.location.hostname,
      rpName: "rpName",
});

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


const userInput {
   username: "insert_username_here"
   userDisplayName: "insert_user_display_name_here"
}

await passport.setupEncryption(); 
await passport.authenticate(userInput);

const config = {
    "authorization": {
        "type": "none"
    },
    "verifications": {
        "count": 1
    },
    "triggers": [
       { "type": "hook"},
    ],
    "envs": [],
    "max_executions": 0,
    "conditions": [
        {
            "type": "code",
            "code": "if (Math.random() < 0.5) { return true; } else { return false; }",
            "output_type": "integer",
            "substitution": true
        }
    ],
    "actions": {
        "type": "personal_sign",
        "check": "",
        "data": "0x000000",
        "substitution": true
    },
    "postHook": []
}

// Generate a threshold signature
const lambda_uuid = await passport.createLambda({data:config});
console.log(lambda_uuid);

createLambda Parameters

ParameterDescriptionExample Values

data

Refer to Full Spec for more info.

{
    "authorization": {
        "type": "none"
    },
    "verifications": {
        "count": 1
    },
    "envs": [],
    "max_executions": 0,
    "conditions": [
        {
            "type": "code",
            "code": "if (Math.random() < 0.5) { return true; } else { return false; }",
            "output_type": "integer",
            "substitution": true
        }
    ],
    "actions": {
        "type": "personal_sign",
        "check": "",
        "data": "0x000000",
        "substitution": true
    },
    "postHook": []
}

createLambda Response

A successful response will return a unique UUID required to execute the lambda function

{
    "jsonrpc": "2.0",
    "result": "a23ef114-c5fb-41c6-b863-0781a3d10ee5",
    "id": 3
}

Last updated