# BTC Bitget Wallet API

This feature is supported by the following versions of Bitget Wallet.

Platform Version Description
Chrome Extension >=v2.1.1 mainnet
App(IOS) >= 7.3.9 mainnet
App(Android) >= 7.3.9 mainnet

Note

Some methods may have exceptions and will be supported in new versions

Platform Version function
Chrome Extension >=v2.2.0 getBalance, getInscriptions, pushTx
App(IOS) >= 8.8.0 getBalance, getInscriptions, pushTx
App(Android) >= 8.8.0 getBalance, getInscriptions, pushTx

# Detect the BTC

const isBitKeepInstalled = !!(window.bitkeep && window.bitkeep.unisat);
1

# requestAccounts

Connecting to Bitget Wallet

Parameters:

  • none

Returns:

  • Promise returns string[]: Address of current account.
try {
  let accounts = await unisat.requestAccounts();
  console.log('connect success', accounts);
} catch (e) {
  console.log('connect failed');
}
> connect success ['tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz']
1
2
3
4
5
6
7

# getAccounts

Get address of current account

Parameters:

  • none

Returns:

  • Promise - string: Address of current account.
try {
  let res = await unisat.getAccounts();
  console.log(res)
} catch (e) {
  console.log(e);
}
> ["tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz"]
1
2
3
4
5
6
7

# getNetwork

Get address of current account

Parameters:

  • none

Returns:

  • Promise - string: the network. livenet and testnet
try {
  let res = await unisat.getNetwork();
  console.log(res)
} catch (e) {
  console.log(e);
}
> 'livenet'
1
2
3
4
5
6
7

# switchNetwork

switch network

Parameters:

  • network - string: the network. livenet and testnet

Returns

  • none
try {
  let res = await unisat.switchNetwork("livenet");
  console.log(res)
} catch (e) {
  console.log(e);
}
> 'livenet'
1
2
3
4
5
6
7
8

# getPublicKey

Get publicKey of current account.

Parameters:

  • none

Returns:

  • Promise - string: publicKey
try {
  let res = await unisat.getPublicKey();
  console.log(res)
} catch (e) {
  console.log(e);
}
> "03cbaedc26f03fd3ba02fc936f338e980c9e2172c5e23128877ed46827e935296f"
1
2
3
4
5
6
7

# getBalance

Get BTC balance

Parameters:

  • none

Returns:

  • Promise - Object
    • confirmed - number : the confirmed satoshis
    • unconfirmed - numbet: the unconfirmed satoshis
    • total - number: the total satoshis
try {
  let res = await unisat.getBalance();
  console.log(res)
} catch (e) {
  console.log(e);
}
> {
    "confirmed":0,
    "unconfirmed":100000,
    "total":100000
  }
1
2
3
4
5
6
7
8
9
10
11
12

# getInscriptions

List inscriptions of current account

Parameters:

  • none

Returns:

  • Promise - Object
    • total - number : the total count
    • list - Object[] :
    • inscriptionId - string : the id of inscription.
    • inscriptionNumber - string : the number of inscription.
    • address - string : the address of inscription.
    • outputValue - string : the output value of inscription.
    • content - string : the content url of inscription.
    • contentLength - string : : the content length of inscription.
    • contentType - number : the content type of inscription.
    • preview - number : the preview link
    • timestamp - number : the blocktime of inscription.
    • offset - number : the offset of inscription.
    • genesisTransaction - string : the txid of genesis transaction
    • location - string : the txid and vout of current location
try {
  let res = await unisat.getInscriptions(0,10);
  console.log(res)
} catch (e) {
  console.log(e);
}
> {
  "total":10,
  "list":[
    {
      inscriptionId: '6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531i0',
      inscriptionNumber: 959941,
      address: 'bc1q8h8s4zd9y0lkrx334aqnj4ykqs220ss735a3gh',
      outputValue: 546,
      preview: 'https://ordinals.com/preview/6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531i0',
      content: 'https://ordinals.com/content/6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531i0',
      contentLength: 53,
      contentType: 'text/plain;charset=utf-8',
      timestamp: 1680865285,
      genesisTransaction: '6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531',
      location: '6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531:0:0',
      output: '6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531:0',
      offset: 0
    }
  ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

# sendBitcoin

Send BTC

Parameters:

  • toAddress - to: the address to send
  • satoshis - the satoshis to send
  • options - object: (optional)
    • feeRate - number: the network fee rate

Returns:

  • Promise - string: the txid
try {
  let txid = await unisat.sendBitcoin("tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz",1000);
  console.log(txid)
} catch (e) {
  console.log(e);
}
1
2
3
4
5
6

# sendInscription

Send Inscription

Parameters:

  • address - string: the receiver address.
  • inscriptionId - the id of Inscription
  • options - Object: (optional)
  • feeRate - number: the network fee rate

Returns:

  • Promise - Object:
    • txid - string : the txid
try {
  let { txid } = await unisat.sendInscription("tb1q8h8s4zd9y0lkrx334aqnj4ykqs220ss7mjxzny","e9b86a063d78cc8a1ed17d291703bcc95bcd521e087ab0c7f1621c9c607def1ai0",{feeRate:15});
  console.log("send Inscription 204 to tb1q8h8s4zd9y0lkrx334aqnj4ykqs220ss7mjxzny",{txid})
} catch (e) {
  console.log(e);
}
1
2
3
4
5
6

# signMessage

sign message

Parameters:

  • msg - string: a string to sign

Returns:

  • Promise - string: the signature result.
// sign by ecdsa
try {
  let res = await unisat.signMessage("abcdefghijk123456789");
  console.log(res)
} catch (e) {
  console.log(e);
}
> G+LrYa7T5dUMDgQduAErw+i6ebK4GqTXYVWIDM+snYk7Yc6LdPitmaqM6j+iJOeID1CsMXOJFpVopvPiHBdulkE=
1
2
3
4
5
6
7
8
9

# pushTx

Push Transaction

Parameters

  • options - Object:
    • rawtx - string: rawtx to push

Returns:

  • Promise - string: the txid
try {
  let txid = await unisat.pushTx({
    rawtx:"0200000000010135bd7d..."
  });
  console.log(txid)
} catch (e) {
  console.log(e);
}
1
2
3
4
5
6
7
8

# signPsbt

Sign PSBT This method will traverse all inputs that match the current address to sign.

Parameters:

  • psbtHex - string: the hex string of psbt to sign

Returns:

  • Promise - string: the hex string of signed psbt
try {
  let res = await unisat.signPsbt("70736274ff01007d....");
  console.log(res)
} catch (e) {
  console.log(e);
}
1
2
3
4
5
6
7

# signPsbts

Sign Multiple PSBTs at once This method will traverse all inputs that match the current address to sign.

Parameters:

  • psbtHexs - string[]: the hex strings of psbt to sign

Returns:

  • Promise - string[]: the hex strings of signed psbt
try {
  let res = await unisat.signPsbts(["70736274ff01007d...","70736274ff01007d..."]);
  console.log(res)
} catch (e) {
  console.log(e);
}
1
2
3
4
5
6
7

# pushPsbt

Push transaction

Parameters:

  • psbtHex - string: the hex string of psbt to push

Returns:

  • Promise - string: the txid
try {
  let res = await unisat.pushPsbt("70736274ff01007d....");
  console.log(res)
} catch (e) {
  console.log(e);
}
1
2
3
4
5
6
7
Last Updated: 11/9/2023, 2:11:08 PM