Integrate with Slope Wallet on Solana (Extension)
Establishing a Connection
In order to start interacting with Slope you must first establish a connection. This connection request will prompt the user for permission to share their public key, and indicate that they are willing to interact further.
Once permission is established the first time, the web application's domain will be whitelisted for future connection requests. The user may also indicate that they are willing to auto-approve certain transactions from the application as well.
Similarly, it is possible to terminate the connection both on the application and the user side.
Connecting
The easiest way is to create an object of Slope: new window.Slope()
, and then call the method connect()
.
The call will return a promise that will be resolved when the user accepts or declines the connection request, and when the popup is closed. When msg === 'ok'
it means that the user accepted the request.
Alternatively, the more recommended way is to use Solana's official wallet adapter solana-labs/wallet-adapter. This adapter provides a much better API.
Disconnecting
Disconnecting is similar to connecting.
Sending a Transaction
Once the web application is connected to Slope, it can send transactions on behalf of the user, with the user's permission.
In order to send a transaction, the web application must:
Create an unsigned transaction or transactions.
Have it be signed by the user's Slope wallet.
Send it to a Solana node for processing.
Signing a Transaction
Once a transaction is created, the web application may ask the user's Slope wallet to sign the transaction using their account's private key. By far the easiest way of doing this is by using the signTransaction
method on the provider.
Signing Multiple Transactions
It is also possible to sign and send multiple transactions at once. This is exposed through the signAllTransactions
method on the provider.
Signing a Message
When the web application is connected to Slope, it can also request that the user signs a given message.
In order to send a message for the user to sign, the web application must:
Provide a hex or UTF-8 encoded string as a Uint8Array.
Have it be signed by the user's Slope Wallet.
Example of signing a message.
Last updated