Establish a Connection
After detecting the provider, an application can request to connect to Starkey. This connection request will prompt the user to grant permission to share their public key, signaling their willingness to engage further. Users must approve the connection request before the app can proceed with additional actions, such as signing a message or sending a transaction.
Once permission is granted for the first time, the web application's domain will be whitelisted for future connection requests. After a connection is established, either the application or the user can choose to terminate the connection.
Connecting
To connect to Starkey by default, you can call the window.starkey
function.
The connect
method will return a Promise
. If it resolves, it returns an array where the connected address is in the 0th
index. If the user declines the request or closes the pop-up, it will reject (throw when awaited).
Once the web application is connected to StarKey, it will be able to read the connected account's address and prompt the user for additional transactions. It also exposes a convenience account
method.
Disconnecting
Once a user has established a connection, StarKey will add the website they opened a connection with to a list of apps. The user can then revoke access through the UI at any time, and will need to reconnect.
To disconnect StarKey from dApp, you can call the disconnect
method.
Changing Accounts
StarKey allows users to seamlessly manage multiple accounts (i.e., addresses) from within a single extension or mobile app. Whenever a user switches accounts, StarKey will emit an accountChanged
event.
If a user changes accounts while already connected to an application, and the new account had already whitelisted that application, then the user will stay connected and StarKey will pass the public key of the new account.
Last updated