Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssp wallet api #192

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions SSP_Wallet_API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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:
```javascript
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:
```javascript
window.ssp.request('sspwid_sign_message', {
message: 'Hello SSP, please sign this message'
}).then(response => {
console.log(response);
});
```