Documentation
    Preparing search index...

    The DAppClient has to be used in decentralized applications. It handles all the logic related to connecting to beacon-compatible wallets and sending requests.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _beaconId: ExposedPromise<string>

    The beaconId is a public key that is used to identify one specific application (dapp or wallet). This is used inside a message to specify the sender, for example.

    The local keypair that is used for the communication encryption

    _transport: ExposedPromise<Transport<any, any, any>>
    accountManager: AccountManager
    appUrl?: string

    The URL of the dApp.

    blockchains: Map<string, Blockchain>
    blockExplorer: BlockExplorer

    The block explorer used by the SDK

    description?: string

    The description of the app

    handleResponse: (
        _event: BeaconRequestMessage | BeaconMessageWrapper<BeaconBaseMessage>,
        connectionInfo: ConnectionContext,
    ) => void
    iconUrl?: string

    The URL of the dApp Icon. This can be used to display the icon of the dApp on in the wallet

    matrixNodes: NodeDistributions
    name: string

    The name of the client

    network: Network
    p2pTransport: undefined | DappP2PTransport
    postMessageTransport: undefined | DappPostMessageTransport
    rateLimit: number

    How many requests can be sent after another

    rateLimitWindowInSeconds: number

    The time window in seconds in which the "rateLimit" is checked

    requestCounter: number[]

    Stores the times when requests have been made to determine if the rate limit has been reached

    storage: Storage
    walletConnectTransport: undefined | DappWalletConnectTransport
    wcProjectId?: string
    wcRelayUrl?: string

    Accessors

    • get beaconId(): Promise<string>

      Returns Promise<string>

    • get connectionStatus(): TransportStatus

      Returns the connection status of the Client

      Returns TransportStatus

    • get keyPair(): Promise<KeyPair>

      Returns Promise<KeyPair>

    • get ready(): Promise<void>

      Returns whether or not the transaport is ready

      Returns Promise<void>

    • get transport(): Promise<Transport<any, any, any>>

      Returns Promise<Transport<any, any, any>>

    Methods

    • Register a blockchain to the client

      Parameters

      Returns void

    • Parameters

      Returns Promise<void>

    • Add a new peer to the known peers

      Parameters

      Returns Promise<void>

    • Add a new request (current timestamp) to the pending requests, remove old ones and check if we are above the limit

      Returns Promise<boolean>

    • Check if we have permissions to send the specific message type to the active account. If no active account is set, only permission requests are allowed.

      Parameters

      Returns Promise<boolean>

    • Returns Promise<void>

    • Clear the active account

      Returns Promise<void>

    • Destroy the instance.

      WARNING: Call destroy whenever you no longer need dAppClient as it frees internal subscriptions to the transport and therefore the instance may no longer work properly. If you wish to disconnect your dApp, use disconnect instead.

      Returns Promise<void>

    • Returns Promise<void>

    • Parameters

      • OptionalpublicKey: string

      Returns Promise<undefined | PeerInfo>

    • Return the account by ID

      Parameters

      • accountIdentifier: string

        The ID of an account

      Returns Promise<undefined | AccountInfo>

    • Return all locally known accounts

      Returns Promise<AccountInfo[]>

    • Returns the active account

      Returns Promise<undefined | AccountInfo>

    • Returns Promise<AppMetadata>

      Use getOwnAppMetadata instead

    • Returns Promise<ColorMode>

    • Return all known peers

      Returns Promise<PeerInfo[]>

    • Parameters

      • elements: ("alert" | "toast")[]

      Returns Promise<void>

    • This method initializes the client. It will check if the connection should be established to a browser extension or if the P2P transport should be used.

      Parameters

      • Optionaltransport: Transport<any, any, any>

        A transport that can be provided by the user

      • OptionalsubstratePairing: boolean

      Returns Promise<TransportType>

    • Returns Promise<void>

    • This method initializes the SDK by setting some values in the storage and generating a keypair.

      Returns Promise<void>

    • Will remove the account from the local storage and set a new active account if necessary.

      Parameters

      • accountIdentifier: string

        ID of the account

      Returns Promise<void>

    • Remove all accounts and set active account to undefined

      Returns Promise<void>

    • Remove all peers and all accounts that have been connected through those peers

      Parameters

      • OptionalsendDisconnectToPeers: boolean

      Returns Promise<void>

    • Remove a blockchain from the client by its identifier

      Parameters

      • chainIdentifier: string

        The identifier of the blockchain to remove

      Returns void

    • Removes a peer and all the accounts that have been connected through that peer

      Parameters

      Returns Promise<void>

    • Sends a "BroadcastRequest" to the wallet. This method can be used to inject an already signed transaction to the network.

      Parameters

      Returns Promise<BroadcastResponse>

    • This method sends an OperationRequest to the wallet. This method should be used for all kinds of operations, eg. transaction or delegation. Not all properties have to be provided. Data like "counter" and fees will be fetched and calculated by the wallet (but they can still be provided if required).

      Parameters

      Returns Promise<OperationResponse>

    • Send a permission request to the DApp. This should be done as the first step. The wallet will respond with an publicKey and permissions that were given. The account returned will be set as the "activeAccount" and will be used for the following requests.

      Parameters

      Returns Promise<PermissionResponseOutput>

    • Send a proof of event request to the wallet. The wallet will either accept or decline the challenge. If it is accepted, the challenge will be stored, meaning that even if the user refresh the page, the DAppClient will keep checking if the challenge has been fulfilled. Once the challenge is stored, a challenge stored message will be sent to the wallet. It's highly recommended to run a proof of event challenge to check the identity of an abstracted account

      Parameters

      Returns Promise<ProofOfEventChallengeResponse>

    • This method will send a "SignPayloadRequest" to the wallet. This method is meant to be used to sign arbitrary data (eg. a string). It will return the signature in the format of "edsig..."

      Parameters

      Returns Promise<SignPayloadResponse>

    • Send a simulated proof of event request to the wallet. The wallet will either accept or decline the challenge. It's the same than requestProofOfEventChallenge but rather than executing operations on the blockchain to prove the identity, The wallet will return a list of operations that you'll be able to run on your side to verify the identity of the abstracted account It's highly recommended to run a proof of event challenge to check the identity of an abstracted account

      Parameters

      Returns Promise<SimulatedProofOfEventChallengeResponse>

    • Parameters

      Returns Promise<void>

    • Parameters

      • title: string
      • message: string
      • payload: string
      • protocolIdentifier: string

      Returns Promise<string>

    • Sets the active account

      Parameters

      • Optionalaccount: AccountInfo

        The account that will be set as the active account

      Returns Promise<void>

    • Parameters

      Returns Promise<void>

    • Parameters

      Returns Promise<void>

    • A "setter" for when the transport needs to be changed.

      Parameters

      Returns Promise<void>

    • Returns Promise<void>

    • Allows the user to subscribe to specific events that are fired in the SDK

      Type Parameters

      Parameters

      • internalEvent: K

        The event to subscribe to

      • eventCallback: BeaconEventHandlerFunction<BeaconEventType[K]>

        The callback that will be called when the event occurs

      Returns Promise<void>