📃
CasperDash Knowledge Base
  • Our Story
  • Welcome to CasperDash Knowledge Base
  • Audit Reports
  • User Guides
    • CasperDash Mobile Wallet
      • How to install the mobile app?
      • How to Create a wallet with recovery phrase?
      • How to export private key from Casper Signer?
      • How to import an account from a private key?
      • How to import an account from a Recovery Phrase?
      • How to import an account from Casper Wallet?
      • How to import an account from BitGet Wallet?
      • Connect with Ledger
      • Staking
    • CasperDash Extension Wallet
      • How to install the CasperDash Extension?
    • CasperDash Web App (Beta)
      • How to install CasperDash Progressive Web App?
      • How to import wallet to CasperDash Web App?
    • Developer Docs
      • Getting Started
      • API Reference
      • Listing new dApps
  • Third Party Integration
    • Ramp.network integration
Powered by GitBook
On this page
  • Methods
  • Events
  1. User Guides
  2. Developer Docs

API Reference

CasperDash injects a global API into websites visited by its users at window.casperDashHelper. This API allows websites to request users' Casper accounts, read data from blockchains the user is connected to, and suggest that the user sign messages and transactions.

Methods

casperDashHelper.requestConnection()

requestConnection: () => Promise<void>;

Requests a connection to the DApp

casperDashHelper.requestSwitchAccount()

requestSwitchAccount: () => Promise<void>;

Requests to switch connected account

casperDashHelper.isConnected()

casperDashHelper.isConnected() : Promise<boolean>;

Returns true if the provider is connected to the current chain, and false otherwise

casperDashHelper.disconnectFromSite()

disconnectFromSite: () => Promise<void>;

Requests a disconnection from the Casper Network DApp

casperDashHelper.signMessage()

signMessage: (message: string, signingPublicKeyHex: string) => Promise<string>;

Suggest that the user sign a message

casperDashHelper.sign()

sign: (deploy: { deploy: JsonTypes }, signingPublicKeyHex: string, targetPublicKey: string) => Promise<Deploy>;

Suggest that the user sign a deploy

casperDashHelper.getActivePublicKey()

getActivePublicKey: () => Promise<string>;

Return the current connected account's public key

Events

connected

window.addEventListener('casperdash:connected', (event: CustomEventInit<{ activeKey: string; isConnected: boolean }>) => {
      console.log({ isConnected: event.detail?.isConnected, activeKey: event.detail?.activeKey });
});

disconnected

window.addEventListener('casperdash:disconnected', () => {});

activeKeyChanged

window.addEventListener('casperdash:activeKeyChanged', (event: CustomEventInit<{ activeKey: string; isConnected: boolean }>) => {
      console.log({ isConnected: event.detail?.isConnected, activeKey: event.detail?.activeKey });
});

The CasperDash provider emits this event whenever the return value of the activeKey changes. This means that activeKeyChanged will be emitted whenever the user's exposed account address changes.

PreviousGetting StartedNextListing new dApps

Last updated 1 year ago

The CasperDash provider emits this event when it first becomes able to submit RPC requests to a chain. We recommend using a connect event handler and the in order to determine when/if the provider is connected.

The CasperDash provider emits this event if it becomes unable to submit RPC requests to any chain. In general, this will only happen due to network connectivity issues, some unforeseen error or DApp invokes method.

casperDashHelper.isConnected method
casperDashHelper.disconnectFromSite()