Variable DemosTransactionsConst

DemosTransactions: {
    broadcast: ((validationData: RPCResponseWithValidityData, demos: Demos) => Promise<any>);
    broadcastAndWait: ((validationData: RPCResponseWithValidityData, demos: Demos, opts?: {
        failFastOnBroadcastError?: boolean;
        pollIntervalMs?: number;
        timeoutMs?: number;
    }) => Promise<{
        broadcast: RPCResponse;
        status: {
            blockNumber?: number;
            state: "included" | "failed";
        };
    }>);
    confirm: ((transaction: Transaction, demos: Demos) => Promise<RPCResponseWithValidityData>);
    empty: (() => Transaction);
    prepare: ((data?: any) => Promise<Transaction>);
    sign: ((raw_tx: Transaction, keypair: IKeyPair, options: {
        algorithm: SigningAlgorithm;
    }) => Promise<Transaction>);
    signWithAlgorithm: ((data: string, keypair: IKeyPair, options: {
        algorithm: SigningAlgorithm;
    }) => Promise<{
        data: string;
        type: SigningAlgorithm;
    }>);
    _demNumberToOsBigint(amountDem: number): bigint;
    createL2PSHashUpdate(l2psUid: string, consolidatedHash: string, transactionCount: number, demos: Demos): Promise<Transaction>;
    pay(to: string, amount: number | bigint, demos: Demos): Promise<Transaction>;
    proposeNetworkUpgrade(params: {
        effectiveAtBlock: number;
        proposalId: string;
        proposedParameters: Partial<NetworkParameters>;
        rationale: string;
    }, demos: Demos): Promise<Transaction>;
    stake(amount: string, connectionUrl: string, demos: Demos): Promise<Transaction>;
    store(bytes: Uint8Array<ArrayBufferLike>, demos: Demos): Promise<Transaction>;
    transfer(to: string, amount: number | bigint, demos: Demos): Promise<Transaction>;
    unstake(demos: Demos): Promise<Transaction>;
    validatorExit(demos: Demos): Promise<Transaction>;
    voteOnUpgrade(proposalId: string, approve: boolean, demos: Demos): Promise<Transaction>;
} = ...

Type declaration

  • broadcast: ((validationData: RPCResponseWithValidityData, demos: Demos) => Promise<any>)

    Broadcasts a transaction for execution.

      • (validationData, demos): Promise<any>
      • Parameters

        Returns Promise<any>

        The response from the node

  • broadcastAndWait: ((validationData: RPCResponseWithValidityData, demos: Demos, opts?: {
        failFastOnBroadcastError?: boolean;
        pollIntervalMs?: number;
        timeoutMs?: number;
    }) => Promise<{
        broadcast: RPCResponse;
        status: {
            blockNumber?: number;
            state: "included" | "failed";
        };
    }>)

    Broadcast a confirmed transaction and wait for inclusion.

    Polls the node's getTransactionStatus RPC until the tx is observed included or failed, or until opts.timeoutMs elapses (default 30s).

    Use this when you want a single call with a deterministic outcome. Use plain broadcast() when you want to handle async confirmation yourself.

    On timeout, throws BroadcastTimeoutError carrying the tx hash, the last observed state, and the elapsed time so the caller can resume polling.

    When opts.failFastOnBroadcastError is true, also throws BroadcastFailedError synchronously when the broadcast itself can't reach the node (e.g., ECONNREFUSED, ENOTFOUND). HTTP 5xx responses are NOT considered fail-fast cases - the server did answer, so the tx may still have landed and polling should run. Defaults to false for one release to preserve current callers' behavior.

      • (validationData, demos, opts?): Promise<{
            broadcast: RPCResponse;
            status: {
                blockNumber?: number;
                state: "included" | "failed";
            };
        }>
      • Parameters

        • validationData: RPCResponseWithValidityData

          The validity data of the transaction (from confirm)

        • demos: Demos

          The demos instance

        • Optionalopts: {
              failFastOnBroadcastError?: boolean;
              pollIntervalMs?: number;
              timeoutMs?: number;
          }
          • OptionalfailFastOnBroadcastError?: boolean

            If true, throw BroadcastFailedError immediately when the broadcast can't contact the node. Defaults to false.

          • OptionalpollIntervalMs?: number

            Delay between status polls. Defaults to 500.

          • OptionaltimeoutMs?: number

            Total time to wait for inclusion. Defaults to 30_000.

        Returns Promise<{
            broadcast: RPCResponse;
            status: {
                blockNumber?: number;
                state: "included" | "failed";
            };
        }>

        The original broadcast response and the terminal status.

  • confirm: ((transaction: Transaction, demos: Demos) => Promise<RPCResponseWithValidityData>)

    Confirms a transaction.

  • empty: (() => Transaction)
  • prepare: ((data?: any) => Promise<Transaction>)
  • sign: ((raw_tx: Transaction, keypair: IKeyPair, options: {
        algorithm: SigningAlgorithm;
    }) => Promise<Transaction>)

    Signs a transaction after hashing its content.

    Use demos.sign(tx) instead

  • signWithAlgorithm: ((data: string, keypair: IKeyPair, options: {
        algorithm: SigningAlgorithm;
    }) => Promise<{
        data: string;
        type: SigningAlgorithm;
    }>)

    Signs a message with a given algorithm.

      • (data, keypair, options): Promise<{
            data: string;
            type: SigningAlgorithm;
        }>
      • Parameters

        • data: string

          The message to sign.

        • keypair: IKeyPair

          The keypair to use for signing.

        • options: {
              algorithm: SigningAlgorithm;
          }

        Returns Promise<{
            data: string;
            type: SigningAlgorithm;
        }>

        A Promise that resolves to the signed message.

  • _demNumberToOsBigint:function
    • Convert a legacy DEM number input to an OS bigint for internal carrying. Only whole-DEM number inputs are accepted on this legacy path — fractional DEM is rejected with a clear error directing callers to the bigint OS path (denomination.demToOs).

      Rationale: silently flooring (the previous behaviour) discarded up to ~10^9 OS per call without warning. The migration period tolerates legacy number callers, but only at exact DEM granularity — anything sub-DEM must come in as bigint so the caller has explicitly opted into OS arithmetic.

      Parameters

      • amountDem: number

      Returns bigint

  • createL2PSHashUpdate:function
    • Create a signed L2PS hash update transaction for DTR relay to validators.

      L2PS hash updates are self-directed transactions that carry consolidated hash information representing multiple L2PS transactions. These transactions are automatically relayed to validators via DTR (Distributed Transaction Routing) to enable consensus on L2PS network activity without exposing transaction content.

      Parameters

      • l2psUid: string

        The unique identifier of the L2PS network

      • consolidatedHash: string

        SHA-256 hash representing all L2PS transactions

      • transactionCount: number

        Number of transactions included in this hash update

      • demos: Demos

        The demos instance (for getting the address nonce)

      Returns Promise<Transaction>

      The signed L2PS hash update transaction

      const hashUpdateTx = await DemosTransactions.createL2PSHashUpdate(
      "l2ps_network_123",
      "0x1234567890abcdef...",
      5,
      demos
      )
  • pay:function
    • Create a signed DEMOS transaction to send native tokens to a given address.

      P4 dual-input:

      • bigint: OS amount (preferred — 1 DEM = 10^9 OS).
      • number: DEM amount (legacy, deprecated). Auto-converted to OS.

      Internal carrier in tx.content.amount is bigint OS; the serializerGate (run from demos.sign) emits the right wire shape per the connected node's fork status.

      Parameters

      • to: string

        The reciever

      • amount: number | bigint

        DEM number (legacy) or OS bigint.

      • demos: Demos

        The demos instance (for getting the address nonce)

      Returns Promise<Transaction>

      The signed transaction.

  • proposeNetworkUpgrade:function
    • Create a signed networkUpgrade proposal transaction.

      Only active validators may propose. The node rejects proposals whose proposedParameters violate safety bounds (≤50% change, absolute floor/ceiling) or overlap keys with other pending/activating proposals.

      Parameters

      • params: {
            effectiveAtBlock: number;
            proposalId: string;
            proposedParameters: Partial<NetworkParameters>;
            rationale: string;
        }
        • effectiveAtBlock: number

          Activation block. Must be ≥ tallyBlock + grace period.

        • proposalId: string

          UUID. Also used as lexicographic activation-order tiebreaker.

        • proposedParameters: Partial<NetworkParameters>

          Subset of NetworkParameters to change.

        • rationale: string

          Human-readable reason, ≤1024 bytes.

      • demos: Demos

      Returns Promise<Transaction>

  • stake:function
    • Create a signed validatorStake transaction. Used both for initial validator registration and to top up an existing stake.

      Parameters

      • amount: string

        Stake amount in base-unit DEMOS, encoded as a bigint string.

      • connectionUrl: string

        Validator's public endpoint (required on first stake; subsequent top-ups may overwrite it).

      • demos: Demos

        The demos instance (for nonce + signing).

      Returns Promise<Transaction>

  • store:function
    • Create a signed DEMOS transaction to store binary data on the blockchain. Data is stored in the sender's account.

      Parameters

      • bytes: Uint8Array<ArrayBufferLike>

        The binary data to store (will be base64-encoded)

      • demos: Demos

        The demos instance (for getting the address nonce)

      Returns Promise<Transaction>

      The signed storage transaction.

  • transfer:function
    • Create a signed DEMOS transaction to send native tokens to a given address.

      Alias of pay. Same dual-input semantics — bigint OS preferred, number DEM accepted as the deprecated path.

      Parameters

      • to: string

        The reciever

      • amount: number | bigint

        DEM number (legacy) or OS bigint.

      • demos: Demos

        The demos instance (for getting the address nonce)

      Returns Promise<Transaction>

      The signed transaction.

  • unstake:function
  • validatorExit:function
  • voteOnUpgrade:function
    • Create a signed networkUpgradeVote transaction.

      The voter must be in the validator snapshot taken at the proposal's confirmation block, and may cast exactly one vote per proposal (final, non-revocable).

      Parameters

      • proposalId: string
      • approve: boolean
      • demos: Demos

      Returns Promise<Transaction>