# Relysia SDK

The official Relysia JavaScript SDK to use the Bitcoin SV blockchain.

![](https://1860373586-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ml6s5BMmWoDc9jHH2VT%2F-Ml7Z6BMamjyPyqAJilF%2F-Ml7ZAur8bt1bMJ-ePw5%2FGroup%201543.png?alt=media\&token=5ea626b7-c335-4082-ad14-93d9511bea85)


# Setup

Your first Blockchain Application is just minutes away

{% embed url="<https://share.synthesia.io/2cede1dd-1211-452b-8955-6718e95dc054>" %}

## Getting Started

Make use of our npm repository to add it to your node project of choice or Clone the Relysia SDK repository from <https://github.com/kohze/relysiaSDK> to add it locally to your project. Alternatively we also offer a CDN to integrate the Relysia SDK into traditional html pages. &#x20;

```bash
npm i @relysia/sdk
```

Alternatively, install the newest development version via GitHub

```bash
git clone https://github.com/kohze/relysiaSDK
```

## Initialize the Library

Each Relysia SDK interaction starts with getting the Authentication Token. To get a Authentication token, load the Relysia SDK either via NPM or CDN and start with the following lines.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const RelysiaSDK = require('relysia');

const relysia = new RelysiaSDK();
await relysia.authentication.v1.auth({email: "abc@gmail.com", password: "pass"});
```

{% endtab %}

{% tab title="JavaScript ES6" %}

```javascript
import RelysiaSDK from 'relysia';

const relysia = new RelysiaSDK();
await relysia.auth({email: "abc@gmail.com", password: "pass"});
```

{% endtab %}

{% tab title="HTML" %}

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="https://cdn.jsdelivr.net/npm/relysia@1.0.6/dist/relysia-sdk.js"></script>
</head>
<body>
  <script>
    const relysia = new RelysiaSDK();
  </script>
</body>
</html>
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
&#x20;Make sure the authentication codes are **not shared publicly**.&#x20;
{% endhint %}

In case you already have the authentication token or serviceId from your firebase frontend application use:

```javascript
const relysia = new RelysiaSDK({authToken: "your authToken", serviceId:"<your serviceId>"})
```

#### Account details

User details are typically an essential part of your user management and platform experience. To access user account details, such as email, name or profile picture, call the `getUserDetails()` function as indicated below.&#x20;

```javascript
const response = await relysia.user.v1.getUserDetails();
```


# API

The Engine Inside the Relysia SDK

You can access all feature functionalities of the JavaScript Relysia SDK via Swagger to implement it into a variety of languages and third party tools. The Relysia SDK package helps developers to easily integrate our endpoints, simplify error handling and reduces building time.&#x20;

<https://api.relysia.com/docs/static/index.html>

{% embed url="<https://api.relysia.com/docs/static/index.html>" %}

![](https://1860373586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ml6s5BMmWoDc9jHH2VT%2Fuploads%2F5OCp0xoHvuOqe3p8YLpc%2FScreenshot_80.jpg?alt=media\&token=2d102460-a523-46aa-afde-e3877a303fe0)

You can interactively try out all API endpoints on the Open API 3.0 Swagger page. We created this real timesaver to help developers to debug or explore which inputs could be combined to create one of countless blockchain applications.


# Infrastructure

Keep full control and make it your own.

Relysia is a wallet infrastructure, that means we can not only be accessed by logging into Vaionex platforms, but moreover enable 3rd party developers to create their very own dedicated versions of it. Relysia is a **Blockchain As A Service** platform, to create your very own sophisticated blockchain platforms while keeping your very own user database and control over settings and funds.&#x20;

{% hint style="info" %}
If you intend to build your own blockchain platform, go to the wallet interface of [Relysia.com](https://relysia.com) to sign up to your very own Infrastructure Plan.&#x20;
{% endhint %}

During the Infrastructure Plan setup, you can choose between a variety of functions, enable and disable user functionalities and endpoints, tailored to your very own Application.&#x20;

### Miner Fee Settings

To create the optimal user experience for your user, you need to decide what options the user will prefer for your application. At the moment, Relysia Infrastructure supports 3 fee types.&#x20;

* Classical: Let users pay for transaction fees with BSV
* Miner: Use A minerAPI cover your costs (e.g. TAAL mAPI Key)
* Dynamic: Cover the costs of your users to a certain limit (FeeManager).&#x20;

### Infrastructure Costs

In our initial beta, we will keep plans free of costs to certain limits. Within the next month, we will announce a low cost volume based plan that will keep average applications with 50k users well below 30$ per month. &#x20;


# Wallets

How to create your first Blockchain Wallet.

#### Wallets

Once you created a new account, you first need to create a wallet. Since Relysia allows you to pick between multiple wallet types, we rather leave the wallet choice to the user on their setup. Lets explore how to set up your first wallet.&#x20;

#### Types of Wallets

As the name already indicates, the `createWallet()` adds a new wallet straight to your user account. There is no limit to the number of wallets you can have in a single account. Lets first explore the most simple **standard wallet** case, before exploring the extended version. Using the `walletTitle: 'default'` tag, will create a wallet with deterministic path id `0000-00000000-00000` .

```javascript
var parameters = {
    walletTitle: 'default'
}

const response = await relysia.wallet.v1.createWallet(parameters);
```

{% hint style="info" %}
in most endpoints you see a **walletId** input, if you create a default wallet, you can leave the field open and the API will automatically access the default wallet for the operation.
{% endhint %}

The standard wallet will do the trick for most wallet applications in terms of encryption and usability. For extended functionality, such as password protection or escrow wallets, use the following synthax.

```javascript
var parameters = {
    walletTitle: 'required',
    serviceId: 'optional',
    type: 'optional',
    walletLogo: 'optional',
    walletPassword: 'optional',
}

const response = await relysia.wallet.v1.createWallet(parameters);
```

## Create a wallet.

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/createWallet`

Create a HD wallet of choice in your user account. You can select between standard, secure, escrow and shared wallets (see docs.relysia.com).

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| walletTitle<mark style="color:red;">\*</mark> | string  |             |
| mnemonicPhrase                                | string  |             |
| paymail                                       | string  |             |
| paymailActivate                               | boolean |             |
| type                                          | string  |             |
| walletLogo                                    | string  |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "wallet created successfully",
    "walletID": "58c4e3e0-c4d3-413e-a8b9-3b30508e8c83"
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
There are 4 wallet types: ***Standard Wallets*** have a base encryption, ***Secure Wallets*** are additionally password protected, unencrypted ***Escrow Wallets*** and ***Multi Party Wallets*** (that make use of multi-sig schemes). Each type has very specific use cases that depend on your applications needs
{% endhint %}

#### List All Wallets&#x20;

The wallets endpoint returns you a list of all the wallets associated with your Relysia account. The response details include: **walletID**, **walletTitle** and a link to your **walletLogo**.

```javascript
var parameters = {
    oauth: 'optional',
    serviceId: 'optional',
}

const response = await relysia.wallet.v1.wallets(parameters);
```

## List of available user wallets.

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/wallets`

The endpoint provides the user with a list of all active wallets on their account. Depending on your service requirements, you might have one or multiple wallets.

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully",
    "wallets": [
      {
        "walletID": "58c4e3e0-c4d3-413e-a8b9-3b30508e8c83",
        "walletTitle": "Relysia production wallet",
        "walletLogo": null
      },
      {
        "walletID": "ec4ae905-c5ef-41bd-adfb-4db361093245",
        "walletTitle": "Relysia secondary wallet",
        "walletLogo": null
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

#### Delete Specific Wallet

To delete any specific wallet from your account, you can use this endpoint. You need to pass your **walletID** that you received from [#list-all-wallets](#list-all-wallets "mention")endpoint.

## Delete specific wallet

<mark style="color:red;">`DELETE`</mark> `https://api.relysia.com/v1/wallet`

To delete a wallet, this api will delete your wallet and related data of that walletId

#### Headers

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| walletID<mark style="color:red;">\*</mark> | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  statusCode: 200,
  data: {
    status: 'success',
    msg: 'wallet deleted successfully !',
    walletId: '58c4e3e0-c4d3-413e-a8b9-3b30508e8c83'
  }
}
```

{% endtab %}
{% endtabs %}

#### Delete All Wallets

## Delete all wallets of account

<mark style="color:red;">`DELETE`</mark> `https://api.relysia.com/v1/wallets`

To delete all wallet, this api will delete all wallets at once

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  statusCode: 200,
  data: { status: 'success', msg: 'wallets deleted successfully !' }
}
```

{% endtab %}
{% endtabs %}


# Mnemonic

We are non-custodial - make sure to keep your wallet backup

An essential aspect of regulatory compliance of our Blockchain as a service infrastructure is to keep wallets non-custodial. Users are interacting with their very own keys and we only store those fragments that enable them to unlock them for transaction processing purposes.

#### Mnemonic Phrase

As a non-custodial wallet, users are responsible for backing up their keys. The mnemonic phrase function returns the 12 word backup seed-phrase of the wallet selected.&#x20;

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
}
const response = await relysia.wallet.v1.mnemonic(parameters);
```

## Get your mnemonic phrase.

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/mnemonic`

The mnemonic phrase secures your wallet keys. Each mnemonic acts as seed of a HDPrivatekey that itself contains hundrets of PrivateKeys.

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully",
    "mnemonic": "Trades Extend Steps Then Degrees Entice Melodious Organs keen pattern disorder vintage"
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Make sure you backup your mnemonic phrase and never share it with anyone.
{% endhint %}

### Retrieve Funds

The mnemonic phrase is the seed for a HDPrivateKey with millions of potential addresses. You can extract your funds from the **M/44/0/0/{1,2,3...}** path. First transactions will always go to the first addresses and their corresponding private keys, while over time, to prevent address re-usage for privacy reasons we use a larger and larger address space. Nonetheless, knowing the order of writings, you can recover all funds without Relysia.&#x20;

{% hint style="success" %}
If you want to learn more about manually extracting funds, we got you covered.&#x20;

Visit the [Satolearn.com](https://satolearn.com) platform to learn more about bitcoin coding.&#x20;
{% endhint %}


# Addresses

Get your address to receive your first BitcoinSV, token or NFT.

#### Get your Wallet Address

An essential feature of every wallet is the wallet address, which can be either a ***classical bitcoin address*** or the more modern ***paymail alias*** address. To ensure privacy for the user, each API call will return a different classical address. &#x20;

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
}

const response = await relysia.wallet.v1.address(parameters);
```

## Get your wallet address and paymail.

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/address`

Receive a single address and the paymail alias to receive Coins or Token.

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation Completed Successfully",
    "address": "1NcijXHErt2LnTUPRqzBQXFYZS8X9NKRq5",
    "paymail": "1325@relysia.com"
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
Addresses are public, you can share them with anyone.&#x20;
{% endhint %}

#### All Wallet Addresses

In case your application requires to fetch all available addresses, use the code below. This might be useful if you want to manage your own address usage flow.&#x20;

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
}

const response = await relysia.wallet.v1.allAddresses(parameters);
```

## Get all wallet addresses.

<mark style="color:blue;">`GET`</mark> `https://api.relysia.comv1/allAddresses`

Get a list of all wallet addresses that are currently available in your wallet.

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation Completed Successfully",
    "addressess": [
      "1NZaXzJHBLTqeBXn45AvkoPCkbwatizDCd",
      "13ypszR4JSgmznrfiTDodiRVSRkaL94usx",
      "1E4We5K6zFh7msq6r2ZrNuyK56X2gqTzGy",
      "1LS54Yo1xLGkyCgcGZo6RLj5QgkqEchvUg",
      "16Jg2sYouH8jGFRyUyEnoNZ1gyj9mKECMu",
      "12fKJzMbsMW6HxAsCMsrL4jrxC2p8umDGn",
      "12T7men1z1FU9sruoFgFx2D7JCJRgZtvrA",
      "12519wQZvqjuqxggUco872zKs66L9x438C",
      "1JVxt4RMjLqdHh9RCAizFqFWc4yhjEWeeo",
      "1892sYWjiHzkn6sD12q9Xn7s4ZHjZCmfEh",
      "15PYXZhGAnoKqTxVqDVkp5zMnwYd3g2oii",
      "147Pha46z8xhMHjq6Wcy9ZWgUV9okUgqeu",
      "14WcvWcfUqUqLhm4BUkQ1JXPdaCDNSpnnp",
      "1H2XN9TPkbcpWA1ZwyJCjGPu15m5QLKfh6",
      "1Ey63N7rE2K1F7uhjgo9cRV8t79sVsh8uu",
      "1ZjCnXk7H2QyAR8oWetDo11FXek4ML6oG",
      "1AF5yUb1kCmGhCwLUsaTweGJKmkTB6fF2x",
      "1Do2akh13LjagoZWuyiJsgt32aTGW5uSva",
      "1NcijXHErt2LnTUPRqzBQXFYZS8X9NKwq5",
      "13JGSa4y2mLB7krgQkLyb43ca1Dwru9mWK"
    ]
  }
}
```

{% endtab %}
{% endtabs %}

#### Paymail vs Classical Addresses&#x20;

Paymail aliases enable instant p2p transactions with close to no waiting time. They are operating at reduced resource cost and lead to a generally better user experience due to their event based triggering. Classical transactions on the other hand will only be received at your wallet when the UTXO was found on the blockchain, and our infrastructure carefully compared all addresses against all transactions on the network.&#x20;

But as always, there are more details to it. Classical transactions give users security that the funds are received exactly at that address, and no server incident based rerouting happened. Moreover, it is easier to proof that you send someone funds he the user gave you exactly that address to receive your funds (in case that ever stands up to dispute).

{% hint style="info" %}
We recommend paymail transactions for smaller transactions (or infrastructure internal transactions) and classical transactions higher transaction amounts to potentially untrusted 3rd parties.&#x20;
{% endhint %}


# Metrics

Check or Re-Sync your UTXO state

An essential part of managing a wallet is UTXO state management. The Relysia infrastructure is a native peer to peer system that continuously keeps track of its own UTXOs. Since we support classic addresses and transactions from external parties, we automatically run transaction listeners to always keep wallets in sync with the blockchain.

```javascript
var parameters = { serviceId: 'optional',
    walletID: 'optional',
}

const response = await relysia.wallet.v1.metrics(parameters);
```

## Get the latest wallet UTXO state.

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/metrics`

UTXOs are the base unit of transactions in the Bitcoin network. The metrics endpoint first updates the last UTXO state, and then shows a detailed output of each UTXO in the wallet.

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "operation completed successfully !",
    "data": {
      "balance": 248542,
      "userUtxos": [
        {
          "height": 757221,
          "tx_pos": 0,
          "tx_hash": "39c1cbaee9cb45600fb07240f394c1f69erd456d81df8c5f5f132661426b32d8",
          "value": 100,
          "script": "76a914ec83f1fb2c52dbd7d2b4c70cf95150560d611b9088ac",
          "path": "m/44'/0'/0'/0/0",
          "address": "1NZaXzJHBLTqeBXn45AvkoPCkbwatizeCW"
        }
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
You can force refresh the UTXO state by calling the metrics function
{% endhint %}

{% hint style="warning" %}
When refreshing the UTXO state less than 15 seconds after last transaction was submitted, it is likely that miners (such as TAAL) haven't indexed the current state. A force refresh would thus sync an out of date UTXO and it is therefore not advisable to regularly force refresh the UTXO state.&#x20;
{% endhint %}


# Balance

How many currencies and NFTs do you own?

{% embed url="<https://share.synthesia.io/a8384342-c19c-4436-b14a-8f9248fba029>" %}

After the address, the second most essential feature of wallets are the display of the current wallet **balance**. Next to the standard inputs, you can define a fiat **currency** display of the balance.&#x20;

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    currency: 'optional',
}

const response = await relysia.wallet.v1.balance(parameters);
```

{% hint style="success" %}
The balance endpoint returns the BSV balance and fiat equivalent and STAS token balances of your wallet.&#x20;
{% endhint %}

## Get your wallet balance.

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/balance`

Returns both coin and token balances.

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| walletID      | string |             |
| type          | string |             |
| currency      | string |             |
| nextPageToken | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation Completed Successfully",
    "totalBalance": {
      "currency": "USD",
      "balance": 0.11926660683
    },
    "coins": [
      {
        "protocol": "BSV",
        "balance": 248542
      }
    ],
    "meta": {
      "nextPageToken": null
    }
  }
}
```

{% endtab %}
{% endtabs %}

####


# History

Check what transactions you made in the past, or export it.

The transaction history displays all deposits and withdrawals from the user wallet. When building applications, try to keep the data as shallow as possible to reduce the data fetched. We added filter parameters to reduce the number of entries per page or pick a specific coin types that are referenced by their respective tokenID.&#x20;

```javascript
var parameters = {
    nextPageToken: 'optional',
    serviceId: 'optional',
    walletID: 'optional',
    type: 'optional',
}

const response = await relysia.wallet.v1.history(parameters);
```

{% hint style="info" %}
We currently integrate token transactions into the /history endpoint.
{% endhint %}

## Get your transaction history.

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/history`

The transaction history endpoint returns all past transactions, both BSV and Tokens.

#### Query Parameters

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| nextPageToken | string |             |

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |
| type     | string |             |
| version  | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully",
    "histories": [
      {
        "version": "1.0.0",
        "to": "bulk transaction",
        "txId": "29f6d4ee36ffbb70226f342a89097e040df4cdbc91e15bb698d0bf27fa228956",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-09-15 05:25:49",
        "balance_change": -2,
        "docId": "29f6d4ee36ffbb70226f342a89097e040df4cdbc91e15bb698d0bf27fa228956",
        "notes": null,
        "type": "debit",
        "protocol": "STAS"
      },
      {
        "version": "1.0.0",
        "to": "1K1xqUS6nt2niaAcM7K5WuNWyqBaD8JQkN",
        "txId": "baf52af692ed06a2b9fa0e3c256b4e0d3259f6b651dce8c065d5b9d67e91e70c",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-09-15 05:14:38",
        "balance_change": -1,
        "docId": "baf52af692ed06a2b9fa0e3c256b4e0d3259f6b651dce8c065d5b9d67e91e70c",
        "notes": null,
        "type": "debit",
        "protocol": "STAS"
      },
      {
        "version": "1.0.0",
        "to": "payto:3577@relysia.com?amount=120",
        "txId": "d181897e8952e20b38256ba4893a2f2d7ae42ee627d74adcce49c9c6a4b0dd81",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-09-15 04:59:36",
        "balance_change": 0.0000012,
        "docId": "d181897e8952e20b38256ba4893a2f2d7ae42ee627d74adcce49c9c6a4b0dd81",
        "notes": "Send to 3577@relysia.com",
        "type": null,
        "protocol": "BSV"
      },
      {
        "version": "1.0.0",
        "to": "bulk transaction",
        "txId": "0397640d62d8dece842ec6209345de94d4ca9997f83aa31c7467c6060c3f39aa",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-09-15 04:45:39",
        "balance_change": -200,
        "docId": "0397640d62d8dece842ec6209345de94d4ca9997f83aa31c7467c6060c3f39aa",
        "notes": null,
        "type": "debit",
        "protocol": "BSV"
      },
      {
        "version": "1.0.0",
        "to": "1K1xqUS6nt2niaAcM7K5WuNWyqBaD8JQkN",
        "txId": "82f2852d3b0c327f3d67b3a8f96f90b69b312a36bad102b62b69622c8e26fc19",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-09-15 04:39:51",
        "balance_change": -100,
        "docId": "82f2852d3b0c327f3d67b3a8f96f90b69b312a36bad102b62b69622c8e26fc19",
        "notes": null,
        "type": "debit",
        "protocol": "BSV"
      },
      {
        "version": "1.0.0",
        "to": "1Abju7foXMqhBK8CbHVuRXLqTtmxFgTdRh",
        "txId": "b2d88f2b119e276f6c22e62b58ef33f8c572cc1a87c7fd8c0b52ad5c3c713690",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-09-07 16:49:17",
        "balance_change": -100,
        "docId": "b2d88f2b119e276f6c22e62b58ef33f8c572cc1a87c7fd8c0b52ad5c3c713690",
        "notes": null,
        "type": "debit",
        "protocol": "BSV"
      },
      {
        "version": "1.0.0",
        "to": "1L1ik3bjuJFgye8g4f2PYDtB3AAjjif2fK",
        "txId": "4408297291c835d6618105f313e3ebd130f86e3b363469fadc6d19768bde0570",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-08-11 04:38:06",
        "balance_change": -50000,
        "docId": "4408297291c835d6618105f313e3ebd130f86e3b363469fadc6d19768bde0570",
        "notes": null,
        "type": "debit",
        "protocol": "BSV"
      },
      {
        "version": "1.0.0",
        "to": "1FJ4Lt7B5ekcucefgT44VaiZffffZAAUUp",
        "txId": "c0c5761191674cf78d26b227e8faf51e52e1b0888adebec1863847d370f6311e",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-08-01 16:05:26",
        "balance_change": -50000,
        "docId": "c0c5761191674cf78d26b227e8faf51e52e1b0888adebec1863847d370f6311e",
        "notes": null,
        "type": "debit",
        "protocol": "BSV"
      },
      {
        "version": "1.0.0",
        "to": "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
        "txId": "ddef95711560df8373a06d455d716cf2ce21322511b2ec9112a9bb387577859e",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-07-28 16:16:18",
        "balance_change": -500,
        "docId": "ddef95711560df8373a06d455d716cf2ce21322511b2ec9112a9bb387577859e",
        "notes": null,
        "type": "debit",
        "protocol": "BSV"
      },
      {
        "version": "1.0.0",
        "to": "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
        "txId": "1dad4406281f7f5c899ab833a08a16958f194f102ca53ecbdf0f629824af8cba",
        "from": "1325@dev.relysia.com",
        "timestamp": "2022-07-28 16:11:46",
        "balance_change": -500,
        "docId": "1dad4406281f7f5c899ab833a08a16958f194f102ca53ecbdf0f629824af8cba",
        "notes": null,
        "type": "debit",
        "protocol": "BSV"
      }
    ],
    "nextPageTokenId": "2022-07-28T16:11:46.021Z"
  }
}
```

{% endtab %}
{% endtabs %}


# Lookup

Get Balance from a private key string

The lookup endpoint retrieves the balance associated with a single private key string. It will display the balance for both BSV and/or STAS tokens that are housed in the corresponding address. Users can customize responses using additional header parameters, such as currency type, pagination, protocol type (including variations of BSV and/or STAS), and compact mode.<br>

Body Params

```javascript
{
 privateKey : "string"
}
```

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/lookup`

Returns Balance of all assets of Private Key

#### Headers

| Name          | Type    | Description                                                                                                                                                                                             |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type          | String  | Type refers to the protocol returned such as BSV, STAS-20, STAS-789. Default ALL will be used and return all.                                                                                           |
| currency      | String  | Currency type such as USD, CAD, AUD, or any other supported currency type. Default set to USD.                                                                                                          |
| nextPageToken | Number  | Will provide the next page of balance determine by starting point number provided. By default, will start at 0.                                                                                         |
| compact       | Boolean | Compact will be set default to true. This refers to STAS tokens specifically will return total balances of each token Id. Compact false will return each UTXO that comprises of all the total balances. |
| maxResults    | Number  | Number of result in the array provided. Default set to 19, where the BSV balance make the total of 20 returned.                                                                                         |

#### Request Body

| Name                                         | Type   | Description              |
| -------------------------------------------- | ------ | ------------------------ |
| privateKey<mark style="color:red;">\*</mark> | String | Private key string value |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "operation completed successfully",
    "totalBalance": {
      "currency": "USD",
      "balance": 0.0000030209549035757473
    },
    "coins": [
      {
        "protocol": "BSV",
        "balance": 1e-7
      },
      {
        "protocol": "STAS",
        "tokenId": "8b07511349a2d715abc1777777b4c078241a62e5-TESTTOKEN444",
        "splittable": true,
        "name": "Store Bonus Points",
        "address": "1JpvnEDrLR1rXZrUZNkhWSJd3x9D9ib16i",
        "satsPerToken": 1,
        "symbol": "TESTTOKEN444",
        "redeemAddr": "8b07511349a2d715abc1777777b4c078241a62e5",
        "image": "https://upload.wikimedia.org/wikipedia/en/9/95/Test_image.jpg",
        "amount": 3,
        "supply": 3,
        "decimals": 0,
        "sn": [
          0
        ]
      },
      {
        "protocol": "STAS",
        "tokenId": "8b07511349a2d715abc1777777b4c078241a62e5-TESTNFT444",
        "splittable": true,
        "name": "Store Bonus Points",
        "address": "1JpvnEDrLR1rXZrUZNkhWSJd3x9D9ib16i",
        "satsPerToken": 1,
        "symbol": "TESTNFT444",
        "redeemAddr": "8b07511349a2d715abc1777777b4c078241a62e5",
        "image": "https://upload.wikimedia.org/wikipedia/en/9/95/Test_image.jpg",
        "amount": 3,
        "supply": 3,
        "decimals": 0,
        "sn": [
          0
        ]
      }
    ],
    "meta": {
      "nextPageToken": null
    }
  }
```

{% endtab %}
{% endtabs %}


# Sweep

Transfer all assets from a private key

The sweep endpoint facilitates the seamless transfer of all BSV and STAS tokens associated with a specific private key string to a designated address. A notable feature of this endpoint is its compatibility with QR codes incorporating a private key in Wallet Import Format (WIF), offering users a quick and easy method to interact with web pages or participate in live events. Essentially, this functionality can be leveraged to create a "scan and go" system, enhancing the user experience by simplifying transactions and promoting engagement in various digital environments. Moreover, the application of QR codes can foster secure and instantaneous transactions, thereby bringing a dynamic and interactive dimension to the user's journey.\
\
Body Request

```javascript
{
 privateKey : "string"
}
```

## Transfer all assets from PrivateKey to the user

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/sweep`

The sweep endpoints allows users to transfer all coins (BSV and Tokens) from a PrivateKey.

#### Headers

| Name     | Type   | Description                                                   |
| -------- | ------ | ------------------------------------------------------------- |
| walletId | String | User wallet Id. Will use default wallet if no value provided. |

#### Request Body

| Name                                         | Type   | Description                                    |
| -------------------------------------------- | ------ | ---------------------------------------------- |
| privateKey<mark style="color:red;">\*</mark> | String | Private Key string to transfer all asset from. |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "operation completed successfully",
    "txIds": [
      "02f60500a9163ad7af8fa619633fd3d1798daff4159fd4079cb9aab8ec88fe6e",
      "b85a0ba09d65952e78aadca40d99e619e82beff05446ed4c901bcdd30e441b20",
      "00f7c5552da20ba707bafb8a9cc9f83e7b06b550e3fbf575b7b822e8afa20a7d"
    ],
    "errors": []
  }
}
```

{% endtab %}
{% endtabs %}


# URI

How to convert address formats to sensible inputs

{% embed url="<https://share.synthesia.io/1505836e-99cb-4964-bebd-84fddf956c78>" %}

#### A Uniform Resource Identifier

In Bitcoin, there are over 30 combinations sharing address formats. Some include **memos**, which are short messages to the receiver, others include payment **requests** of specified amounts.&#x20;

{% hint style="info" %}
The URI endpoint resolves a variety of address formats such as **<63@relysia.com>** or **1McLoHnGZnXBinS82dqPnRDV9VQJjJpBZF** and it automatically resolves and returns the underlying information.&#x20;
{% endhint %}

Since p2p paymails resolve differently than normal paymails, and invoices can be sometimes just a web link instead of an address. To make it easier for app developers, we created a URI function to catch them all, no matter the format. The function enables developers to scan QR codes without worrying to ever not having the right resolver at hand.&#x20;

Lets have a closer look at what addresses can look like:

{% code title="Address Format variations" %}

```html
//// address ////
19KXpbJMt1SjUNh3ATMgj8FkzvSX7C83gq

//// bip21 ////
bitcoin:19KXpbJMt1SjUNh3ATMgj8FkzvSX7C83gq?amount=10000

//// paymail ////
payto:90@relysia.com?purpose=cashback&amount=10000

//// paymail-noScheme ////
90@relysia.com

//// bip272 ////
bitcoin:?sv=&r=https%3A%2F%2Fstaging.centi.ch%2Fpayment%2Fapi%2Fpayment_request%2F2662e521-ff52-418a-b7e5-c98aefd7295a

//// DPP ////
pay:?r=https://api.relysia.com/v1/paymentRequest/8f9f4c27-3782-46e2-b76f-1ef956f52c61
```

{% endcode %}

As we can see above, a unified resolver reduces the uncertainty of interpreting QR codes and address inputs. Instead of enforcing a single format, the URI endpoint helps to enhance app user friendliness and compatibility with the greater ecosystem.&#x20;

{% hint style="info" %}
The response body of the URI can be used as input for the [/pay](/payments/lookup) endpoint (for invoices) or simply be used to decode the string of a QR code.&#x20;
{% endhint %}

```javascript
const resp = await relysia.utility.v1.uri({uri: '90@relysia.com'});
```

The response body schema looks as follows, independent of the input.&#x20;

```json
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully",
    "data": {
      "uri": "90@relysia.com",
      "type": "paymail",
      "mainProtocol": "paymail",
      "outputs": [
        {
          "script": "76a9149196f6ef3234d17080ebf16460c502c21157125988ac",
          "satoshis": 10000
        }
      ],
      "inputs": [],
      "memo": "Send to 90@relysia.com",
      "isBSV": true,
      "peer": "https://api.relysia.com/v1/bsvalias/receive-transaction/90@relysia.com",
      "peerData": "i164psehd1a",
      "peerProtocol": "paymail"
    }
  }
}
```


# Transactions

Make a transaction, of any kind or type.

{% embed url="<https://share.synthesia.io/fb6560dc-dcb9-4cdb-b2d3-4e208a56ab47>" %}

Transactions are a significant aspect of every wallet interaction. By default, we try to transact every transaction bundle in a p2p fashion to reduce computational load and reduce latency. Classical address transactions will be long term supported for legacy reasons.&#x20;

#### Send Transaction

You can also send transactions without the URI function, by simply composing an array of receiver, amount and type. The note is optional and is send with the p2p bundle as message.&#x20;

Since the input is an Array, you can indicate many receivers at the same time.

{% hint style="success" %}
The receiver indicated can be a paymail alias or classical address
{% endhint %}

#### Non Bundle Transactions

For BSV transactions there is also the option to create separate transactions for each element in the dataArray. By adding in the bundle field and setting it to false it will then create a transaction for each entry in the data array. Note this is only valid for BSV type transactions. See Mulit Output Non Bundle tab for an example.

{% tabs %}
{% tab title="BSV" %}

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.0001,
          notes: "pizza payment"
        }
      ]
    },
}
const response = await relysia.transaction.v1.send(parameters);
```

{% endtab %}

{% tab title="Token" %}

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          tokenId: "1SJDKAS34DKSDKD1OD-SBD",
          amount: 2
        }
      ]
    },
}
const response = await relysia.transaction.v1.send(parameters);
```

{% endtab %}

{% tab title="NFT" %}

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          tokenId: "1SJDKAS34DKSDKD1OD-SBD",
          amount: 1,
          sn: 1 //optional
        }
      ]
    },
}
const response = await relysia.transaction.v1.send(parameters);
```

{% endtab %}

{% tab title="Multi Ouput" %}

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.00001,
          notes: "pizza payment"
        },
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.00001,
          notes: "grocery"
        },
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.0005
        }
      ]
    },
}
const response = await relysia.transaction.v1.send(parameters);
```

{% endtab %}

{% tab title="Mulit Output Non Bundle" %}

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      bundle : false,
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.00001,
          notes: "pizza payment"
        },
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.00001,
          notes: "grocery"
        },
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.0005
        }
      ]
    },
}
const response = await relysia.transaction.v1.send(parameters);
```

{% endtab %}
{% endtabs %}

## Transfer coins to an address.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/send`

Use the /send endpoint to create transactions to peers. The /send endpoint is agnostic to sending either Tokens or BSV.

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

#### Request Body

| Name      | Type    | Description             |
| --------- | ------- | ----------------------- |
| dataArray | array   | As per above            |
| bundle    | boolean | Default True (Optional) |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully",
    "txIds": ["string"]
  }
}
```

{% endtab %}
{% endtabs %}

Other than just BSV, you can send an arbitrary token (such as a NFT or festival ticket token). The fee manager is handling all transaction fees for the user (up to infrastructure provider determined limits) to improve the general onboarding and user experience.&#x20;

#### Data Append (STAS-789)

With the STAS-789 tokens, it is possible to include extra data in the token script during a transaction. To facilitate this feature, we have introduced a new field in the "/send" endpoint named "data", which is an array format. Each element of this array must be a string, and each string will be added as individual hexadecimal chunks of data that can be segmented while in ASM script format.\
\
The STAS-789 tokens are formatted as NFTs and will each have a unique serial number value, denoted as "sn" in the corresponding field.<br>

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          tokenId: "1SJDKAS34DKSDKD1OD-SBD",
          amount: 1,
          sn : 1,
          data : ["some data1", "some data2"]
        }
      ]
    },
}
const response = await relysia.transaction.v1.send(parameters);ja
```

### Paymail with optional Identification Tag

To enable providers with the ability to receive paymail funds from various entities without requiring new paymails, we created an optional extended paymail format. The new extended Paymail format is designed as follows:

```
{message}.name@domain.com
```

#### Example

For example, sending funds to:

```css
342d212.robin@myMail.com
```

This will direct the funds to:

```css
robin@myMail.com
```

With the note "342d212" included in the transaction history.

#### Benefits

* **Clear Association of Funds:** The message segment ensures that funds can be clearly associated with specific senders or transactions.
* **Deterministic Linking:** The message part can be replaced with a UID, providing a deterministic link to the user.
* **Enhanced Tracking:** Useful for exchanges and services requiring precise transaction tracking.

###


# Raw Transactions

Create an un-broadcasted raw transaction

Once a transaction is created using the /send endpoint and broadcasted to the network, there may be situations where access to the raw transaction data before broadcasting is necessary. To address this use case, the /rawtx endpoint becomes relevant. By utilizing the /rawtx endpoint, you can generate one or multiple transactions and retrieve the un-broadcasted raw transaction data. This data can be employed for alternative processes as needed.

The transactions generated through the /rawtx endpoint are constructed in their pure form, devoid of any change outputs that might be required for subsequent transactions. It's important to understand that any change outputs included in the transactions are not considered valid on the network until the previous transaction has been successfully broadcasted.

Similar to the [/send](/payments/transactions) endpoint, the /rawtx endpoint allows you to create transactions using the same input parameters in the request body. This facilitates consistency and familiarity in the process of generating transactions between the two endpoints.\ <br>

{% tabs %}
{% tab title="BSV" %}

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.0001
        }
      ]
    },
}
const response = await relysia.transaction.v1.rawtx(parameters);
```

{% endtab %}

{% tab title="Token" %}

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          tokenId: "1SJDKAS34DKSDKD1OD-SBD",
          amount: 2
        }
      ]
    },
}
const response = await relysia.transaction.v1.rawtx(parameters);
```

{% endtab %}

{% tab title="NFT" %}

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          tokenId: "1SJDKAS34DKSDKD1OD-SBD",
          amount: 1,
          sn: 1 //optional
        }
      ]
    },
}
const response = await relysia.transaction.v1.rawtx(parameters);
```

{% endtab %}

{% tab title="Multi Output" %}

```javascript
var parameters = {
    serviceId: 'optional',
    walletID: 'optional',
    data: {
      dataArray: [
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.00001
        },
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.00001
        },
        {
          to: "17n2JVhrCf1oYSMkZtZNjcf1deteUEKQsH",
          amount: 0.0005
        }
      ]
    },
}
const response = await relysia.transaction.v1.rawtx(parameters);
```

{% endtab %}
{% endtabs %}

## Build and return a raw transaction

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/rawtx`

Use the /rawtx endpoint containing a single input and output. Transactions can be held and the utxo that is used will be blocked from the user access.

#### Headers

| Name     | Type   | Description          |
| -------- | ------ | -------------------- |
| walletID | String | Wallet Id (Optional) |

#### Request Body

| Name                                        | Type  | Description  |
| ------------------------------------------- | ----- | ------------ |
| dataArray<mark style="color:red;">\*</mark> | array | As per above |

{% tabs %}
{% tab title="200: OK Succuss" %}

```json
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully",
    "rawTxs": [
      "0100000002e36d2003986bc84d1dec875ed686960e3794334c2e53bd8ee0d7897e4bf3f521000000006a4730440220063953703f06f9557691dba7b0424b9a1ca6dba2ec35bae7dd41e7b15fd38f1d0220439c01459709def5c824ded74102f4170ab3cee9ba7ab9f3b92dc80d7fcecf74412103c63be73d975c3f6274539704e27b2cb811bcc80dc11e95157cef3df8a5b3ac36ffffffffe36d2003986bc84d1dec875ed686960e3794334c2e53bd8ee0d7897e4bf3f521010000006b483045022100e5e0b6e4a61b7bad5c69a5b83032d6a48bb5976d582d52c881db2910ad79bb58022040a10e7dd9cde95c3756c63f33d6b5c119f35dcb4cedd29cc4424bf01e3548ed4121020824bb65d1cc92de2a37410e4279211a0d53788140a528b17f7ada7f4ad8a9a9ffffffff0101000000000000001976a91447431db9649fd75c28834cb152f17cc8ea7fa11f88ac00000000"
    ]
  }
}
```

{% endtab %}
{% endtabs %}

The rawtx response is a valid signed transaction that can be used in conjunction with paying invoices or awaiting other logic before broadcasting it to the network.<br>


# Invoices

Create a BitcoinSV or Token Invoice

When buying goods in supermarkets or online shops, customers are not asked to type in the exact amount to spend from their credit card, instead, they just get to see a fixed amount that they can decide to pay or not pay. We call systems that pre-determines an amount and requests payments "invoice systems"

{% hint style="info" %}
The advantage of "invoice" based system is that there is no room for failure outside payment success or decline.&#x20;
{% endhint %}

The structured process to create invoices is called BIP270 and is adopted by a variety of wallets such as SimplyCash, Centi or Handcash. An invoice created via the Relysia API can thus be understood by a variety of wallets and be universally used for BSV gateway systems.&#x20;

DPP (Direct Payment Protocol) is an expanded version of the BIP270 process that allows payment invoices to include Stas tokens and additional data for the beneficiaries of the payment. The "modeId" value of "ef63d9775da5" is a standard identifier for DPP payments that is an accepted data format for the invoice. The "native" or "stas" objects can be used to specify the desired transaction type and amount. The "amount" value in the "native" object is used to specify an amount in BSV.

{% hint style="success" %}
Whenever selling a product for BSV or Stas token, the invoice system is the system of choice.
{% endhint %}

In the next sections we will look at how to create the different types of invoices, how to resolve them and then ultimately how to settle them.<br>


# Create Invoice

Creating an invoice for payments

In this section, we will explore the various methods for generating invoices, namely the DPP and BIP270 processes, each with its own set of input fields. It's important to note that while DPP enables the creation of invoices using Tokens, BIP270 is specifically designed for generating BSV-type invoices.

Below, you will find examples of the invoice input bodies for both DPP and BIP270. For DPP, it is important to select and include either the "native" or "stas" section in the invoice input body, but does not support both at the same time.

{% tabs %}
{% tab title="DPP" %}

```javascript
var parameters = {
  "expirationTimeInMinuts": 0,
  "memo": "string",
  "paymentOptions": [
    {
      "transactions": [
        {
          "native": {
            "amount": 0,
            "to": "string"
          },
          "stas": {
            "tokenAmount": 0,
            "tokenRecipient": "string",
            "tokenId": "string"
          }
        }
      ]
    }
  ],
  "modeId": "ef63d9775da5",
  "beneficiary": {
    "name": "string",
    "email": "string",
    "address": "string",
    "paymentReference": "string"
  }
}
const response = await relysia.transaction.v1.invoice(parameters);
```

{% endtab %}

{% tab title="BIP270" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>var parameters = {
</strong>  "type": "string",
  "amount": 0,
  "address": "string",
  "merchantData": "string",
  "description": "string",
  "expirationTimeInMinuts": 0,
  "memo": "string"
}
const response = await relysia.transaction.v1.invoice(parameters);
</code></pre>

{% endtab %}
{% endtabs %}

### DPP&#x20;

The abbreviation "DPP" stands for Direct Payment Protocol, which is utilized for generating invoices that encompass BSV (Bitcoin SV) or STAS tokens. Note that the payment options cannot include both native and stas and only one is required for the invoice to be created.  The following is the "/invoice" endpoint to be employed when utilizing DPP:

## Create an Invoice

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/invoice`

Create an invoice to receive payments for a merchant product.

#### Request Body

| Name                                                      | Type   | Description                                             |
| --------------------------------------------------------- | ------ | ------------------------------------------------------- |
| expirationTimeInMinuts <mark style="color:red;">\*</mark> | Number | Number of minuites the Invoice is valid for             |
| memo                                                      | String | Notes about the transaction                             |
| paymentOptions<mark style="color:red;">\*</mark>          | Array  | Either Native BSV or STAS token                         |
| modeId<mark style="color:red;">\*</mark>                  | String | Specific identifier for the DPP protocol format used    |
| beneficiary<mark style="color:red;">\*</mark>             | Object | Information about the merchant revieing the transaction |

{% tabs %}
{% tab title="200: OK Success" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>{
</strong>  "statusCode": 200,
  "data": {
    "msg": "Operation Completed Successfully !",
    "status": "success",
    "reqUrl": "https://api.relysia.com/v1/payment-request/f339874f-ad98-486d-9359-a8aa2af2e040"
  }
}
</code></pre>

{% endtab %}
{% endtabs %}

### BIP270

BIP270 is a widely recognized invoice standard extensively adopted within the BSV (Bitcoin SV) ecosystem. When utilizing BIP270, the following are the inputs required for the "/invoice" endpoint:

## Create an Invoice

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/invoice`

Create an invoice to receive payments for a merchant product.

#### Request Body

| Name                                                     | Type   | Description                                        |
| -------------------------------------------------------- | ------ | -------------------------------------------------- |
| type                                                     | String | Supported Currencies such as "USD" , "BSV", etc... |
| amount<mark style="color:red;">\*</mark>                 | Number | amount in currency type                            |
| address<mark style="color:red;">\*</mark>                | String | receiving address for the payment                  |
| description                                              | String | Description about the transaction                  |
| expirationTimeInMinuts<mark style="color:red;">\*</mark> | Number | Number of minuites the Invoice is valid for        |
| memo                                                     | String | Notes about the transaction                        |
| merchantData                                             | String | Information about the receiving party/merchant     |

{% tabs %}
{% tab title="200: OK Success" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>{
</strong>  "statusCode": 200,
  "data": {
    "msg": "Operation Completed Successfully !",
    "status": "success",
    "reqUrl": "https://api.relysia.com/v1/payment-request/f339874f-ad98-486d-9359-a8aa2af2e040"
  }
}
</code></pre>

{% endtab %}
{% endtabs %}


# Get Invoice

Resolving an invoice to make a payment

Once an invoice is created, it is essential to provide a means for another party to receive the invoice and proceed with the payment. The response from the "/invoice" endpoint, typically in JSON format, can be utilized to extract the relevant information required for this process. \
\
There are 2 ways to resolve an invoice:

* Using an internal invoice ID query for any invoices that may be stored locally.&#x20;
* Using the URL extension in the [/URI](/payments/uri) endpoint that can be resolved externally.

### Get Invoice by paymentRequest invoice endpoint

In this method simply pass in the invoice Id value returned from the create invoice step which will return an invoice JSON related to that service ID.\ <br>

<pre class="language-javascript"><code class="lang-javascript">var parameters = {
<strong>    invoiceId : "8f9f4c27-3782-46e2-b76f-1ef956f52c61"
</strong>}
const response = await relysia.transaction.v1.paymentRequest(parameters)
</code></pre>

## Get invoice JSON

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/paymentRequest/:invoiceId`

Return Invoice JSON from an internal service using the invoice Id value.

#### Headers

| Name                                        | Type   | Description                               |
| ------------------------------------------- | ------ | ----------------------------------------- |
| invoiceId<mark style="color:red;">\*</mark> | String | Invoice Id provided from creating invoice |

{% tabs %}
{% tab title="200: OK Success" %}

{% endtab %}
{% endtabs %}

### Get Invoice by URI endpoint

In this method, invoices can be obtained by utilizing a [URI ](/payments/uri)endpoint with a specific URL extension. This approach serves as a way to externally receive invoices from the system. \
Here is an example of the URL extended format that is used in the URI endpoint to resolve the invoice and can be found in the "uri" field when creating the invoice.

```javascript
var parameters = {
    uri: "pay:?r=https://api.relysia.com/v1/paymentRequest/8f9f4c27-3782-46e2-b76f-1ef956f52c61"
}
const response = await relysia.utility.v1.uri(parameters)
```

## Resolve address, paymail aliias and invoice information

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/URI`

The URI endpoint helps developers to resolve addresses, paymails and invoices and puts them into a standardized response format.

#### Headers

| Name                                  | Type | Description                                                      |
| ------------------------------------- | ---- | ---------------------------------------------------------------- |
| URI<mark style="color:red;">\*</mark> |      | Invoice URI provided in the /invoice response in the "uri" field |

{% tabs %}
{% tab title="200: OK Success" %}

{% endtab %}
{% endtabs %}

### Response types

\
Depending whether your invoice is DPP or BIP270 will determine the type of response returned. Here are both examples.

{% tabs %}
{% tab title="DPP" %}

```json
{
  "statusCode": 200,
  "status": "success",
  "msg": "Operation Completed Successfully",
  "network": "mainnet",
  "uri": "pay:?r=https://api.relysia.com/v1/paymentRequest/8f9f4c27-3782-46e2-b76f-1ef956f52c61",
  "memo": "paying for testing",
  "type": "bip272",
  "paymentUrl": "https://api.relysia.com/v1/paymentRequest/pay/8f9f4c27-3782-46e2-b76f-1ef956f52c61",
  "mainProtocol": "bip272",
  "creationTimestamp": 1686814941,
  "modes": {
    "ef63d9775da5": {
      "PaymentOption_0": {
        "transactions": [
          {
            "outputs": {
              "stas": [
                {
                  "tokenId": "00b91626e0a4b97f624bc1f0d8fa3a3ef35ac664-TIGLdA",
                  "tokenAmount": 1,
                  "tokenRecipient": "1HQKnJ5FfCjcgvr6AAqNPYhY7NKuZXByMF"
                }
              ]
            },
            "policies": {
              "fees": {
                "standard": {
                  "bytes": 1000,
                  "satoshis": 50
                },
                "data": {
                  "bytes": 1000,
                  "satoshis": 50
                }
              }
            }
          }
        ]
      }
    }
  },
  "beneficiary": {
    "name": "vaionex test",
    "email": "test@vaionex.com",
    "paymentReference": "8f9f4c27-3782-46e2-b76f-1ef956f52c61",
    "address": "19702 Newark, Delaware, USA"
  },
  "expirationTimestamp": 1686816741,
  "version": "2.0.0"
}
```

{% endtab %}

{% tab title="BIP270" %}

```json
{
  "statusCode": 200,
  "status": "success",
  "msg": "Operation Completed Successfully",
  "mainProtocol": "bip272",
  "merchantData": "a3621ebf-97a4-476f-a028-a7a9c55b27e8",
  "expirationTimestamp": 1686560853,
  "memo": "paying for testing",
  "outputs": [
    {
      "description": "paying 1$ for testing",
      "script": "76a9140bb9eb13c821d10af1f5fbf01c04577305c24d3788ac",
      "satoshis": 3971132
    }
  ],
  "version": "2.0.0",
  "uri": "pay:?r=https://api.relysia.com/v1/paymentRequest/f3a7f350-2e2e-4e8b-af0d-58eb5eb3728a",
  "creationTimestamp": 1686560793,
  "type": "bip272",
  "network": "mainnet",
  "paymentUrl": "https://api.relysia.com/v1/paymentRequest/pay/f3a7f350-2e2e-4e8b-af0d-58eb5eb3728a"
}
```

{% endtab %}
{% endtabs %}

These responses can be directly used to make a payment. In the next section we will see how to use these response values.


# Pay Invoice

Make a payment on an invoice

As We learned in the earlier section about [invoices](/payments/invoices), there are advantages to pre-determine request amounts. From a infrastructure perspective, it is advantageous to create invoice alike schemas even if no invoice was given to exactly determine what script to use to make certain payments.&#x20;

The [/pay](#undefined) endpoint takes up [lookup ](/payments/uri)response formats and triggers a payment. While that might sound a bit complex, we can imagine is as a standardization machine that can take up a variety of formats without worrying about their compatibility. \
\
Similar to the get invoice methods, there are also two ways to pay for an invoice. This includes an internal method and and external method.

{% hint style="info" %}
Whereas the payment endpoint is essential to complete invoice requests, we created utility wrappers around the pay endpoint, such as the [/send](/payments/transactions) endpoint that lets you define address, type and amount to make transactions in a simpler format.&#x20;
{% endhint %}

### Pay Invoice using by URI response (external)

To make a invoice payment, take the response of the [URI](/payments/invoices/get-invoice) endpoint (the **data**) without any additional changes to pay a payment invoice.&#x20;

#### DPP using /pay

This is an example of paying for a DPP invoice using the /pay endpoint. Please check in [Get Invoice ](/payments/invoices/get-invoice)to get extended values for the body input using DPP.

## Pay an Invoice

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/pay`

The endpoint enables users to pay their invoices that were earlier resolved and put into a standardized format by the /URI endpoint.

#### Request Body

| Name                                           | Type   | Description |
| ---------------------------------------------- | ------ | ----------- |
| network<mark style="color:red;">\*</mark>      | String |             |
| uri<mark style="color:red;">\*</mark>          | String |             |
| memo<mark style="color:red;">\*</mark>         | String |             |
| type<mark style="color:red;">\*</mark>         | String |             |
| paymentUrl<mark style="color:red;">\*</mark>   | String |             |
| mainProtocol<mark style="color:red;">\*</mark> | String |             |
| modes<mark style="color:red;">\*</mark>        | Object |             |
| beneficiary <mark style="color:red;">\*</mark> | Object |             |
| version<mark style="color:red;">\*</mark>      | String |             |

#### BIP270 using /pay

This is an example if paying for a BIP270 invoice using the /pay endpoint. Please check in [Get Invoice ](/payments/invoices/get-invoice)to get extended values for the body input using BIP270.<br>

## Pay an Invoice

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/pay`

The endpoint enables users to pay their invoices that were earlier resolved and put into a standardized format by the /URI endpoint.

#### Request Body

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| uri          | String |             |
| type         | String |             |
| mainProtocol | String |             |
| outputs      | Array  |             |
| inputs       | Array  |             |
| memo         | String |             |
| isBSV        | String |             |
| peer         | String |             |
| peerData     | String |             |
| peerProtocol | String |             |

{% tabs %}
{% tab title="200: OK Success" %}

```json
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Transaction sent successfully",
    "txid": "80e5b09f1613a0f82c94216e84db747b80b631be8618eb97f3ea4ab440ea223f"
  }
}
```

{% endtab %}
{% endtabs %}

### Pay Invoice using payment-request Invoice (internal)

This method involves constructing a transaction using the[ /rawTx ](/payments/raw-transactions)API and using it as a parameter in another API to associate it with an internal invoice ID for payment confirmation.

Whether DPP or BIP270 is used, the process remains consistent. The /rawTx API is used to create the transaction, and its data is passed as a parameter in the relevant API to link it with an internal invoice ID.

Regardless of the invoice standard (DPP or BIP270) being utilized, the transaction construction and referencing process remains the same, ensuring compatibility and consistency across both methods.

## Settle an invoice request

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/paymentRequest/pay/:invoiceId`

The API takes invoice and settles it.

#### Headers

| Name                                        | Type   | Description           |
| ------------------------------------------- | ------ | --------------------- |
| invoiceId<mark style="color:red;">\*</mark> | String | Invoice ID to be paid |

#### Request Body

| Name                                          | Type   | Description                       |
| --------------------------------------------- | ------ | --------------------------------- |
| merchantData                                  | String | merchant information              |
| transaction<mark style="color:red;">\*</mark> | String | Transaction hexadecimal value     |
| refundTo                                      | String | Address for refund if required    |
| memo                                          |        | Description about the transaction |

{% tabs %}
{% tab title="200: OK Success" %}

```json
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully.",
    "statusCode": 200,
    "data": {
      "status": "success",
      "msg": "Payment Completed Successfully",
      "txId": "ef8bdedd64477adcf1d297cf7fbb92c743251634841418e43f6e74db921770a3"
    }
  }
}
```

{% endtab %}
{% endtabs %}


# Payments

How to make general payments

To make a payment it requires an input, and rather than the requirement to build this input from scratch we can utilize the URI endpoint as described in lookup. We can use the /URI endpoint as a way to construct these payment JSON values in a simplistic way.\
\
Here is an example of creating a payment request using the [URI ](/payments/uri)endpoint&#x20;

```javascript
var parameters = {
    uri: "payto:90@relysia.com?purpose=cashback&amount=10000"
}
const response = await relysia.utility.v1.uri(parameters)
```

This will be the response which is a standard payment format.

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully",
    "data": {
      "uri": "payto:90@relysia.com?purpose=cashback&amount=10000",
      "type": "paymail",
      "mainProtocol": "paymail",
      "outputs": [
        {
          "script": "76a914e2a15b75da46234f5e5943b1289b955842532ce088ac",
          "satoshis": 10000
        }
      ],
      "inputs": [],
      "memo": "cashback",
      "isBSV": true,
      "peer": "https://api.relysia.com/v1/bsvalias/receive-transaction/90@relysia.com",
      "peerData": "2zwwsow4bfg",
      "peerProtocol": "paymail"
    }
  }
}
```

This can then be used to facilitate general payments. The advantages include using a simple format provided by the URI endpoint, which allows for the retrieval of a comprehensive JSON schema conforming to widely accepted industry standards within the ecosystem. Alternatively, these formats can also be constructed from scratch if necessary.

## Pay an invoice request.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/pay`

The endpoint enables users to pay their invoices that were earlier resolved and put into a standardized format by the /URI endpoint.

#### Headers

| Name                                   | Type   | Description                                    |
| -------------------------------------- | ------ | ---------------------------------------------- |
| data<mark style="color:red;">\*</mark> | Object | As described above using the inner data object |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Transaction Completed Successfully",
    "txid": "f12823a06cbc8b14b14a779f55c51a9c99e980495505b43d79ab6b8d5d0f5393"
  }
}
```

{% endtab %}
{% endtabs %}


# Asm

Create a Bitcoin script transaction

**Asm trasaction:**

With this endpoint user can create a trasaction by passing custom ASM script as input. This endpoint accept ASM script an amount of trasfer as input in request body. It send amount of BSV to target destination.

{% hint style="warning" %}
Asm doesn't support Token or NFT transfer, It only support BSV transfer.&#x20;
{% endhint %}

```javascript
const dataArray = [
    {
      "asm": "string",
      "amount": "number"
    }
];
```

## Asm trasaction endpoint

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/asm`

The asm endpoint allows custom scripts to be added as outputs in a transaction

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletId | string |             |

#### Request Body

| Name      | Type   | Description  |
| --------- | ------ | ------------ |
| dataArray | object | As per above |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "txid": "string"
  }
}
```

{% endtab %}
{% endtabs %}


# Basics

Relysia Infrastructure and Tokens

Relysia was build from the ground up with token support in mind. You can let your users mint and share tokens without them requiring to own any BitcoinSV base currency.&#x20;

As platform, we focus on a portfolio of reliable and stable protocols to ensure the best experience for both developers and their users. In our initial release, we thus launch on STAS tokens that have the unique ability to only require the execution of bitcoin script smart contracts.&#x20;

{% hint style="success" %}
Similar to artwork, NFTs and other collectibles may require decade long stability of their underlying token protocols. We at Relysia use inherently stable protocols to ensure ownership and the individual faith of companies are never connected.&#x20;
{% endhint %}

#### STAS Token

STAS tokens are native bitcoin script tokens that get directly enforced by smart contracts. On of their main benefits over existing protocols is their long term stability and maintenance free functioning.

Smart contracts on the Bitcoin blockchain (written in script) are very similar to normal transactions, with the difference that they can only be transferred if certain conditions are met. Since they are normal transaction, they have the same limitations as a standard bitcoin transaction. The advantage is that a **STAS token natively scales** with improvements of the underlying network.

A transaction (and thus UTXO) can only be created with at least one satoshi within the STAS contract. When creating a token with 1 million supply, it will require 1 million satoshis.

#### STAS Types

The STAS protocol is versatile, capable of accommodating both NFTs and Tokens through configuration. The meta field associated with STAS tokens is fully customizable, enabling developers to input any necessary JSON data. In schema, the metadata format can be defined as either standard or non-standard. A standard metadata format is NFT1.0, which includes a media field containing a B protocol link, media type specified in MIME format, and altURI (a classical image URL).

A crucial distinction lies in the value of "splittable," which determines whether STAS tokens can be split (2 --> 1 + 1) and merged (1 + 1 --> 2), or not (1 --> 1). For NFTs, splittable should be set to false, resulting in serialization such as 1/100, 2/100, and so on.

#### STAS redemption

As previously established, each STAS UTXO smart contract requires a certain number of satoshis. However, when a token is no longer needed, the satoshis used in its creation are not lost; they can be released by redeeming the STAS smart contract, essentially dissolving the token. STAS tokens are redeemed by sending them back to their contract issuance address that is contained within every STAS token script.


# Token Issuance

Create a STAS token

Creating a token requires you to first create a 'default' wallet to issue it to the wallet. If you didnt create one, you can jump back to the wallet section.

{% content-ref url="/pages/hABMaBoPQMjkGOFOBk1I" %}
[Wallets](/wallets/wallets)
{% endcontent-ref %}

The token issuance endpoint takes care of all the rest (including paying the mining fee to mint the token). All you need is to add the parameters to specify the type of STAS token you want.&#x20;

| Parameter      | Description                                                                      | Property                                       |
| -------------- | -------------------------------------------------------------------------------- | ---------------------------------------------- |
| Name           | The token name                                                                   | UTF-8 standard, up to 32 characters in length. |
| Symbol         | The token symbol                                                                 | 1-9 alphanumeric characters                    |
| Description    | The token description                                                            | up to 512 characters                           |
| Image          | The mini icon image                                                              | 250x250 pixels, type image                     |
| Token Supply   | The amount of tokens to mint in the issuance                                     | Any integer                                    |
| Decimals       | Decimals indicate the formatting, e.g. decimals 2 for a dollar token with cents. | Integer not bigger than 8                      |
| Sats Per Token | Satoshis to be used for each token.                                              | Integer                                        |
| Splitable      | Tokens are split table and merge able, NFTs are not.                             | Boolean \[true/false]                          |
| Data           | Custom data string(s) to be added to the issued tokens                           | Object\<Array>                                 |
| Meta           | Any extra data to indicate legals and terms.                                     | RFC 3986 JSON formatted                        |

Above stated are the main inputs for each STAS token, the extended schema can be found in below code example. There is only one STAS format but various settings that make it behave according to its purpose and use case.&#x20;

#### Issuance function

To issue a STAS token, create a variable with all parameters, and trigger `relysia.issue()`.&#x20;

```javascript
var parameters = {
    serviceId: 'optional',
    protocol: 'optional',
    data: {
      "name": "Bonus Point Token",
      "protocolId": "STAS",
      "symbol": "BPT",
      "description": "A supermarket bonus point token to be used ay https://yourproject.com",
      "image": "https://firebasestorage.googleapis.com/v0/b/nftdev/o/nftTemp%2FWL1DdD?alt=media",
      "tokenSupply": 30,
      "decimals": 0,
      "satsPerToken": 1,
      "splitable": true,
      "data" : {"1" : ["custom data 1", "custom data 2"]},
      "properties": {
        "legal": {
          "terms": "STAS, Inc. retains all rights to the token script.  Use is subject to terms at https://stastoken.com/license.",
          "licenceId": "stastoken.com"
        },
        "issuer": {
          "organisation": "vaionex corp.",
          "legalForm": "Limited",
          "governingLaw": "US",
          "issuerCountry": "US",
          "jurisdiction": "US",
          "email": "info@vaionex.com"
        },
        "meta": {
          "schemaId": "STAS1.0",
          "website": "https://yourProject.com",
          "legal": {
            "terms": "Your personal token terms"
          }
        }
      }
    }
}
const response = await relysia.contracts.v1.issue(parameters);
```

### Custom Data Field for Tokens

Incorporating personalized data into your Tokens can significantly enhance its functionality. The "data" field allows for the inclusion of an object value, which will be assigned as a numbered string key with an accompanying array property. Each element in the array will be added to the token script as its own data chunk.

```
"data" : {"1" : ["custom data 1", "custom data 2"]},
```

## Mint a Token.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/issue`

Mint a token with given specifications (can be both token or NFT). More on docs.relysia.com.

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| protocol | string |             |
| walletID | string |             |

#### Request Body

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| name         | string  |             |
| protocolId   | string  |             |
| symbol       | string  |             |
| description  | string  |             |
| image        | string  |             |
| tokenSupply  | number  |             |
| decimals     | number  |             |
| satsPerToken | number  |             |
| properties   | object  |             |
| splitable    | boolean |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Contract created successfully",
    "tokenId": "7791e1839f705e2813ec744a15fd10d355ff99b2-Han-2022",
    "tokenObj": {
      "name": "Han solo",
      "protocolId": "STAS",
      "symbol": "Han-2022",
      "description": "Starwars addition",
      "image": "https://images.unsplash.com/photo-1663454455454-49cf9e3d87f6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxMHx8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60",
      "totalSupply": 3,
      "decimals": 0,
      "satsPerToken": 1,
      "properties": {
        "legal": {
          "terms": "Your token terms and description.",
          "licenceId": "T3ST-2"
        },
        "issuer": {
          "organisation": "Vaionex Corp.",
          "legalForm": "Limited",
          "governingLaw": "US",
          "issuerCountry": "US",
          "jurisdiction": "US",
          "email": "info@vaionex.com"
        },
        "meta": {
          "schemaId": "NFT1.0/MA",
          "website": "vaionex.com",
          "legal": {
            "terms": "© 2020 TAAL TECHNOLOGIES SEZC\nALL RIGHTS RESERVED. ANY USE OF THIS SOFTWARE IS SUBJECT TO TERMS AND CONDITIONS OF LICENSE. USE OF THIS SOFTWARE WITHOUT LICENSE CONSTITUTES INFRINGEMENT OF INTELLECTUAL PROPERTY. FOR LICENSE DETAILS OF THE SOFTWARE, PLEASE REFER TO: www.taal.com/stas-token-license-agreement"
          },
          "media": [
            {
              "URI": "string",
              "type": "string",
              "altURI": "string"
            }
          ]
        }
      },
      "splitable": true,
      "contractTxid": "bc6dd15cb063163dfe7a9707a02a6365301fb95d4365cc79a6c4fa3018064a6b",
      "issueTxid": "c776daaaabbbf61b9ca97bfbd3580600b69806ee2b9b224b5b570e704d639b8c",
      "intialSupply": 3,
      "contractAddress": "1BuEAp4mjJdeDGcpw6XdvtA9fWmHNF2mMX",
      "creationDate": "1663823369759",
      "userId": "JZzO1ySdhkPkBYQLXa66EbXDUFD2",
      "updationDate": "1663823369760"
    }
  }
}
```

{% endtab %}
{% endtabs %}

####


# NFT Issuance

Create your first NFT

Non fungible tokens (NFTs) are a way to reward your fans, create collectors, distribute art and declare ownership. NFTs can also be used in extended use as access token or ticket to a festival, which enables countless business opportunities. The issuance of NFTs with the STAS protocol is very similar to normal tokens, with an extended metadata format (to store media files) and other freely customizable attributes.&#x20;

The general issuance format is the same as the STAS token:

| Parameter      | Description                                                                      | Property                                       |
| -------------- | -------------------------------------------------------------------------------- | ---------------------------------------------- |
| Name           | The token name                                                                   | UTF-8 standard, up to 32 characters in length. |
| Symbol         | The token symbol                                                                 | 1-9 alphanumeric characters                    |
| Description    | The token description                                                            | up to 512 characters                           |
| Image          | The mini icon image                                                              | 250x250 pixels, type image                     |
| Token Supply   | The amount of tokens to mint in the issuance                                     | Any integer                                    |
| Decimals       | Decimals indicate the formatting, e.g. decimals 2 for a dollar token with cents. | Integer not bigger than 8                      |
| Sats Per Token | Satoshis to be used for each token.                                              | Integer                                        |
| Splitable      | Tokens are split table and merge able, NFTs are not.                             | Boolean \[true/false]                          |
| Data           | Custom data string(s) to be added to the issued tokens                           | Object\<Array>                                 |
| Meta           | Any extra data to indicate legals and terms.                                     | RFC 3986 JSON formatted                        |

This endpoint will issue a STAS token in your wallet, depending on the parameters you assign.

{% hint style="info" %}
NFTs need to be issued with splittable = false tag. While a token (splittable = true) can also be used as NFT, there is a risk of getting merged or split and thus destroying the value of the NFT.&#x20;
{% endhint %}

```javascript
var parameters = {
    serviceId: 'optional',
    protocol: 'optional',
    data: {
      "name": "Football Card 21",
      "protocolId": "STAS",
      "symbol": "FC21",
      "description": "A FC 21 season nft",
      "image": "https://firebasestorage.googleapis.com/v0/b/nftdev/o/nftTemp%2FWL1DdD?alt=media",
      "tokenSupply": 21,
      "decimals": 0,
      "satsPerToken": 1,
      "splitable": false,
      "data" : {"1" : ["custom data 1", "custom data 2"]},
      "properties": {
        "legal": {
          "terms": "STAS, Inc. retains all rights to the token script.  Use is subject to terms at https://stastoken.com/license.",
          "licenceId": "stastoken.com"
        },
        "issuer": {
          "organisation": "vaionex corp.",
          "legalForm": "Limited",
          "governingLaw": "US",
          "issuerCountry": "US",
          "jurisdiction": "US",
          "email": "info@vaionex.com"
        },
        "meta": {
          "schemaId": "NFT1.0",
          "website": "https://football21.com",
          "legal": {
            "terms": "the terms of your nft"
          },
          "media": [
            {
              "URI": "string",
              "type": "string",
              "altURI": "string"
            }
          ]
        }
      },
    },
}
const response = await relysia.contracts.v1.issue(parameters);
```

### Custom Data for NFTs

Incorporating personalized data into your NFT can significantly enhance its functionality. The "data" field allows for the inclusion of an object value, which will be assigned as a numbered string key with an accompanying array property. Each element in the array will be added to the token script as its own data chunk. In this method below it will add the same data to each of the NFTs in a collection

```
"data" : {"1" : ["custom data 1", "custom data 2"]},
```

### Custom Data for NFT collection&#x20;

When building a collection of NFTs, you have the ability to incorporate distinct custom data into each of them using the following approach. In this method, each object key corresponds to the specific NFT number to which you are attaching the data.

```
 "data" : {"1" : ["custom data"], "2" : ["custom data 1", "custom data 2"]},
```

{% hint style="warning" %}
When adding different custom data for each of your NFT collection it is required that the number of keys matches the number of NFTs in the collection.&#x20;
{% endhint %}

## Mint a Token.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/issue`

Mint a token with given specifications (can be both token or NFT). More on docs.relysia.com.

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| protocol | string |             |
| walletID | string |             |

#### Request Body

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| name         | string  |             |
| protocolId   | string  |             |
| symbol       | string  |             |
| description  | string  |             |
| image        | string  |             |
| tokenSupply  | number  |             |
| decimals     | number  |             |
| satsPerToken | number  |             |
| properties   | object  |             |
| splitable    | boolean |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Contract created successfully",
    "tokenId": "7791e1839f705e2813ec744a15fd10d355ff99b2-Party-Monster",
    "tokenObj": {
      "name": "Party plans",
      "protocolId": "STAS",
      "symbol": "Party-Monster",
      "description": "NFT to access party pass",
      "image": "https://images.unsplash.com/photo-1663668566893-7a4887f9a41d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHw0MHx8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60",
      "totalSupply": 3,
      "decimals": 0,
      "satsPerToken": 1,
      "properties": {
        "legal": {
          "terms": "Your token terms and description.",
          "licenceId": "T3ST-2"
        },
        "issuer": {
          "organisation": "Vaionex Corp.",
          "legalForm": "Limited",
          "governingLaw": "US",
          "issuerCountry": "US",
          "jurisdiction": "US",
          "email": "info@vaionex.com"
        },
        "meta": {
          "schemaId": "NFT1.0/MA",
          "website": "vaionex.com",
          "legal": {
            "terms": "© 2020 TAAL TECHNOLOGIES SEZC\nALL RIGHTS RESERVED. ANY USE OF THIS SOFTWARE IS SUBJECT TO TERMS AND CONDITIONS OF LICENSE. USE OF THIS SOFTWARE WITHOUT LICENSE CONSTITUTES INFRINGEMENT OF INTELLECTUAL PROPERTY. FOR LICENSE DETAILS OF THE SOFTWARE, PLEASE REFER TO: www.taal.com/stas-token-license-agreement"
          },
          "media": [
            {
              "URI": "string",
              "type": "string",
              "altURI": "string"
            }
          ]
        }
      },
      "splitable": false,
      "contractTxid": "4f0f48aed55faaa23a2824f833627b1e663489b8a582cc8e0ff343c8e0350fb9",
      "issueTxid": "7fb2f67aba101fb650d8d35a9a6dc2600ed6aef0d26008bb5a4b363382dd386b",
      "intialSupply": 3,
      "contractAddress": "1BuEAp4mjJdeDGcpw6XdvtA9fWmHNF2mMX",
      "creationDate": "1663824087093",
      "userId": "JZzO1ySdhkPkBYQLXa66EbXDUFD2",
      "updationDate": "1663824087093"
    }
  }
}
```

{% endtab %}
{% endtabs %}

####


# Atomic Swaps

Exchanging one token against another.

{% embed url="<https://share.synthesia.io/8f6e8505-aa09-406e-bb98-1df337866abd>" %}

When exchanging tokens, an Atomic Swaps are essential to guarantee that both tokens are exchanged instantaneously and without the ability of any party to default on their commitment.

Atomic swaps are single transactions that contain partially signed peaces of the transaction from both parties. Only when the transaction piece gets completed by the counterparty, the transaction can get send to the mining network. &#x20;

Atomic Swaps either accept the transaction and do the swap or make no transaction at all (thus neither party looses their respective asset). Since the function has no room for one-sided failure, it is a ideal to be implemented in any kind of value exchange, since it reduces fraud levels and security risk. Moreover, the exchange can happen in a peer 2 peer fashion, without any additional intermediary other than the exchanging parties.&#x20;

In the relysia API, the first atomic swap partial transaction gets created with the /offer endpoint and later completed with the /swap endpoint by the counter party. \ <br>

{% hint style="info" %}
The partially signed transaction hex, created by the /offer endpoint, is shared to the party wanting to complete the transaction (e.g. a buyer of an asset).&#x20;
{% endhint %}

### Swap Types

There are three swap types that can be used to create an offer. Note that the token quantities will be represented as Integers (without decimal places), while the BSV amounts will be of type Number with native decimal representation (e.g. 0.0000001)\
\
**Token for BSV**\
This type of swap will return an offer hex containing a token input from a user and a desired output amount in BSV. The "sn" parameter is optional and will specify a specific serial number value for an NFT collection.\
\
**Token for Token**\
This type of swap will return an offer hex containing a token input from a user and a specified token to swap with. The "sn" and "wantedSn" parameters are optional and will specify a specific serial number value for an NFT collection. Alternatively, the "wantedScript" parameter can be used instead of "wantedTokenId" to specify an entire script hex value of a token, regardless of the owner of that token script.\
\
**BSV for Token**\
This type of swap will return an offer hex containing a specified BSV amount UTXO as an input and a specified token to swap with. Like the previous type, the "wantedSn" parameter is optional and will specify a specific serial number value for an NFT collection. The "wantedScript" parameter can also be used instead of "wantedTokenId" to specify an entire script hex value of a token, regardless of the owner of that token script.

{% tabs %}
{% tab title="Token for BSV" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>const dataArray = [{
</strong>    "tokenId": "d4b5ec377fa847b53b0e08459326817000886af4-USD",
    "amount" : 10,
    "wantedAmount" : 0.001
}];
</code></pre>

{% endtab %}

{% tab title="Token for Token" %}

<pre class="language-javascript"><code class="lang-javascript">const dataArray = [{
    "tokenId": "d4b5ec377fa847b53b0e08459326817000886af4-USD",
    "amount" : 10,
    "wantedTokenId" : "ca7a5c64543850de318639334a5aaa65947914cb-MYNFT",
<strong>    "wantedSn" : 1, // optional
</strong>    "wantedAmount" : 1
}];
</code></pre>

{% endtab %}

{% tab title="BSV for Token" %}

```javascript
const dataArray = [{   
    "amount" : 0.001,
    "wantedTokenId" : "d4b5ec377fa847b53b0e08459326817000886af4-USD", 
    "wantedAmount" : 10
}];
```

{% endtab %}
{% endtabs %}

## Create an Atomic Swap

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/offer`

This endpoint allows user to create a swap offer. The amount is the value in satoshis wanted in exchange for the token

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

#### Request Body

| Name      | Type  | Description  |
| --------- | ----- | ------------ |
| dataArray | array | as per above |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully",
    "contents": [
      "0100000001046ae503360b130eb8c1da56c96b9776aade49333550bca085153978dde308c5010000006b483045022100ce974678e2ef48c42dd80e100f8637545e4da32e5d9bdd622066a86187d4a49f0220046b187e4e9b92d62a2edc893fe580f98e8f45fd090a7e175ea87e1ca3b62d88c3210387d82034a417c41916f212a70978c199fead7a3a2769f4d3ed0ebce8f361f835ffffffff0100e1f505000000001976a914ec83f1fb2c52dbd7b2d4c70cf95150560d611b9088ac00000000"
    ]
  }
}
```

{% endtab %}
{% endtabs %}

After defining the token asset to sell and the token asset or BSV and amount to receive, a partially signed transaction is created, and the hex value returned. This signature will bind the input provided by the user to the single output value in the offer hex

{% hint style="info" %}
The hex value can be read by any third party services to complete the transaction in a decentralized way without reliance on the Relyisa infrastructure. &#x20;
{% endhint %}

Before accepting an atomic swap, the 2nd party might want to inspect the partially signed transaction hex to ensure they actually receive the asset they expect to get at the right conditions. For that we created the /inspect endpoint. Add any partially signed transaction hex to the endpoint to decode the insights/conditions.&#x20;

```javascript
const dataArray = [{
    "swapHex": "string",
}];
```

## Inspect an atomic swap offer.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v2/inspect`

This endpoint allows users to inspect an atomic swap hex to verify the validity of the offer.

#### Request Body

| Name                                        | Type  | Description  |
| ------------------------------------------- | ----- | ------------ |
| dataArray<mark style="color:red;">\*</mark> | array | as per above |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation completed successfully",
    "offerDetails": [
      {
        "tokenOwnerAddress": "1DuxjqtUenBrXBsLSYn4UEFP8MKXSLfuq4",
        "tokenCreatorAddress": "114pj3BWST7zXWbYpHUyPhR83r9SHFwSN2",
        "tokenSatoshis": 1,
        "wantedSatoshis": 1,
        "tokenImage": "https://upload.wikimedia.org/wikipedia/en/9/95/Test_image.jpg",
        "serialNumber": 1,
        "splittbale": false,
        "contractTxid": "441e1695a5ea130b9b5a7beda88afc75c47f9f4e868e0e025ca51788555010a0",
        "tokenId": "00b91626e0a4b97f624bc1f0d8fa3a3ef35ac664",
        "symbol": "dwE1u6",
        "tokenSupply": 1,
        "verified": true,
        "tokenName": "Test Token - Generated automatically form tests",
        "tokenDescription": "Test Token - Generated automatically form tests"
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

Finally, after ensuring the partially signed transaction is indeed having the assets one wants to buy for the given price, the atomic swap gets completed by the counterparty with the /swap endpoint.&#x20;

The /swap endpoint accepts the partially signed transaction hex as input (and thus also works cross platforms with external atomic swap offers).&#x20;

{% hint style="warning" %}
Always ensure the asset you buy is actually the asset you want. While we try to warn users of "fake" assets, the user is signing whatever the counter party provides (especially when from external counter parties).
{% endhint %}

```javascript
const dataArray = [{
    "swapHex": "string"
}];
```

## Accepting atomic swap offers.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/swap`

This endpoint allows users to accept swap offers by passing respective hex value values.

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

#### Request Body

| Name      | Type  | Description  |
| --------- | ----- | ------------ |
| dataArray | array | as per above |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  statusCode: 200,
  data: {
    status: 'success',
    msg: 'Operation completed successfully',
    txIds: [
      '698080e9917a576a1451770c2cb91b50d27b54c3ecaca663fb54f3ed1b143789'
    ]
  }
}
```

{% endtab %}
{% endtabs %}

After completing the atomic swap by counter signing the offer transaction (and adding their piece of information to the puzzle), the transaction is directly submitted and the transaction id returned.&#x20;


# Details

Verify that you got the correct STAS token

Fetch the latest state of your STAS token and the issuance details. The only parameter required is tokenID, which you will have if you issued a token via the /issue endpoint or can be found on the manage tokens section of Relysia Wallet.

```javascript
var parameters = {
    tokenID: 'ca7a5c64543850de318639334a5aaa65947914cb-MYNFT'
}
const response = await relysia.contracts.v2.tokenDetails(parameters);
```

In the event that the item in question is an NFT, it is possible to expand your search parameters by including a designated serial number in addition to the token ID.

```javascript
var parameters = {
    tokenID: 'ca7a5c64543850de318639334a5aaa65947914cb-MYNFT-2'
}
const response = await relysia.contracts.v2.tokenDetails(parameters);
```


# Leaderboard

To display the distribution of a particular token, we implemented the /leaderboard endpoint. A leaderboard is typically an information page on a platform page that shows how you rank among others. Distributing tokens in a competition and then displaying ownership is thus an interesting way to enrich the user experience.&#x20;

Since tokens are on a public blockchain, we can aggregate all transactions and balances from the public blockchain to display the leaderboard. Thanks to p2p paymail integration, updating the leaderboard happens in real time.&#x20;

<figure><img src="https://1860373586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ml6s5BMmWoDc9jHH2VT%2Fuploads%2FMIquWbRK8EtQYqE9PyFF%2Fimage.png?alt=media&amp;token=a17c6e89-266e-4fdc-be1d-979af55420fa" alt=""><figcaption></figcaption></figure>

{% openapi src="<https://api.relysia.com/docs/json>" path="/v1/leaderboard" method="get" %}
<https://api.relysia.com/docs/json>
{% endopenapi %}


# Post

Upload Data to the Blockchain

{% embed url="<https://share.synthesia.io/046d191d-698b-46ca-891c-675792113059>" %}

The bitcoin blockchain is a timestamp server. That means it can proof that certain documents were added to the blockchain at exactly that time and not modified later, which led to a variety of applications within the BSV space. From certifying documents against the blockchain to later proof no modification of it occurred to social media posts. \
\
While miners are not required to keep a copy of your blockchain post for all eternity on their mining servers, a whole ecosystem spawned over the years that uses the blockchain as decentralized storage system.&#x20;

{% hint style="warning" %}
OP\_R*eturn data on the blockchain can be pruned by individual miners since OP\_return transactions can't create another transaction (thus irrelevant for the validation process).*
{% endhint %}

Even though the hosting of uploaded data is not guaranteed, the hash of transactions is always verifiable via SPV networks and presents a long term reliable path to verify that B://cat data is unaltered since upload.&#x20;

{% hint style="info" %}
*The business of maintaining and hosting OP\_Return data onchain has found some traction with services such as Project Babbage, Metashard and Planaria.*
{% endhint %}

{% embed url="<https://api.relysia.com/docs/static/index.html>" %}

```javascript
const dataArray = [
    {
      "notes": [
        "note-1",
        "note-2"
      ]
    }
  ]
```

## Post Messages to the Blockchain.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/post`

The /post endpoint broadcasts a note to the blockchain (in B:// protocol format).

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

#### Request Body

| Name      | Type  | Description  |
| --------- | ----- | ------------ |
| dataArray | array | As per above |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  statusCode: 200,
  data: {
    status: 'success',
    msg: 'Data uploaded Successfully',
    txid: 'string'
  }
}
```

{% endtab %}
{% endtabs %}

```javascript
var parameters = { 
    serviceID: 'optional',
    walletID: 'optional',
    body: {
        notes: ["text1", "text2", "text3"]
    }
}

const response = await relysia.post(parameters);
```


# Upload

Upload Data to the Blockchain

{% embed url="<https://share.synthesia.io/dc3378e7-ab2a-4f03-ab58-1694000e9a32>" %}

Every transaction on the blockchain is a data bundle. Instead of integrating locking and unlocking scripts to the UTXO, one can also upload arbitrary data.&#x20;

A common use case for uploads is to store NFT images or videos in [B://cat](https://bcat.bico.media/) protocol format directly on-chain instead of on a server, to ensure the long term availability of the media file.&#x20;

Our media /upload endpoint is currently available via API to seamlessly upload files.&#x20;

{% hint style="info" %}
We currently support uploads up to 20MB on the production server and keep extending the limits. In our prototypes we recently successfully uploaded >1GB files.&#x20;
{% endhint %}

{% hint style="warning" %}
Same [pruning considerations](/utility/post) shall apply to the /upload endpoint.
{% endhint %}

{% embed url="<https://api.relysia.com/docs/static/index.html>" %}

## Blockchain File Upload.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/upload`

The /upload endpoint broadcasts a media file (supplied as URL) to the blockchain (in B:// protocol format).

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| fileUrl<mark style="color:red;">\*</mark>  | string |             |
| fileName<mark style="color:red;">\*</mark> | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Data uploaded Successfully",
    "uploadObj": {
      "fileName": "Relysia Test nft image size 1 kb.",
      "fileType": "image",
      "fileSize": 1121,
      "timeStamp": "2022-09-19T09:24:10.808Z",
      "txid": "f6c830f25f84ba14ef9cdef76dcf16934a9693b9acadd6573d759e8104fa38d8",
      "address": "1BuEAp4mjJdeDGcpw6XdvtA9fWmHNF2mMX",
      "addressPath": "m/44'/0'/0'/0/0",
      "url": "B://f6c830f25f84ba14ef9cdef76dcf16934a9693b9acadd6573d759e8104fa38d8"
    }
  }
}
```

{% endtab %}
{% endtabs %}

```javascript
var parameters = { 
    serviceId: 'optional',
    walletID: 'optional',
    body: {
          type: "media",
          fileUrl: "https://firebasestorage.googleapis.com/v0/b/musicartdev/o/nftAssets%2F0bb0267f-d5e4-4266-9499-987e2c910451_250x250?alt=media",
          fileName: "nft relysia",
          notes: "max notes text length allowed 100K"
    }
}
const response = await relysia.upload(parameters);
```


# Conversion

Get to know how many Satoshis are how much balance in any fiat currency

{% embed url="<https://share.synthesia.io/6e1d4a19-f011-4f18-bc25-d35b908cf935>" %}

#### Currency Conversion

Since users often interact in their wallet with fiat currency denominations, while the wallet infrastructure takes Satoshis as base unit of account, we created the currency conversion function. Convert your Satoshi Balance in any FIAT currency of choice (e.g. USD).

```javascript
var parameters = {
    satoshis: 'required',
    currency: 'required',
}
const response = await relysia.currencyConversion(parameters);
```

## Converts BSV satoshis to fiat currency.

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/currencyConversion`

Add a satoshi amount and fiat pair of your choice, e.g. USD, EUR, INR to receive information of the equivalent value.

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| satoshis | string |             |
| currency | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation Completed Successfully",
    "currency": "USD",
    "balance": 0.000047492999999999994
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
The currency conversion rate gets updated every 10 minutes.&#x20;
{% endhint %}


# Paymail

Customize your paymail domain.

Paymail is a alias protocol that let's users pick a easier identifiable address (such as <sato@relysia.com>) and increases computational efficiency due with the peer-to-peer (P2P) approach.

P2P means that instead of the receiver needing to search the blockchain for a incoming transactions (potentially among billions), the receiver gets directly the transaction bundle which the receiver then submits to the miners and to instantly get a payment confirmation.&#x20;

To add your own paymail domain to your dedicated server (with a serviceID), you need to append to the your-domain.com/.well-known/bsvalias path the following json file.

```
{"bsvalias":"1.0","capabilities":{"6745385c3fc0":false,"pki":"https://api.relysia.com/v1/bsvalias/id/{alias}@{domain.tld}","paymentDestination":"https://api.relysia.com/v1/bsvalias/address/{alias}@{domain.tld}","a9f510c16bde":"https://api.relysia.com/v1/bsvalias/verifypubkey/{alias}@{domain.tld}/{pubkey}","5f1323cddf31":"https://api.relysia.com/v1/bsvalias/receive-transaction/{alias}@{domain.tld}","2a40af698840":"https://api.relysia.com/v1/bsvalias/p2p-payment-destination/{alias}@{domain.tld}"}}
```

you find examples of the entry at all major wallets, including <https://relysia.com/.well-known/bsvalias>. Once you added the entry to your domain & set up the serviceId with given domain, your paymail will be active.&#x20;

## Get paymail Id details

<mark style="color:blue;">`GET`</mark> `https://api.relysia.com/v1/paymail/:paymailId`

Get a paymail account details.

#### Path Parameters

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| paymailId<mark style="color:red;">\*</mark> | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Operation successful",
    "paymailDetails": {
      "walletID": "ec4ae905-c5ef-41bd-adfb-4db361093245",
      "paymailId": "1325@relysia.com"
    }
  }
}
```

{% endtab %}
{% endtabs %}

you can change your paymail to any of your personalized choice, but each paymail should be unique so before setting your personalized paymail we will check if already not exists in our system.

## Update paymail

<mark style="color:orange;">`PUT`</mark> `https://api.relysia.com/v1/paymail`

Set a paymail to your personalized choice

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

#### Request Body

| Name                                           | Type   | Description |
| ---------------------------------------------- | ------ | ----------- |
| newPaymailId<mark style="color:red;">\*</mark> | string |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "operation completed successfully !",
    "paymail": "new-personalized-paymail@relysia.com"
  }
}
```

{% endtab %}
{% endtabs %}

## Activate/Deactivate paymail

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/paymail/activate`

If you want to change your paymail status you can use this endpoint

#### Headers

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| walletID | string |             |

#### Request Body

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| activate | boolean |             |

{% tabs %}
{% tab title="200: OK Activate paymail" %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "paymail activated now"
  }
}
```

{% endtab %}

{% tab title="200: OK Deactivate paymail" %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "paymail deactivated now"
  }
}
```

{% endtab %}
{% endtabs %}


# Transpile-Compile

#### Transpile

This endpoint is use to convert solidity script into sCrypt. We need to pass base64 version of solidity script and in response we will get sCrypt script.

## Transpile solidity code to sCrypt.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/transpile`

Takes base64 string of solidity code and converts it to sCrypt.

#### Headers

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| force | boolean |             |

#### Request Body

| Name                                         | Type   | Description               |
| -------------------------------------------- | ------ | ------------------------- |
| sourceCode<mark style="color:red;">\*</mark> | string | base64 of solidity script |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Transpiled successfully",
    "scrypt": "contract Counter {\n  @state\n  public int count;\n\n  public function get(int retVal, SigHashPreimage txPreimage) {\n    require(this.count == retVal);\n    require(this.propagateState(txPreimage, SigHash.value(txPreimage)));\n  }\n\n  public function inc(SigHashPreimage txPreimage) {\n    this.count += 1;\n    require(this.propagateState(txPreimage, SigHash.value(txPreimage)));\n  }\n\n  public function dec(SigHashPreimage txPreimage) {\n    this.count -= 1;\n    require(this.propagateState(txPreimage, SigHash.value(txPreimage)));\n  }\n\n  function propagateState(SigHashPreimage txPreimage, int value) : bool {\n    require(Tx.checkPreimage(txPreimage));\n    bytes outputScript = this.getStateScript();\n    bytes output = Utils.buildOutput(outputScript, value);\n    return hash256(output) == SigHash.hashOutputs(txPreimage);\n  }\n}",
    "errorLogs": []
  }
}
```

{% endtab %}
{% endtabs %}

#### Compile

This endpoint is use to convert sCrypt script into bitcoin script. We need to pass base64 version of sCrypt script and in response we will get bitcoin script.

## Compile sCrypt code to Bitcoin Script.

<mark style="color:green;">`POST`</mark> `https://api.relysia.com/v1/compile`

Takes base64 string of sCrypt code and converts it to Bitcoin Script.

#### Request Body

| Name                                         | Type   | Description             |
| -------------------------------------------- | ------ | ----------------------- |
| sourceCode<mark style="color:red;">\*</mark> | string | base64 of sCrypt script |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "statusCode": 200,
  "data": {
    "status": "success",
    "msg": "Complied successfully",
    "scrypt": "OP_1 40 97dfd76851bf465e8f715593b217714858bbe9570ff3bd5e33840a34e20ff026 02ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382 1008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c $count $__codePart__ OP_7 OP_PICK OP_NOP OP_0 OP_PICK 68 OP_SPLIT OP_NIP OP_NOP OP_0 OP_0 OP_2 OP_PICK OP_1 OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_0 OP_PICK fd OP_EQUAL OP_IF OP_3 OP_PICK OP_3 OP_SPLIT OP_DROP OP_1 OP_SPLIT OP_NIP OP_NOP OP_0 OP_PICK 00 OP_CAT OP_BIN2NUM OP_1 OP_ROLL OP_DROP OP_NOP OP_3 OP_ROLL OP_DROP OP_2 OP_ROLL OP_2 OP_ROLL OP_3 OP_PICK OP_3 OP_4 OP_PICK OP_ADD OP_SPLIT OP_DROP OP_3 OP_SPLIT OP_NIP OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_ELSE OP_0 OP_PICK fe OP_EQUAL OP_IF OP_3 OP_PICK OP_5 OP_SPLIT OP_DROP OP_1 OP_SPLIT OP_NIP OP_NOP OP_0 OP_PICK 00 OP_CAT OP_BIN2NUM OP_1 OP_ROLL OP_DROP OP_NOP OP_3 OP_ROLL OP_DROP OP_2 OP_ROLL OP_2 OP_ROLL OP_3 OP_PICK OP_5 OP_4 OP_PICK OP_ADD OP_SPLIT OP_DROP OP_5 OP_SPLIT OP_NIP OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_ELSE OP_0 OP_PICK ff OP_EQUAL OP_IF OP_3 OP_PICK OP_9 OP_SPLIT OP_DROP OP_1 OP_SPLIT OP_NIP OP_NOP OP_0 OP_PICK 00 OP_CAT OP_BIN2NUM OP_1 OP_ROLL OP_DROP OP_NOP OP_3 OP_ROLL OP_DROP OP_2 OP_ROLL OP_2 OP_ROLL OP_3 OP_PICK OP_9 OP_4 OP_PICK OP_ADD OP_SPLIT OP_DROP OP_9 OP_SPLIT OP_NIP OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_ELSE OP_3 OP_PICK OP_1 OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_NOP OP_0 OP_PICK 00 OP_CAT OP_BIN2NUM OP_1 OP_ROLL OP_DROP OP_NOP OP_3 OP_ROLL OP_DROP OP_2 OP_ROLL OP_2 OP_ROLL OP_3 OP_PICK OP_1 OP_4 OP_PICK OP_ADD OP_SPLIT OP_DROP OP_1 OP_SPLIT OP_NIP OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_ENDIF OP_ENDIF OP_ENDIF OP_1 OP_PICK OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_1 OP_ROLL OP_DROP OP_NOP OP_0 OP_PICK OP_NOP OP_0 OP_PICK OP_SIZE OP_NIP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_SUB OP_SPLIT OP_DROP OP_1 OP_PICK OP_4 OP_SUB OP_1 OP_SUB OP_SPLIT OP_NIP OP_0 OP_PICK OP_BIN2NUM OP_2 OP_PICK OP_1 OP_PICK OP_SUB OP_4 OP_SUB OP_1 OP_SUB OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_SPLIT OP_DROP OP_3 OP_ROLL OP_DROP OP_2 OP_ROLL OP_2 OP_ROLL OP_0 OP_0 OP_3 OP_PICK OP_3 OP_PICK OP_SPLIT OP_NIP OP_NOP OP_0 OP_PICK OP_3 OP_ROLL OP_DROP OP_2 OP_ROLL OP_2 OP_ROLL OP_0 OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_ADD OP_SPLIT OP_DROP OP_1 OP_PICK OP_SPLIT OP_NIP OP_1 OP_PICK OP_DUP OP_1ADD OP_3 OP_ROLL OP_DROP OP_2 OP_ROLL OP_2 OP_ROLL OP_DROP 00 OP_1 OP_PICK OP_EQUAL OP_NOT OP_1 OP_ROLL OP_DROP OP_NOP OP_0 OP_PICK OP_NOT OP_IF OP_NOP OP_NOP OP_0 OP_3 OP_PICK OP_0 OP_1 OP_PICK OP_5 OP_PICK OP_1 OP_ADD OP_SPLIT OP_DROP OP_5 OP_PICK OP_SPLIT OP_NIP OP_BIN2NUM OP_5 OP_PICK OP_DUP OP_1ADD OP_7 OP_ROLL OP_DROP OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_DROP OP_0 OP_PICK 4c OP_LESSTHAN OP_IF OP_0 OP_PICK OP_4 OP_ROLL OP_DROP OP_3 OP_ROLL OP_3 OP_ROLL OP_3 OP_ROLL OP_2 OP_PICK OP_6 OP_PICK OP_5 OP_PICK OP_ADD OP_SPLIT OP_DROP OP_6 OP_PICK OP_SPLIT OP_NIP OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_ELSE OP_0 OP_PICK 4c OP_NUMEQUAL OP_IF OP_2 OP_PICK OP_6 OP_PICK OP_1 OP_ADD OP_SPLIT OP_DROP OP_6 OP_PICK OP_SPLIT OP_NIP OP_NOP OP_0 OP_PICK 00 OP_CAT OP_BIN2NUM OP_1 OP_ROLL OP_DROP OP_NOP OP_4 OP_ROLL OP_DROP OP_3 OP_ROLL OP_3 OP_ROLL OP_3 OP_ROLL OP_5 OP_PICK OP_1 OP_ADD OP_6 OP_ROLL OP_DROP OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_PICK OP_DROP OP_2 OP_PICK OP_6 OP_PICK OP_5 OP_PICK OP_ADD OP_SPLIT OP_DROP OP_6 OP_PICK OP_SPLIT OP_NIP OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_ELSE OP_0 OP_PICK 4d OP_NUMEQUAL OP_IF OP_2 OP_PICK OP_6 OP_PICK OP_2 OP_ADD OP_SPLIT OP_DROP OP_6 OP_PICK OP_SPLIT OP_NIP OP_NOP OP_0 OP_PICK 00 OP_CAT OP_BIN2NUM OP_1 OP_ROLL OP_DROP OP_NOP OP_4 OP_ROLL OP_DROP OP_3 OP_ROLL OP_3 OP_ROLL OP_3 OP_ROLL OP_5 OP_PICK OP_2 OP_ADD OP_6 OP_ROLL OP_DROP OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_PICK OP_DROP OP_2 OP_PICK OP_6 OP_PICK OP_5 OP_PICK OP_ADD OP_SPLIT OP_DROP OP_6 OP_PICK OP_SPLIT OP_NIP OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_ELSE OP_0 OP_PICK 4e OP_NUMEQUAL OP_IF OP_2 OP_PICK OP_6 OP_PICK OP_4 OP_ADD OP_SPLIT OP_DROP OP_6 OP_PICK OP_SPLIT OP_NIP OP_NOP OP_0 OP_PICK 00 OP_CAT OP_BIN2NUM OP_1 OP_ROLL OP_DROP OP_NOP OP_4 OP_ROLL OP_DROP OP_3 OP_ROLL OP_3 OP_ROLL OP_3 OP_ROLL OP_5 OP_PICK OP_4 OP_ADD OP_6 OP_ROLL OP_DROP OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_PICK OP_DROP OP_2 OP_PICK OP_6 OP_PICK OP_5 OP_PICK OP_ADD OP_SPLIT OP_DROP OP_6 OP_PICK OP_SPLIT OP_NIP OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_ELSE OP_0 OP_VERIFY OP_ENDIF OP_ENDIF OP_ENDIF OP_ENDIF OP_5 OP_PICK OP_4 OP_PICK OP_ADD OP_6 OP_ROLL OP_DROP OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_ROLL OP_5 OP_PICK OP_DROP OP_1 OP_PICK OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_BIN2NUM OP_NOP OP_7 OP_ROLL OP_DROP OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_ENDIF OP_6 OP_PICK OP_1 OP_ADD OP_7 OP_ROLL OP_DROP OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_ROLL OP_6 OP_PICK OP_DROP OP_12 OP_PICK OP_NOP OP_0 OP_PICK OP_NOP OP_0 OP_PICK OP_12 OP_PICK OP_12 OP_PICK 0ac407f0e4bd44bfc207355a778b046225a7068fc59ee7eda43ad905aadbffc800 6c266b30e6a1319c66dc401e5bd6b432ba49688eecd118297041da8074ce0810 OP_14 OP_PICK 13 OP_PICK 13 OP_PICK OP_OR OP_NOP OP_6 OP_PICK OP_HASH256 OP_0 OP_PICK OP_NOP OP_0 OP_PICK OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT 00 OP_CAT OP_BIN2NUM OP_1 OP_ROLL OP_DROP OP_NOP OP_7 OP_PICK OP_6 OP_PICK OP_6 OP_PICK OP_6 OP_PICK OP_6 OP_PICK OP_NOP OP_3 OP_PICK OP_6 OP_PICK OP_4 OP_PICK OP_7 OP_PICK OP_MUL OP_ADD OP_MUL 414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff00 OP_1 OP_PICK OP_1 OP_PICK OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_MOD OP_0 OP_PICK OP_0 OP_LESSTHAN OP_IF OP_0 OP_PICK OP_2 OP_PICK OP_ADD OP_ELSE OP_0 OP_PICK OP_ENDIF OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_1 OP_PICK OP_1 OP_PICK OP_2 OP_DIV OP_GREATERTHAN OP_IF OP_0 OP_PICK OP_2 OP_PICK OP_SUB OP_2 OP_ROLL OP_DROP OP_1 OP_ROLL OP_ENDIF OP_3 OP_PICK OP_SIZE OP_NIP OP_2 OP_PICK OP_SIZE OP_NIP OP_3 OP_PICK 20 OP_NUM2BIN OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_1 OP_SPLIT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT 20 OP_2 OP_PICK OP_SUB OP_SPLIT OP_NIP OP_4 OP_3 OP_PICK OP_ADD OP_2 OP_PICK OP_ADD 30 OP_1 OP_PICK OP_CAT OP_2 OP_CAT OP_4 OP_PICK OP_CAT OP_8 OP_PICK OP_CAT OP_2 OP_CAT OP_3 OP_PICK OP_CAT OP_2 OP_PICK OP_CAT OP_7 OP_PICK OP_CAT OP_0 OP_PICK OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_0 OP_PICK OP_7 OP_PICK OP_CHECKSIG OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_1 OP_ROLL OP_DROP OP_NOP OP_VERIFY OP_NOP OP_0 OP_NOP OP_0 OP_PICK OP_IF OP_1 OP_ELSE 00 OP_ENDIF OP_1 OP_ROLL OP_DROP OP_NOP OP_8 OP_PICK OP_NOP OP_0 OP_PICK OP_0 OP_NUMEQUAL OP_IF 00 OP_ELSE OP_0 OP_PICK OP_ENDIF OP_NOP OP_0 OP_PICK OP_SIZE OP_NIP OP_0 OP_1 OP_PICK 4c OP_LESSTHAN OP_IF OP_1 OP_PICK OP_1 OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_ADD OP_NUM2BIN OP_0 OP_PICK OP_1 OP_PICK OP_SIZE OP_NIP OP_1 OP_SUB OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_1 OP_ROLL OP_DROP OP_ELSE OP_1 OP_PICK 0001 OP_LESSTHAN OP_IF 4c OP_2 OP_PICK OP_1 OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_ADD OP_NUM2BIN OP_0 OP_PICK OP_1 OP_PICK OP_SIZE OP_NIP OP_1 OP_SUB OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_CAT OP_1 OP_ROLL OP_DROP OP_ELSE OP_1 OP_PICK 000001 OP_LESSTHAN OP_IF 4d OP_2 OP_PICK OP_2 OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_ADD OP_NUM2BIN OP_0 OP_PICK OP_1 OP_PICK OP_SIZE OP_NIP OP_1 OP_SUB OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_CAT OP_1 OP_ROLL OP_DROP OP_ELSE OP_1 OP_PICK 0000000001 OP_LESSTHAN OP_IF 4e OP_2 OP_PICK OP_4 OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_ADD OP_NUM2BIN OP_0 OP_PICK OP_1 OP_PICK OP_SIZE OP_NIP OP_1 OP_SUB OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_CAT OP_1 OP_ROLL OP_DROP OP_ELSE OP_0 OP_VERIFY OP_ENDIF OP_ENDIF OP_ENDIF OP_ENDIF OP_0 OP_PICK OP_3 OP_PICK OP_CAT OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_1 OP_ROLL OP_DROP OP_NOP OP_CAT OP_7 OP_PICK OP_1 OP_PICK OP_NOP OP_0 OP_PICK OP_SIZE OP_NIP OP_4 OP_NUM2BIN OP_1 OP_PICK OP_1 OP_PICK OP_CAT OP_0 OP_1 OP_NUM2BIN OP_CAT OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_CAT OP_1 OP_ROLL OP_DROP OP_NOP OP_0 OP_PICK OP_2 OP_PICK OP_NOP OP_0 OP_PICK OP_NOP OP_0 OP_PICK OP_SIZE OP_NIP OP_1 OP_PICK OP_1 OP_PICK 2c OP_SUB OP_SPLIT OP_DROP OP_1 OP_PICK 34 OP_SUB OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_NOP OP_0 OP_PICK 00 OP_CAT OP_BIN2NUM OP_1 OP_ROLL OP_DROP OP_NOP OP_1 OP_ROLL OP_DROP OP_NOP OP_NOP OP_0 OP_PICK OP_8 OP_NUM2BIN OP_2 OP_PICK OP_NOP OP_0 OP_PICK OP_SIZE OP_NIP OP_0 OP_1 OP_PICK fd00 OP_LESSTHAN OP_IF OP_1 OP_PICK OP_1 OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_ADD OP_NUM2BIN OP_0 OP_PICK OP_1 OP_PICK OP_SIZE OP_NIP OP_1 OP_SUB OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_1 OP_ROLL OP_DROP OP_ELSE OP_1 OP_PICK 000001 OP_LESSTHAN OP_IF fd OP_2 OP_PICK OP_2 OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_ADD OP_NUM2BIN OP_0 OP_PICK OP_1 OP_PICK OP_SIZE OP_NIP OP_1 OP_SUB OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_CAT OP_1 OP_ROLL OP_DROP OP_ELSE OP_1 OP_PICK 0000000001 OP_LESSTHAN OP_IF fe OP_2 OP_PICK OP_4 OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_ADD OP_NUM2BIN OP_0 OP_PICK OP_1 OP_PICK OP_SIZE OP_NIP OP_1 OP_SUB OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_CAT OP_1 OP_ROLL OP_DROP OP_ELSE OP_1 OP_PICK 000000000000000001 OP_LESSTHAN OP_IF ff OP_2 OP_PICK OP_8 OP_NOP OP_1 OP_PICK OP_1 OP_PICK OP_1 OP_ADD OP_NUM2BIN OP_0 OP_PICK OP_1 OP_PICK OP_SIZE OP_NIP OP_1 OP_SUB OP_SPLIT OP_DROP OP_0 OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_CAT OP_1 OP_ROLL OP_DROP OP_ENDIF OP_ENDIF OP_ENDIF OP_ENDIF OP_0 OP_PICK OP_3 OP_PICK OP_CAT OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_CAT OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_0 OP_PICK OP_HASH256 OP_3 OP_PICK OP_NOP OP_0 OP_PICK OP_SIZE OP_NIP OP_1 OP_PICK OP_1 OP_PICK OP_8 OP_SUB OP_SPLIT OP_DROP OP_1 OP_PICK 28 OP_SUB OP_SPLIT OP_NIP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_EQUAL OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_1 OP_ROLL OP_DROP OP_NOP OP_NIP OP_NIP OP_NIP OP_NIP OP_NIP OP_NIP OP_NIP OP_NIP OP_NIP OP_NIP OP_NIP OP_NIP OP_NIP "
  }
}
```

{% endtab %}
{% endtabs %}


# Overview

The Relysia Enterprise Wallet

<figure><img src="https://1860373586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ml6s5BMmWoDc9jHH2VT%2Fuploads%2F3OkbZmfeWs5gli43BKxZ%2Fimage.png?alt=media&amp;token=a973f0fb-2f41-496f-806a-d207c990653e" alt=""><figcaption><p>https://enterprise.relysia.com</p></figcaption></figure>

Enterprise wallets have special needs in terms of user management, rights and endpoint functionalities. Most notably, next to role management, enterprise clients require 2 factor authentication to run the wallet infrastructure reliably.&#x20;

We created a proxy server infrastructure in the dedicated serviceId servers to ensure all requirement are matched while keeping otherwise the same API intrastructure. Primary idea is that the dedicated google cloud server can run cloud functions that ensure the integrity of user permission rights while still providing all flexibility beyond those rights.&#x20;

{% hint style="info" %}
If you already have your dedicated serviceId and are interested in running the Relysia enterprise wallet, contact us and we set it all up.
{% endhint %}


# Authentication

Obtaining an authorization token

Authentication allows all types of users to obtain an Auth id\_token, which can then be utilized as an Authorization Bearer token for users with defined roles, including administrators.&#x20;

This authToken serves as proof of a user's authentication and can be used to authorize access to protected resources

#### Login

Login API allows users to securely authenticate and retrieve their Auth Token and User Role.&#x20;

The endpoint accepts HTTP POST requests and expects the following headers:

* `serviceId` (required): The unique identifier for each project.

and JSON payload with the following parameters:

* `email` (required): The email of the user.
* `password` (required): The password of the user.

```bash
curl --location --request POST 'https://api.enterprise.relysia.com/api/v1/login' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email":"test@change.com",
    "password":"password"
}
```

Upon successful authentication, the Login API returns a JSON response with the following parameters:

* token : The Auth Token used for authorization.
* role : The role of the authenticated user.


# Management

Create and manage users

#### Create User

Admins have the ability to create multiple users and assign their roles within the system.

The available user roles include:

* Manager
* Viewer
* Operator
* Api User
* Admin

By assigning the appropriate role to each user, the admin can ensure that the operations within the system are performed efficiently and securely.

```bash
curl --location --request POST 'https://api.enterprise.relysia.com/api/v1/createUser' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email":"test@change.com",
    "password":"password",
    "role":"manager",
    "firstName":"John",
    "lastName":"Doe",
    "title":"Frontend Manager"
}'
```

Upon successful creation of a user, the following information will be included in the response:

* Status: The status of the user creation process.
* UID (User ID): This unique identifier will be used as part of the authentication process.
* Email: The email address associated with the user account.
* Role: The assigned role for the user.

#### Update User

This API allows Admins to change the role of an existing user, identified by their User ID.

As an Admin, you can modify the role of a user and ensure that their access rights align with your organization's needs.

```bash
curl --location --request POST 'https://api.enterprise.relysia.com/api/v1/updateUser' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--data-raw '{
    "userId":"userId",
    "role":"manager",
    "firstName":"John",
    "lastName":"Doe",
    "title":"Frontend Manager"
}'
```

If the update is successful, the API will return a success status response along with the updated user details.

#### Delete User

This API endpoint allows Admins to delete an existing user from the system, identified by their User ID.

To delete a user, you must provide the userId in the request body:

```bash
curl --location --request POST 'https://api.enterprise.relysia.com/api/v1/deleteUser' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--data-raw '{
    "userId":"userId"
}'
```

Upon successful execution, the specified user will be removed from the system and will no longer have access to the API or the wallet.


# Wallet

Manage your enterprise wallet with all the necessary tools and resources.

#### Balance

The Balance Endpoint allows users to check the balance of their enterprise wallet. The following user roles have access to this feature:

* Admin
* Manager
* Viewer
* Operator.

{% tabs %}
{% tab title="Standard " %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/balance' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
```

{% endtab %}

{% tab title="With Subwallet" %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/balance' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--header 'walletID: yourWalletID'
```

{% endtab %}
{% endtabs %}

On success, the API returns a JSON object with the totalBalance and token coins list.

#### Mnemonic

The mnemonic phrase is a critical component in securing your enterprise wallet's keys. Each mnemonic acts as the seed of a Hierarchical Deterministic (HD) Private Key, which contains hundreds of individual Private Keys. Only users with the Admin role are able to access this feature.

{% tabs %}
{% tab title="Standard " %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/mnemonic' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
```

{% endtab %}

{% tab title="With Subwallet" %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/mnemonic' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--header 'walletID: yourWalletID'
```

{% endtab %}
{% endtabs %}

On success, the API returns a JSON object with the Bip39 formatted mnemonic key.

#### Address

An essential feature of every wallet is the wallet address, which can be either a ***classical bitcoin address*** or the more modern ***paymail alias*** address. To ensure privacy for the user, each API call will return a different classical address. &#x20;

{% tabs %}
{% tab title="Standard " %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/address' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
```

{% endtab %}

{% tab title="With Subwallet" %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/address' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--header 'walletID: yourWalletID'
```

{% endtab %}
{% endtabs %}

#### All Wallet Addresses

In case your application requires fetching all available addresses, use the addresses API. This might be useful if you want to manage your own address usage flow.&#x20;

{% tabs %}
{% tab title="Standard " %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/addresses' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
```

{% endtab %}

{% tab title="With Subwallet" %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/addresses' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--header 'walletID: yourWalletID'
```

{% endtab %}
{% endtabs %}

Upon successful execution, the API will return an array of up to 20 available addresses.

#### Retrieve All Wallets

If you create multiple wallets, you can fetch the IDs of each wallet via /wallets.

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/wallets' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
```

{% hint style="info" %}
you can add the walletID header to each request to execute commands on the specific wallets. You can Retrieve walletId's from /wallets.
{% endhint %}

#### Wallet History

The History Endpoint allows users to retrieve the transaction history of their enterprise wallet. It is a GET request and requires the following parameters in the headers:

* authToken
* serviceID

Additionally, it requires the nextPageToken in the headers, which is used to keep track of the current page of transactions.

{% tabs %}
{% tab title="Standard " %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/history' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'nextPageToken: nextPageToken' \
--header 'Content-Type: application/json' \
```

{% endtab %}

{% tab title="With Subwallet" %}

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/history' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'nextPageToken: nextPageToken' \
--header 'Content-Type: application/json' \
--header 'walletID: yourWalletID'
```

{% endtab %}
{% endtabs %}

On success, the following information will be included in the response:

* status: The status of the user creation process.
* histories: A list of transactions.
* meta: Includes the nextPageToken for retrieving subsequent data.

#### Update Paymail

This API allows users to update their Paymail address using a `PUT` request method. Users can easily customize their Enterprise wallet Paymail address and ensure that it reflects their branding and identity.

{% tabs %}
{% tab title="Standard " %}

```
curl --location --request PUT 'https://api.enterprise.relysia.com/api/v1/paymail' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
-d '{"newPaymailId":"paymail@domain.com"}'
```

{% endtab %}

{% tab title="With Subwallet" %}

```
curl --location --request PUT 'https://api.enterprise.relysia.com/api/v1/paymail' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--header 'walletID: yourWalletID' \
-d '{"newPaymailId":"paymail@domain.com"}'
```

{% endtab %}
{% endtabs %}


# Smart Contracts

Token and Smart Contract Management

#### Issue

Mint a token with given specifications (can be both token or NFT). Only users having a manager or admin role can access this endpoint.

```
curl --location --request POST 'https://api.enterprise.relysia.com/api/v1/issue' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'reminting: false' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "Store Bonus Points",
  "protocolId": "STAS",
  "symbol": "SBP",
  "description": "A supermarket bonus point.",
  "image": "https://upload.wikimedia.org/wikipedia/en/9/95/Test_image.jpg",
  "tokenSupply": 3,
  "decimals": 0,
  "satsPerToken": 1500,
  "properties": {
    "legal": {
      "terms": "Your token terms and description.",
      "licenceId": "T3ST-2"
    },
    "issuer": {
      "organisation": "Vaionex Corp.",
      "legalForm": "Limited",
      "governingLaw": "US",
      "issuerCountry": "US",
      "jurisdiction": "US",
      "email": "info@vaionex.com"
    },
    "meta": {
      "schemaId": "NFT1.0/MA",
      "website": "vaionex.com",
      "legal": {
        "terms": "© 2020 TAAL TECHNOLOGIES SEZC\nALL RIGHTS RESERVED. ANY USE OF THIS SOFTWARE IS SUBJECT TO TERMS AND CONDITIONS OF LICENSE. USE OF THIS SOFTWARE WITHOUT LICENSE CONSTITUTES INFRINGEMENT OF INTELLECTUAL PROPERTY. FOR LICENSE DETAILS OF THE SOFTWARE, PLEASE REFER TO: www.taal.com/stas-token-license-agreement"
      },
      "media": [
        {
          "URI": "string",
          "type": "string",
          "altURI": "string"
        }
      ]
    }
  },
  "splitable": true
}'
```

#### Redeem

The Redeem Token Endpoint allows users to redeem their tokens and dissolve the underlying smart contract in exchange for satoshis. Only users having a manager or admin roles can access this endpoint.

The request body is a JSON object that contains an array of data items, each representing a single redemption request. Each data item in the array should contain the following properties:

* "amount": The amount of tokens to be redeemed, represented as a positive integer.
* "tokenId": The identifier of the token to be redeemed, represented as a string.
* "sn": The serial number of the token to be redeemed, represented as a positive integer.

<pre><code>curl --location --request POST 'https://api.enterprise.relysia.com/api/v1/redeem' \
<strong>--header 'authToken: authToken' \
</strong>--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--data-raw '
{
  "dataArray": [
    {
      "amount": 1,
      "tokenId": "tokenId",
      "sn": 0
    }
  ]
}'
</code></pre>

#### Get token details

The Token Details API is a GET request endpoint that returns detailed information about a specific token. This API can be accessed by all authorized users.

The API endpoint is a URL that consists of the base URL followed by the token Id in the format ':id'.

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/token:id' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
```


# Transaction

Allows users with limited roles to do transections by using following endpoints

#### Send

Create transactions to peers using the /send endpoint. This endpoint can send either Tokens or BSV and is accessible by users with the following roles:

* admin
* operator&#x20;
* manager

```
curl --location --request POST 'https://api.enterprise.relysia.com/api/v1/send' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
--data-raw '{
  "dataArray": [
    {
      "to":"address",
      "amount": "amount in number",
      "type": "BSV"
    }
  ]
}'
```


# Fee Manager

The fee manager to injects the fee into blockchain operations.

The Fee Manager APIs enable efficient management of the enterprise fee manager and are restricted to users with either admin or manager roles.

#### initBeta

Creates a new Fee Manager that can cover the transaction fees of your users.

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/initBeta' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
```

#### feeMetricsBeta

The endpoint returns all UTXOs and refreshes the UTXO state.&#x20;

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/feeMetricsBeta' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
```

#### feeAddressBeta

Returns a list of feeManager addresses. The feeManager is used to fund transactions.&#x20;

```
curl --location --request GET 'https://api.enterprise.relysia.com/api/v1/feeAddressBeta' \
--header 'authToken: authToken' \
--header 'serviceid: serviceid' \
--header 'Content-Type: application/json' \
```


# Events

Real time transaction notification

To create a client application that receives real-time notifications for transactions (BSV, Token, and NFT), we will use the socket.io-client package. This document provides a step-by-step guide for implementing this functionality.

#### Step 1: User Authentication

The first step is to authenticate the user by making a request to the "/v1/login" endpoint. This is a necessary step to ensure that only authorized users can receive transaction notifications.

#### Step 2: Event Listening

The next step is to set up the client application to listen for specific events in order to receive relevant messages and data. The following events can be listened for:

* "notification": To receive transactional notifications.
* "balance": To receive updates on balance changes.
* "history": To receive updates on history changes.

Here is an example of how to implement event listening in your client application:

```
const { io } = require('socket.io-client')
            
const relysiaEndpoint = 'https://api.enterprise.relysia.com/';

(async () => {
    // Connect websocket for this account
    const socket = io(relysiaEndpoint, {
        auth: {
            serviceid: serviceid
            authToken: token
        }
    });

    socket.on('error', function(error) {
        console.log("Connection Error: " + error.toString());
    });

    // Listen for message and log them as notification arrive
    socket.on('notification', function (message) {
        console.log('Notification received:', message);
    })

    // Listen for balance and log them on balance arrive
    socket.on('balance', function (balance) {
        console.log('Balance update received:', balance);
    })

    // Listen for history and log them on history arrive
    socket.on('history', function (history) {
        console.log('History update received:', history);
    })
    
    socket.on('connect', function(connection) {
        console.log('WebSocket Client Connected');
        socket.on('close', function() {
            console.log('Connection Closed');
        });
    });
})()
```


# Use Case

Real time transaction notification

Client Application will get Real-time notification for any transaction (BSV, Token, and NFT)

The client application will perform any type of transaction using Relysia transaction APIs (<https://docs.relysia.com/payments/transactions>)\
\
Client WebSocket listener will get real-time notifications for the transaction details.


# Setup and Configuration

Prerequisites and Setup

We require two packages to create a simple client application to receive notifications:\
1\. [socket.io-client](https://www.npmjs.com/package/socket.io-client) (For connectivity)\
2\. HTTP [client-library](https://www.npmjs.com/package/axios) (For HTTP sending requests)

A typical simple application to get notification enabled is as depicted below.\
It's a two-step process.

1. Authentication (/v1/auth) user
2. Listen the specific event to receive relevant message\data\
   -Listen for event the "**notification**" to receive transactional notifications\
   -Listen for event the "**balance**" to receive balance changes\
   -Listen for event the "**history**" to receive history changes

```
const axios = require('axios').default;
const { io } = require('socket.io-client')
            
const relysiaEndpoint = 'api.relysia.com';

(async () => {
    // Login into account
    const loginObject = await axios.post(`https://${relysiaEndpoint}/v1/auth`, {email: "user@abc.com", password: "password"});
    console.log('Login completed', loginObject.data);
    // Connect websocket for this account
    const socket = io(`wss://${relysiaEndpoint}`, {
        extraHeaders: {
            authToken: loginObject.data.data.token,
        },    
        transports: ['websocket', 'polling']
    });

    socket.on('error', function(error) {
        console.log("Connection Error: " + error.toString());
    });

     // Listen for message and log them as notification arrive
    socket.on('notification', function (message) {
        console.log('event received', message);
    })

    // listen for balance and log them on balance arrive
    socket.on('balance', function (balance) {
        console.log('event received', balance);
    })

    // listen for history and log them on history arrive
    socket.on('history', function (history) {
        console.log('event received', history);
    })
    
    

    socket.on('connect', function(connection) {
        console.log('WebSocket Client Connected');
        socket.on('close', function() {
            console.log('echo-protocol Connection Closed');
        });
    });
})()
```


# Events and Messages

Details about events and respective messages

<table><thead><tr><th>Event Name</th><th>description</th><th>Message data</th><th data-hidden>Message Data</th><th data-hidden></th></tr></thead><tbody><tr><td>notification:global</td><td>In this user will get all transaction notification which is happening on Relysia Infrastructure.</td><td>{ amount, type, timestamp, txid, sender, receiver, tokenId }</td><td></td><td></td></tr><tr><td>notification</td><td>In this event. The user, who is connected with socket he will get only his wallet transaction notification.</td><td>{ amount, type, timestamp, txid, sender, receiver, tokenId }</td><td>{ amount, type, timestamp, txid, sender, receiver, tokenId }</td><td></td></tr><tr><td>notification:wallet:{walletId}</td><td>in this event user will get only his specified walletId transaction notification</td><td>{ amount, type, timestamp, txid, sender, receiver, tokenId }</td><td></td><td></td></tr><tr><td>balance</td><td>The user, who is connected with socket he will get only his wallet balance.</td><td>{ walletId, totalBalance, coins }</td><td>{ walletId, totalBalance, coins }</td><td></td></tr><tr><td>history</td><td>The user, who is connected with socket he will get only his wallet history.</td><td>{ walletId, histories }</td><td>{ walletId, histories }</td><td></td></tr></tbody></table>


# Metashard

Scalable blockchains are ideal to store immutable data. Immutability implies that you can write data to the blockchain, but you verifiably not change the data, thus making it ideal to store registry entries (such as land ownership) or certificates where authenticity is essential. While the blockchain itself does not enforce authenticity, the incentive of creating a forgery diminishes when you know to get caught eventually. Moreover, in the case of landownership it presents a case of verifying whether 3rd parties have claims to the same land, which is only possible with public and open databases such as the Bitcoin SV blockchain.&#x20;

Metashard is a SaaS platform users can register and manage their shards. A shard is a sub database with specified files in it. Since we are a blockchain database solution, we naturally acquire our data from the blockchain (see post and [upload](/utility/upload)). To not need to query the whole blockchain each time a user wants to get access to their required data, we let users pre-define the data transaction they want to keep track off. Metashard then makes sure to automatically sort all transactions of that identifier into the users shard for rapid access.&#x20;

![https://metashard.com](https://1860373586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ml6s5BMmWoDc9jHH2VT%2Fuploads%2FkCc9G7TXN3g3M35PVsM0%2Fimage.png?alt=media\&token=ffa522a2-5875-4a03-823d-121e404b56a2)

Comparing costs and performance, Metashard is significantly more resource efficient than solutions that crawl the whole database on each request.&#x20;

{% hint style="success" %}
Metashard is a extension of the Relysia Infrastructure that complements especially the /post endpoint. Give it a try at <https://metashard.com>.
{% endhint %}


# Satolearn

The leading BSV learning platfor

The Relysia infrastructure APIs makes blockchain coding easy, but sometimes its good to really understand whats happening under the hood. We created Satolearn to interactively learn about the blockchain essentials and specifics such as key management, transactions smart contracts and more.

![https://satolearn.com](https://1860373586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ml6s5BMmWoDc9jHH2VT%2Fuploads%2FKfsyrbwPiRb3ZWKMNtF3%2Fimage.png?alt=media\&token=a9c7a4cc-a26e-4487-80e6-f207ef770f2c)

A core feature is the interactivity of learning with Satolearn. Students are guided with interactive coding and mentor videos to learn each concept. At the end of the classes, students receive Satolearn certificates for each class to showcase their learning success to the world.

![Satolearn interactive Videos](https://1860373586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ml6s5BMmWoDc9jHH2VT%2Fuploads%2FReqpFCIJCkzEjgDXliFJ%2Fimage.png?alt=media\&token=971eeb59-397a-44af-abcc-d65083ccf22e)

So don't miss any time and just give it a try - its free! <https://satolearn.com>


