Leather Developer API Overview
Introduction
Leather empowers developers to build apps for the Bitcoin and Stacks blockchains. Through the Leather browser extension, you can interact directly with user wallets using simple JavaScript methods. This integration supports Bitcoin-native actions and Stacks smart contract calls—all with secure user approval across desktop and mobile.
Getting Started
Detecting the Provider
In a browser environment, the Leather extension injects a global object into the window. You can detect and use it like this:
This follows the .request
method standard from the Modern Wallet APIs proposal.
Core Methods
getAddresses
: Get Bitcoin (SegWit, Taproot) and Stacks addresses.signMessage
: Sign an arbitrary message with a Bitcoin address.sendTransfer
: Sign and broadcast a Bitcoin transaction.signPsbt
: Sign and broadcast a PSBT.Stacks Libraries
: Interact with Stacks smart contracts and assets.
TypeScript Support
If you're working in a TypeScript environment, Leather provides type definitions via the @leather.io/rpc
package. This package declares LeatherProvider
on the global object and types its available methods and responses for better developer experience.
Installation
You can install the typings package using your preferred package manager:
Once installed, you'll benefit from autocomplete and type checking when interacting with the Leather API in your web app or extension.