Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sats Connect kit #87

Merged
merged 29 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
eef91d6
init WalletProvider Wrapper
m-aboelenein Mar 20, 2024
115787e
Sort wallet providers
aryzing Mar 20, 2024
3745d73
Add provider management methods
aryzing Mar 20, 2024
1aa0a34
Remove unused icons
aryzing Mar 20, 2024
4ec4f45
update walletProvider implementation
m-aboelenein Mar 21, 2024
dfa7e80
added example app and refactor WalletProvider class
m-aboelenein Mar 21, 2024
4ff8a91
update test app code
m-aboelenein Mar 22, 2024
d0d249a
cleanup + update WalletProvider methods
m-aboelenein Mar 26, 2024
8fe2d10
Update types
aryzing Mar 26, 2024
c156725
default to base adapter if no adapter was found
m-aboelenein Mar 26, 2024
8357210
Move default selector config to core
aryzing Mar 26, 2024
3867b78
use published packages
m-aboelenein Mar 27, 2024
cd90034
Merge remote-tracking branch 'origin/develop' into connect-kit/v0
m-aboelenein Mar 27, 2024
12a1ea9
update provide name and trigger connect modal if first request cancelled
m-aboelenein Mar 27, 2024
103920f
update sats-connect-core and implement wallet action loading
m-aboelenein Mar 28, 2024
642de5d
update example app version
m-aboelenein Mar 28, 2024
0c55d47
cleanup and update readme
m-aboelenein Apr 1, 2024
39b02c0
Handle provider selection cancellation
aryzing Apr 2, 2024
99a776e
Update ui version
aryzing Apr 2, 2024
a46850c
update core version and test-app
m-aboelenein Apr 2, 2024
70ac819
add usage example in readme
m-aboelenein Apr 5, 2024
b360a71
added mint runes example
m-aboelenein Apr 5, 2024
776de00
update core package
m-aboelenein Apr 5, 2024
ebed7a3
update core version
m-aboelenein Apr 5, 2024
88b844d
update core version
m-aboelenein Apr 5, 2024
7a9f737
Merge pull request #91 from secretkeylabs/runes-rpc-methods-support
m-aboelenein Apr 5, 2024
ceb8fab
update core
m-aboelenein Apr 6, 2024
6fbbb18
format readame
m-aboelenein Apr 6, 2024
46b0334
Update dependencies versions
m-aboelenein Apr 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
# Sats Connect
![logo](/example/public/sats-connect.svg)

Sats connect is a simple javascript library that connects apps to Bitcoin wallets like Xverse to retrieve user wallet addresses and sign transactions (PSBTs).

[Read the docs](https://docs.xverse.app/sats-connect/)
Developers building apps on the Bitcoin ecosystem can use Sats connect to interact with users' wallets:

1. Retrieve users' wallet address(es)

2. Request the signature of arbitrary messages for authentication purposes

3. Request the signature of partially signed Bitcoin transactions (PSBT)

4. Request BTC or Stacks transfers to one or multiple recipients

5. Request Stacks contract interactions and deployments

6. Inscribe sats with arbitrary content for ordinals & BRC-20 use cases

## Quick start

```bash
npm i sats-connect
```

## Usage

### import

```ts
import Wallet from 'sats-connect';
```

### Connect Wallet

```ts
const response = await Wallet.request('getAccounts', {
purposes: [AddressPurpose.Payment, AddressPurpose.Ordinals, AddressPurpose.Stacks],
message: 'Cool app wants to know your addresses!',
});
```

### Request a wallet action

```ts
await Wallet.request('sendTransfer', {...});
```

### Disconnect Wallet

```ts
await Wallet.disconnect();
```

## Documentation

For full documentation, visit [docs.xverse.app](https://docs.xverse.app/sats-connect/).
23 changes: 23 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
54 changes: 54 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Using sats-connect and Xverse to build a dapp
=============================================
This is a simple example of how to use the sats-connect library to build a dapp. The dapp is a simple web application that allows users to send and receive btc and stx using the sats-connect library.

The dapp is built in typescript with Create-React-App.

# Installation and running the dapp
To install the node dependencies for the dapp, run the following command:
```bash
npm i
```

To run the dapp, run the following command:
```bash
npm start
```

The dapp should now be reachable in your browser on http://localhost:3001

# Using sats-connect
[Sats-connect](https://github.com/secretkeylabs/sats-connect) is an open source library which allows you to interact with the Xverse wallet from your dapp. The library exposes a `request` function which you can use to send requests to the Xverse wallet. The `request` function takes a `method` and `params` as arguments. The `method` is the name of the method you want to call in the Xverse wallet and the `params` is an object with the parameters typed specifically for the method.

If using typescript, the methods are typed and will come up in the intellisense of your IDE. Once you have typed a specific method, the params will be typed according to that method and will also come up in the intellisense.

The methods are namespaced according to the functionality they provide, with the exception of Bitcoin methods, which live in the global namespace. For example, to create a Bitcoin send transaction you would call `request('sendTransfer', { ... })`. To create a Stacks send transaction you would call `request('stx_transferStx', { ... })`.

The available Bitcoin methods are:

```
getInfo
getAddresses
signMessage
sendTransfer
signPsbt
```

The Stacks methods are:

```
stx_callContract
stx_deployContract
stx_getAccounts
stx_getAddresses
stx_signMessage
stx_signStructuredMessage
stx_signTransaction
stx_transferStx
```

There are also some more specialised methods exposed by sats connect which have not been migrated to the `request` function yet. One of these can be seen in the main App.tsx file, where we use the `getAddresses` method to get both the Bitcoin and Stacks addresses. However, these methods have a different calling convention using callback functions instead of promises.

# Happy Hacking

And buidl on! 🚀
Loading
Loading