Head over to the @stacks/connect README.
This repository includes three packages:
@stacks/connect: The one-stop-shop tool for letting web-apps interact with Stacks web wallets.@stacks/connect-ui: A web-component UI for displaying an intro modal in Stacks web-apps during authentication (used in the background by@stacks/connect).@stacks/connect-react: A wrapper library for making@stacks/connectuse in React even easier
Wallets implement a "Provider" interface.
The latest spec uses a simple JS Object exposing a .request(method: string, params?: object) method.
Pseudo-code:
window.MyProvider={asyncrequest(method,params){// Somehow communicate with the wallet (e.g. via events)// Recommendation: Create a JSON RPC 2.0 request object// https://www.jsonrpc.org/specificationreturnPromise.resolve({// Respond with a JSON RPC 2.0 response objectid: crypto.randomUUID(),// required, same as requestjsonrpc: '2.0',// required// `.result` is required on successresult: {// object matching specified RPC methods},// `.error` is required on errorerror: {// Use existing codes from https://www.jsonrpc.org/specification#error_objectcode: number,// required, integermessage: string,// recommended, single sentencedata: object,// optional},});},isMyWallet: true,// optional, a way of identifying the wallet for developers};window.wbip_providers=window.wbip_providers||[];window.wbip_providers.push({// `WbipProvider` type/** The global "path" of the provider (e.g. `"MyProvider"` if registered at `window.MyProvider`) */id: 'MyProvider',/** The name of the provider, as displayed to the user */name: 'My Wallet';/** The data URL of an image to show (e.g. `data:image/png;base64,iVBORw0...`) @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs */icon?: 'data:image/png;base64,iVBORw0...';/** Web URL of the provider */webUrl?: 'https://mywallet.example.com';// Addional URLschromeWebStoreUrl?: string;mozillaAddOnsUrl?: string;googlePlayStoreUrl?: string;iOSAppStoreUrl?: string;});Wallets may add their own unstandardized methods. However, the minimum recommended methods are:
getAddressesWBIPsendTransferWBIPsignPsbtWBIPstx_getAddressesSIP-030stx_transferStxSIP-030stx_callContractSIP-030stx_signMessageSIP-030stx_signStructuredMessageSIP-030
Development of this product happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving the product.
Please read our Code of conduct since we expect project participants to adhere to it.
Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.