🖥️API

All Javascript methods to interact with the wallet

declare global {
 interface Window {
  xidar: {
   v1: {
    hasWallet: () => Promise<boolean>
    isConnected: () => Promise<boolean>
    connect: () => Promise<string>
    disconnect: () => Promise<{code: number}>
    sign: (challenge: string) => Promise<string>
    submitTransaction: (payload: {}) => Promise<any>
    encrypt: (message: string, fromAddress: string, toAddress: string) => Promise<string>
    decrypt: (message: string, fromAddress: string) => Promise<string>
    accounts: () => Promise<string[]>
    balances: () => Promise<{}>
    stakes: () => Promise<{}>
    unstakes: () => Promise<{}>
   }
  }
 }
}

hasWallet()

This function allows you to know if the user has the wallet installed and initialized. Returns true or false.

hasWallet: () => Promise<boolean>

isConnected()

This function allows you to know if the user's wallet is synchronized with the current domain name. Returns true or false.

isConnected: () => Promise<boolean>

connect()

This function allows the website to be synchronized with the user's wallet. Ask for permissions if the user has not already accepted. Returns the active address of the user or null.

connect: () => Promise<string>

disconnect()

This function allows to disconnect the website from the user's wallet.

disconnect: () => Promise<{code: number}>

sign()

This function allows you to sign a message with the private key of the active address of the user's wallet. Returns the signed message.

sign: (challenge: string) => Promise<string>

submitTransaction()

This function allows you to send a transaction with the user's active wallet address. Return the transaction ID.

submitTransaction: (payload: {}) => Promise<any>

encrypt()

This function allows you to encrypt a message with the the user's active wallet address. Returns the encrypted message.

encrypt: (message: string, fromAddress: string, toAddress: string) => Promise<string>

decrypt()

This function allows you to decrypt a message with the the user's active wallet address. Returns the decrypted message.

decrypt: (message: string, fromAddress: string) => Promise<string>

accounts()

This function allows you to retrieve the list of all the addresses of the user's wallet. Return an array of addresses.

accounts: () => Promise<string[]>

balances()

This function allows you to retrieve balances of the user's active wallet address. Returns an array of tokens informations.

balances: () => Promise<{}>

stakes()

This function allows you to retrieve staking positions of the user's active wallet address. Returns an array of staking positions.

stakes: () => Promise<{}>

unstakes()

This function allows you to retrieve unstaking positions of the user's active wallet address. Returns an array of unstaking positions.

unstakes: () => Promise<{}>

Last updated