High-level API for creating escrow transactions Enables trustless sending of DEM to unclaimed social identities

Constructors

Methods

  • Creates a transaction to claim escrowed funds

    Prerequisites:

    • Claimant must have already proven ownership of the social identity (via Web2 identity linking transaction)

    Parameters

    • demos: Demos

      Demos SDK instance (must have keypair set)

    • platform: "github" | "twitter" | "telegram"

      Social platform

    • username: string

      Username to claim for

    Returns Promise<Transaction>

    Signed transaction ready to submit

    // Bob links Twitter first
    await demos.Web2.linkTwitter("@bob")

    // Then claims escrow
    const tx = await EscrowTransaction.claimEscrow(
    demos,
    "twitter",
    "@bob"
    )
    await demos.submitTransaction(tx)
  • Computes deterministic escrow address from platform:username MUST MATCH the node implementation!

    Parameters

    • platform: string

      Social platform ("twitter", "github", "telegram")

    • username: string

      Username on that platform (e.g., "@bob")

    Returns string

    Hex-encoded escrow address

  • Creates a transaction to refund an expired escrow

    Parameters

    • demos: Demos

      Demos SDK instance (must have keypair set)

    • platform: "github" | "twitter" | "telegram"

      Social platform

    • username: string

      Username

    Returns Promise<Transaction>

    Signed transaction ready to submit

    const tx = await EscrowTransaction.refundExpiredEscrow(
    demos,
    "twitter",
    "@unclaimed_user"
    )
    await demos.submitTransaction(tx)
  • Creates a transaction to send DEM to a social identity escrow

    Parameters

    • demos: Demos

      Demos SDK instance (must have keypair set)

    • platform: "github" | "twitter" | "telegram"

      Social platform ("twitter", "github", "telegram")

    • username: string

      Username on that platform

    • amount: number

      Amount of DEM to send (number)

    • Optionaloptions: {
          expiryDays?: number;
          message?: string;
      }

      Optional parameters

      • OptionalexpiryDays?: number
      • Optionalmessage?: string

    Returns Promise<Transaction>

    Signed transaction ready to submit

    const tx = await EscrowTransaction.sendToIdentity(
    demos,
    "twitter",
    "@bob",
    100,
    { expiryDays: 30, message: "Welcome to Demos!" }
    )
    await demos.submitTransaction(tx)