---
description: Use the following provider api to connect to the Nabox wallet
---

# Provider API

### getAccounts (connect wallet)

```javascript
const res = await NaboxWallet.bitcoin.getAccounts();
// Returns the currently connected account
['bc1pqw2apzlwqdx5cyp.........a5fupu5l0hsl9n7uw'];
```

### requestAccounts (get the currently connected account)

```javascript
const res = await NaboxWallet.bitcoin.requestAccounts();
// Returns the currently connected account
['bc1pqw2apzlwqdx5cyp.........a5fupu5l0hsl9n7uw'];
```

### getNetwork (get the current network, Nabox wallet only supports the main network)

```javascript
const network = await NaboxWallet.bitcoin.getNetwork();
// Returns the currently connected account
livenet
```

### getPublicKey (get the public key of the currently connected account)

```javascript
const pubKey = await NaboxWallet.bitcoin.getPublicKey();

// 037c92dfbdafb4de8f1249c.........6f95146c8233e107879ad
```

### getBalance (get the balance of the currently connected account)

```javascript
const balance = await NaboxWallet.getBalance();

{
  "confirmed":0,
  "unconfirmed":1000,
  "total":1000
}
```

### getInscriptions (get the inscriptions of the currently connected account)

```javascript
const cursor = 0 // Optional，default 0
const size = 10 // Optional，default 20

const res = await NaboxWallet.getBalance(cursor, size);

// Returns the inscription information of the current address
```

### sendBitcoin(sendBitcoin)

```javascript
const toAddress = 'Target address';
const satoshis = '1000'; // sat
const options ={}; // Optional

const txId = await NaboxWallet.bitcoin.sendBitcoin(toAddress, satoshis, options);

// Returns the txId of the transaction
```

```javascript
const message= 'message'; // Signature required messagemessage
const type = 'ecdsa'; // Optional， "ecdsa" | "bip322-simple" default ecdsa

const res = await NaboxWallet.bitcoin.signMessage(message, type);

// Return the signature result
```

### pushTx (push transaction)

```javascript
const rawTx = '0200000000000.....';

const txId = await NaboxWalllet.bitcoin.pushTx(rawTx);

// return txId
```

### signPsbt (signature psbt)

```javascript
const psbtHex = '078282720000...';
const options = {};

const res = await NaboxWalllet.bitcoin.signPsbt(psbtHex, options);

// Returns the signed hex string
```

### signPsbt(signature psbts)

```javascript
const psbtHexs = ['078282720000...', '078282720001...'];
const options = {};

const res = await NaboxWalllet.bitcoin.signPsbt(psbtHexs, options);

// Returns the signed[hex string, hex string1]
```

### pushPsbt (broadcast psbt transaction)

```javascript
const psbtHex = '727592090282902....';

const txId = await NaboxWalllet.bitcoin.pushPsbt(psbtHex);

// Returns the txId after broadcasting
```

### on(Account change monitoring event)

```javascript
NaboxWallet.bitcoin.on('accountsChanged', (accounts) => {
  console.log(accounts);
  // ['bc1pqw2apzlwqdx5cyp.........a5fupu5l0hsl9n7uw']
});
```
