Skip to content

Latest commit

 

History

History
64 lines (51 loc) · 2.15 KB

SSP_Wallet_API.md

File metadata and controls

64 lines (51 loc) · 2.15 KB

SSP Wallet JavaScript API

The SSP Wallet injects a window.ssp object into the website, enabling communication between web pages and the SSP Wallet Chrome extension.

API Method: window.ssp.request(method, parameters)

This function takes two parameters:

  • method: A string specifying the method to be called.
  • parameters: An object containing additional parameters specific to the method.

Implemented Methods

1. Pay Request

  • Method: 'pay'

  • Description: Requests SSP to perform payment actions (sending assets).

  • Parameters:

    • message (string): A message to include in the transaction (e.g., 'Hello SSP').
    • amount (string): The amount to send in whole units (e.g., '4.124').
    • address (string): The recipient's address (e.g., 't1eabPBaLCqNgttQMnAoohPaQM6u2vFwTNJ').
    • chain (string): The chain ID identifier of SSP (e.g., 'flux').
  • Response:

    • status (string): Indicates success or error.
    • result? (string): Explanation of error (if any).
    • data? (string): Explanation of success (if any).
    • txid? (string): Transaction ID in case of a successful payment.

Example:

window.ssp.request('pay', {
  message: 'Hello SSP',
  amount: '4.124',
  address: 't1eabPBaLCqNgttQMnAoohPaQM6u2vFwTNJ',
  chain: 'flux'
}).then(response => {
  console.log(response);
});

2. Sign Message with SSP Wallet ID (FluxID)

  • Method: 'sspwid_sign_message'

  • Description: Requests SSP to sign a message using SSP Wallet Identity.

  • Parameters:

    • message (string): The message to be signed by SSP Wallet Identity (e.g., 'Hello SSP, please sign this message').
  • Response:

    • status (string): Indicates success or error.
    • result? (string): Explanation of error (if any).
    • data? (string): Explanation of success (if any).
    • signature? (string): Signature of the signed message.
    • address? (string): Address that signed the message.
    • message? (string): The message that was signed.

Example:

window.ssp.request('sspwid_sign_message', {
  message: 'Hello SSP, please sign this message'
}).then(response => {
  console.log(response);
});