Connection API

Connection

await window.spika.connect();

This method will prompt user to grant web application permission to access account's address, public key and authentication key.

This method will add application to the whitelist.

Response example
{
    "responseMethod": "connect",
    "id": 4,
    "response": {
        "address": "0x07313c786ae592e2b134ef11a26721e4bf9f46e44139ce3bee35a011a9dea062",
        "publicKey": "0x246149be5064eb9913690c7b2eca963fede52fcbd072d2fbba22f7383e66c0c8",
        "authKey": "0x07313c786ae592e2b134ef11a26721e4bf9f46e44139ce3bee35a011a9dea062"
        }
    }
}

It will return false if:

  • account not initialized yet (e.g. address is not created);

  • user rejected request;

  • error occurred during request

Disconnection

await window.spika.disconnect();

This method will revoke application from the whitelist and return true on success or false if application is not registered.

Response example
{
    "responseMethod": "disconnect",
    "id": 5,
    "response": true
}

Check if connection established

await window.spika.isConnected();

This method will return true if application is whitelisted and return false if not.

Response example
{
    "responseMethod": "isConnected",
    "id": 5,
    "response": true
}

Last updated