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

  • Normalise a public-API amount input (number legacy DEM or bigint OS) into both forms. Used at every boundary that needs dual-shape support during the pre-/post-fork rollout.

    • number input: must be a non-negative integer DEM amount; converted to OS via OS_PER_DEM. Fractional DEM number is rejected — silently flooring (the previous behaviour) discarded up to ~10^9 OS per call. Callers who need sub-DEM precision must pass a bigint OS amount (e.g. denomination.demToOs("1.5")).
    • bigint input: treated as OS; DEM form is the integer division amountOs / OS_PER_DEM. The pre-fork sub-DEM precision rejection lives in Demos._assertAmountAcceptableOnTargetNode (called by sendToIdentity before this helper runs).

    Parameters

    • amount: number | bigint

    Returns {
        amountDem: number;
        amountOs: bigint;
    }

    • amountDem: number
    • amountOs: bigint

    Exposed only to keep the migration paths discoverable.

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

    P4 dual-input:

    • bigint (preferred, post-v3): OS amount.
    • number (deprecated, v2 callers): DEM amount, auto-converted.

    Internal carrier in tx.content.amount and gcr_edits[].amount is bigint OS; the serializerGate (called from demos.sign) picks the wire shape per fork status. Sub-DEM precision against a pre-fork node throws SubDemPrecisionError.

    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 | bigint

      DEM number (legacy) or OS bigint (preferred).

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

      Optional parameters

      • OptionalexpiryDays?: number
      • Optionalmessage?: string

    Returns Promise<Transaction>

    Signed transaction ready to submit

    import { denomination } from "@kynesyslabs/demosdk"
    const tx = await EscrowTransaction.sendToIdentity(
    demos,
    "twitter",
    "@bob",
    denomination.demToOs(100), // 100 DEM
    { expiryDays: 30, message: "Welcome to Demos!" }
    )
    await demos.confirm(tx)