This class provides methods to interact with the DEMOS blockchain.

Constructors

Properties

algorithm: SigningAlgorithm = "ed25519"
connected: boolean = false

Connection status of the RPC URL

crypto: UnifiedCrypto = null
DemosTransactions: {
    broadcast: ((validationData: RPCResponseWithValidityData, demos: Demos) => Promise<any>);
    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;
    }>);
    pay(to: string, amount: number, demos: Demos): Promise<Transaction>;
    transfer(to: string, amount: number, demos: Demos): Promise<Transaction>;
} = DemosTransactions

Type declaration

DemosWebAuth: typeof DemosWebAuth = DemosWebAuth
dual_sign: boolean = false
skeletons: skeletons = skeletons
transactions: {
    broadcast: ((validationData: RPCResponseWithValidityData, demos: Demos) => Promise<any>);
    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;
    }>);
    pay(to: string, amount: number, demos: Demos): Promise<Transaction>;
    transfer(to: string, amount: number, demos: Demos): Promise<Transaction>;
} = DemosTransactions

Type declaration

tx: {
    broadcast: ((validationData: RPCResponseWithValidityData, demos: Demos) => Promise<any>);
    confirm: ((transaction: Transaction, demos: Demos) => Promise<RPCResponseWithValidityData>);
    empty: (() => Transaction);
    prepare: ((data?: any) => Promise<Transaction>);
    sign: ((raw_tx: Transaction) => Promise<Transaction>);
    signWithAlgorithm: ((data: string, keypair: IKeyPair, options: {
        algorithm: SigningAlgorithm;
    }) => Promise<{
        data: string;
        type: SigningAlgorithm;
    }>);
    pay(to: string, amount: number, demos: Demos): Promise<Transaction>;
    transfer(to: string, amount: number, demos: Demos): Promise<Transaction>;
} = ...

Type declaration

web2: {
    createDahr: (() => Promise<Web2Proxy>);
    getTweet: ((tweetUrl: string) => Promise<{
        error?: string;
        success: boolean;
        tweet: Tweet;
    }>);
} = ...
xm: {
    createPayload: ((xm_payload: XMScript, keypair?: IKeyPair) => Promise<Transaction>);
} = ...

Accessors

  • get keypair(): {
        privateKey: NativeBuffer;
        publicKey: NativeBuffer;
    }
  • The keypair of the connected wallet

    Returns {
        privateKey: NativeBuffer;
        publicKey: NativeBuffer;
    }

    • privateKey: NativeBuffer
    • publicKey: NativeBuffer

Methods

  • Parameters

    • method: any
    • message: any
    • data: any = {}
    • extra: any = ""
    • sender: any = null
    • receiver: any = null

    Returns Promise<any>

  • Connects to a RPC URL. Throws an error if the connection fails.

    Parameters

    • rpc_url: string

      The URL of the demos node

    Returns Promise<boolean>

    Whether the connection was successful

  • Connects to a Demos wallet using the provided master seed.

    Parameters

    • masterSeed: string | Uint8Array<ArrayBufferLike>

      The master seed of the wallet

    • Optionaloptions: {
          algorithm?: SigningAlgorithm;
          dual_sign?: boolean;
      }

      The options for the wallet connection

      • Optionalalgorithm?: SigningAlgorithm

        The algorithm to use for the wallet

      • Optionaldual_sign?: boolean

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

    Returns Promise<string>

    The public key of the wallet

  • Returns the public key of the connected wallet.

    Returns string

    The public key of the wallet

  • Get information about an address.

    Parameters

    • address: string

      The address

    Returns Promise<AddressInfo>

  • Get address nonce.

    Parameters

    • address: string

      The address

    Returns Promise<number>

  • Returns the ed25519 address of the connected wallet.

    Returns Promise<string>

  • Generates a new mnemonic.

    Parameters

    • strength: 128 | 256 = 128

      The strength of the mnemonic in bits. (128 bits = 12 words, 256 bits = 24 words). Default is 128 bits.

    Returns string

    The mnemonic

  • Performs a nodeCall on the connected RPC.

    Parameters

    • message: any

      The message to send to the node

    • args: {} = {}

      The arguments to send to the node

      Returns Promise<any>

      The nodeCall response

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

      Parameters

      • to: string

        The reciever

      • amount: number

        The amount in DEM

      Returns Promise<Transaction>

      The signed transaction.

    • Parameters

      • request: RPCRequest
      • isAuthenticated: boolean = false
      • retries: number = 0
      • sleepTime: number = 250
      • allowedErrorCodes: number[] = []

      Returns Promise<RPCResponse>

    • Signs a message.

      Parameters

      • message: string | Buffer

        The message to sign

      • Optionaloptions: {
            algorithm?: SigningAlgorithm;
        }

        The options for the message signing

        • Optionalalgorithm?: SigningAlgorithm

          The algorithm to use for the message signing. Defaults to the connected wallet's algorithm.

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

      The signature of the message

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

      Parameters

      • to: string

        The reciever

      • amount: number

        The amount in DEM

      Returns Promise<Transaction>

      The signed transaction.

    • Verifies a message.

      Parameters

      • message: string | Buffer

        The message to verify

      • signature: string

        The signature of the message

      • publicKey: string

        The public key of the message

      • Optionaloptions: {
            algorithm?: SigningAlgorithm;
        }

        The options for the message verification

        • Optionalalgorithm?: SigningAlgorithm

          The algorithm to use for the message verification. Defaults to the connected wallet's algorithm or ed25519 if no wallet is connected.

      Returns Promise<boolean>

      Whether the message is verified