-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: janniks <[email protected]>
- Loading branch information
Showing
3 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,4 +412,4 @@ interface TransactionResponse { | |
} | ||
``` | ||
|
||
<StacksProviderSection/> | ||
<StacksProviderSection/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## StacksProvider injected variable | ||
|
||
When users have the [Hiro Wallet](https://www.hiro.so/wallet/install-web) extension installed, the extension will inject a global `StacksProvider` variable into the JavaScript context of your web app. This allows your JavaScript code to hook into the extension, and make authentication, transaction and signature requests. `@stacks/connect` automatically detects and uses this global variable for you. | ||
|
||
At the moment, only the Hiro Wallet extension and the Xverse built-in browswer includes a `StacksProvider`, however, ideally more wallets (and mobile wallets) will support this format, so that your app can be compatible with any Stacks wallet that has functionality to embed web applications. | ||
|
||
In your web application, you can check to see if the user has a compatible wallet installed by checking for the presence of `window.StacksProvider`. | ||
|
||
Here is the interface for the `StacksProvider` variable. | ||
|
||
```tsx | ||
interface StacksProvider { | ||
transactionRequest(payload: string): Promise<FinishedTxPayload | SponsoredFinishedTxPayload>; | ||
authenticationRequest(payload: string): Promise<string>; | ||
signatureRequest(payload: string): Promise<SignatureData>; | ||
structuredDataSignatureRequest(payload: string): Promise<SignatureData>; | ||
profileUpdateRequest(payload: string): Promise<PublicProfile>; | ||
getProductInfo: | ||
| undefined | ||
| (() => { | ||
version: string; | ||
name: string; | ||
meta?: { | ||
tag?: string; | ||
commit?: string; | ||
[key: string]: any; | ||
}; | ||
[key: string]: any; | ||
}); | ||
} | ||
``` |