Connection status of the RPC URL
Broadcasts a transaction for execution.
The validity data of the transaction
The demos instance
The response from the node
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.
The validity data of the transaction (from confirm)
The demos instance
Optionalopts: { OptionalfailIf true, throw BroadcastFailedError
immediately when the broadcast can't contact the node. Defaults to false.
OptionalpollDelay between status polls. Defaults to 500.
OptionaltimeoutTotal time to wait for inclusion. Defaults to 30_000.
The original broadcast response and the terminal status.
Confirms a transaction.
The transaction to confirm
The validity data of the transaction containing the gas information.
Signs a transaction after hashing its content.
The transaction to be signed.
The keypair to use for signing.
A Promise that resolves to the signed transaction.
Signs a message with a given algorithm.
The message to sign.
The keypair to use for signing.
The algorithm related to the keypair.
A Promise that resolves to the signed message.
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.
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.
The unique identifier of the L2PS network
SHA-256 hash representing all L2PS transactions
Number of transactions included in this hash update
The demos instance (for getting the address nonce)
The signed L2PS hash update transaction
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.
The reciever
DEM number (legacy) or OS bigint.
The demos instance (for getting the address nonce)
The signed transaction.
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.
Activation block. Must be ≥ tallyBlock + grace period.
UUID. Also used as lexicographic activation-order tiebreaker.
Subset of NetworkParameters to change.
Human-readable reason, ≤1024 bytes.
Create a signed validatorStake transaction. Used both for initial
validator registration and to top up an existing stake.
Stake amount in base-unit DEMOS, encoded as a bigint string.
Validator's public endpoint (required on first stake; subsequent top-ups may overwrite it).
The demos instance (for nonce + signing).
Create a signed DEMOS transaction to store binary data on the blockchain. Data is stored in the sender's account.
The binary data to store (will be base64-encoded)
The demos instance (for getting the address nonce)
The signed storage transaction.
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.
The reciever
DEM number (legacy) or OS bigint.
The demos instance (for getting the address nonce)
The signed transaction.
Create a signed validatorUnstake transaction. Arms the unstake lock
period; after UNSTAKE_LOCK_BLOCKS have elapsed the validator may call
validatorExit.
Create a signed validatorExit transaction. Only accepted by the
network once unstake_available_at <= currentBlock.
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).
Get a cost quote for an IPFS operation without submitting a transaction.
Use this to estimate costs and populate custom_charges before signing.
Pipe the response through IPFSOperations.quoteToCustomCharges
(or createCustomCharges) to obtain a max_cost_os decimal-string
suitable for the transaction's custom_charges.ipfs.max_cost_os
field. The helpers handle both pre-fork (cost_dem) and
post-fork (cost_os) node response shapes.
Size of file in bytes
IPFS operation type ('IPFS_ADD', 'IPFS_PIN', or 'IPFS_UNPIN')
OptionaldurationBlocks: numberOptional duration in blocks (for PIN operations)
Cost quote with detailed breakdown
Reads a storage program by address.
The address of the storage program to read
The response from the node
Creates and signs a storage program transaction given a payload.
The payload to sign
The signed transaction
Broadcasts a transaction for execution.
The validity data of the transaction
The demos instance
The response from the node
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.
The validity data of the transaction (from confirm)
The demos instance
Optionalopts: { OptionalfailIf true, throw BroadcastFailedError
immediately when the broadcast can't contact the node. Defaults to false.
OptionalpollDelay between status polls. Defaults to 500.
OptionaltimeoutTotal time to wait for inclusion. Defaults to 30_000.
The original broadcast response and the terminal status.
Confirms a transaction.
The transaction to confirm
The validity data of the transaction containing the gas information.
Signs a transaction after hashing its content.
The transaction to be signed.
The keypair to use for signing.
A Promise that resolves to the signed transaction.
Signs a message with a given algorithm.
The message to sign.
The keypair to use for signing.
The algorithm related to the keypair.
A Promise that resolves to the signed message.
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.
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.
The unique identifier of the L2PS network
SHA-256 hash representing all L2PS transactions
Number of transactions included in this hash update
The demos instance (for getting the address nonce)
The signed L2PS hash update transaction
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.
The reciever
DEM number (legacy) or OS bigint.
The demos instance (for getting the address nonce)
The signed transaction.
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.
Activation block. Must be ≥ tallyBlock + grace period.
UUID. Also used as lexicographic activation-order tiebreaker.
Subset of NetworkParameters to change.
Human-readable reason, ≤1024 bytes.
Create a signed validatorStake transaction. Used both for initial
validator registration and to top up an existing stake.
Stake amount in base-unit DEMOS, encoded as a bigint string.
Validator's public endpoint (required on first stake; subsequent top-ups may overwrite it).
The demos instance (for nonce + signing).
Create a signed DEMOS transaction to store binary data on the blockchain. Data is stored in the sender's account.
The binary data to store (will be base64-encoded)
The demos instance (for getting the address nonce)
The signed storage transaction.
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.
The reciever
DEM number (legacy) or OS bigint.
The demos instance (for getting the address nonce)
The signed transaction.
Create a signed validatorUnstake transaction. Arms the unstake lock
period; after UNSTAKE_LOCK_BLOCKS have elapsed the validator may call
validatorExit.
Create a signed validatorExit transaction. Only accepted by the
network once unstake_available_at <= currentBlock.
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).
Broadcasts a transaction for execution.
The validity data of the transaction
The demos instance
The response from the node
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.
The validity data of the transaction (from confirm)
The demos instance
Optionalopts: { OptionalfailIf true, throw BroadcastFailedError
immediately when the broadcast can't contact the node. Defaults to false.
OptionalpollDelay between status polls. Defaults to 500.
OptionaltimeoutTotal time to wait for inclusion. Defaults to 30_000.
The original broadcast response and the terminal status.
Confirms a transaction.
The transaction to confirm
The validity data of the transaction containing the gas information.
Same as demos.sign.
Signs a transaction after hashing its content.
The transaction to be signed.
Signs a message with a given algorithm.
The message to sign.
The keypair to use for signing.
The algorithm related to the keypair.
A Promise that resolves to the signed message.
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.
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.
The unique identifier of the L2PS network
SHA-256 hash representing all L2PS transactions
Number of transactions included in this hash update
The demos instance (for getting the address nonce)
The signed L2PS hash update transaction
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.
The reciever
DEM number (legacy) or OS bigint.
The demos instance (for getting the address nonce)
The signed transaction.
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.
Activation block. Must be ≥ tallyBlock + grace period.
UUID. Also used as lexicographic activation-order tiebreaker.
Subset of NetworkParameters to change.
Human-readable reason, ≤1024 bytes.
Create a signed validatorStake transaction. Used both for initial
validator registration and to top up an existing stake.
Stake amount in base-unit DEMOS, encoded as a bigint string.
Validator's public endpoint (required on first stake; subsequent top-ups may overwrite it).
The demos instance (for nonce + signing).
Create a signed DEMOS transaction to store binary data on the blockchain. Data is stored in the sender's account.
The binary data to store (will be base64-encoded)
The demos instance (for getting the address nonce)
The signed storage transaction.
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.
The reciever
DEM number (legacy) or OS bigint.
The demos instance (for getting the address nonce)
The signed transaction.
Create a signed validatorUnstake transaction. Arms the unstake lock
period; after UNSTAKE_LOCK_BLOCKS have elapsed the validator may call
validatorExit.
Create a signed validatorExit transaction. Only accepted by the
network once unstake_available_at <= currentBlock.
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).
The keypair of the connected wallet
Connection status of the wallet
StaticinstanceBroadcasts a transaction for execution.
The validity data of the transaction
The response from the node
Broadcast a confirmed transaction and wait until it lands on chain
(or fails) by polling the node's getTransactionStatus RPC.
Throws BroadcastTimeoutError if no terminal state is observed
before the timeout elapses. Use plain broadcast() if you want to
handle async confirmation yourself.
The validity data of the transaction
Optionalopts: { OptionalpollDelay between polls. Defaults to 500.
OptionaltimeoutTotal time to wait. Defaults to 30_000.
Confirms a transaction.
The transaction to confirm
The validity data of the transaction containing the gas information.
Connects to a Demos wallet using the provided master seed.
The master seed of the wallet
Optionaloptions: { The options for the wallet connection
Optionalalgorithm?: SigningAlgorithmThe algorithm to use for the wallet
Optionaldual_Whether to include the ed25519 signature along with the PQC signature, when signing with unlinked PQC keypairs (i.e. PQC keypairs not linked to your ed25519 address on the network).
The public key of the wallet
Lists currently-open proposals (pending tally or activating after approval). Rejected/active historical proposals are not included.
Get the mempool.
Fetches the connected node's per-fork activation status.
Mirrors the node's getNetworkInfo nodeCall
(libs/network/handlers/forkHandlers.ts). The response carries
activation height, current chain head, and the activated boolean
for every known fork.
Caches the result on this Demos instance for the instance's
lifetime (no TTL). To re-fetch after a node upgrade, construct a
fresh Demos instance.
On RPC failure (404, malformed response, network error), this
method returns null and the SDK assumes pre-fork wire format.
A console.warn is emitted exactly once per Demos instance
recommending the operator upgrade the target node.
The fork-status payload, or null if the RPC failed.
Returns the currently-active NetworkParameters — the result of folding
every active NetworkUpgrade over the genesis defaults.
Returns the live vote tally for a specific proposal — total snapshot
weight, approve/reject breakdowns, per-validator votes, threshold, and
a passed flag.
Get the transaction history of an address.
The address
The type of transaction. Defaults to "all".
Optionallimit?: numberOptionalstart?: numberA list of transaction ordered from the most recent to the oldest.
Get all transactions.
Optionalstart: number | "latest"Optionallimit: numberGet transaction by hash.
The transaction hash
Returns the ordered history of proposals whose status has reached
active. Ordered by effectiveAtBlock ASC, then proposalId ASC.
Get a validator's current record (stake, status, unstake timestamps). Returns null if the address is not (and never was) a validator.
List validators at a given block (defaults to the current head). Only
returns validators whose valid_at block is <= the queried block and
whose status is still active.
OptionalblockNumber: numberCreate a signed DEMOS transaction to send native tokens to a given address.
P4 dual-input:
bigint (preferred, post-v3): amount in OS (smallest unit;
1 DEM = 10^9 OS). Use denomination.demToOs(...) to convert
a human-readable DEM input.number (deprecated, v2 callers): amount in DEM. Auto-converted
to OS internally via OS_PER_DEM. Will be removed in v4.Sub-DEM precision is rejected with SubDemPrecisionError when
the connected node is pre-fork — its legacy DEM-number wire
cannot carry < 1 DEM and silent truncation is unacceptable. The
caller can either round to a whole DEM or upgrade the target
node.
The receiver address (0x-prefixed hex).
DEM number (legacy) or OS bigint (preferred).
The signed transaction.
Signs a transaction.
The transaction to sign
The signed transaction
Signs a message.
The message to sign
Optionaloptions: { The options for the message signing
Optionalalgorithm?: SigningAlgorithmThe algorithm to use for the message signing. Defaults to the connected wallet's algorithm.
The signature of the message
Create a signed DEMOS transaction to store binary data on the blockchain. Data is stored in the sender's account.
The binary data to store
The signed storage transaction.
Create a TLSNotary instance for HTTPS attestation.
This method discovers the notary endpoints from the connected node and returns an initialized TLSNotary instance.
Optionalconfig: TLSNotaryConfigOptional explicit configuration (overrides discovery)
Initialized TLSNotary instance
// Option 1: Auto-discovery from connected node (preferred)
const demos = new Demos({ rpc: 'https://node.demos.sh' });
await demos.connect();
const tlsn = await demos.tlsnotary();
// Option 2: Explicit configuration
const tlsn = await demos.tlsnotary({
notaryUrl: 'wss://other-node.demos.sh:7047',
websocketProxyUrl: 'wss://other-node.demos.sh:55688',
});
// Attest an HTTPS request
const result = await tlsn.attest({
url: 'https://api.github.com/users/octocat',
});
console.log('Verified server:', result.verification.serverName);
Create a signed DEMOS transaction to send native tokens to a given address.
Alias of pay. Same dual-input semantics — bigint is the
preferred OS shape; number is the deprecated legacy DEM shape.
The receiver address (0x-prefixed hex).
DEM number (legacy) or OS bigint (preferred).
The signed transaction.
Verifies a message.
The message to verify
The signature of the message
The public key of the message
Optionaloptions: { The options for the message verification
Optionalalgorithm?: SigningAlgorithmThe algorithm to use for the message verification. Defaults to the connected wallet's algorithm or ed25519 if no wallet is connected.
Whether the message is verified
Static_coerceCoerce a wire-format amount/fee value (legacy DEM number,
post-fork OS decimal string, or in-flight bigint) to an OS
bigint. Used by _calculateAndApplyGasFee and other internal
arithmetic paths to stay in OS-bigint regardless of which wire
shape the caller produced. Mirrors the node's toOsBigint helper
in forks/serializerGate.ts.
This class provides methods to interact with the DEMOS blockchain.