GoSat Wallet API
Last updated
Last updated
Welcome to GoSat's Developer Documentation. This documentation is for learning to develop applications for GoSat Wallet.
To develop for GoSat Wallet, install GoSat Wallet on your development machine.
Once GoSat Wallet is installed and running, you should find that new browser tabs have an window.gosat
object available in the developer console. This is how your website will interact with GoSat Wallet.
To verify if the browser is running GoSat Wallet, copy and paste the code snippet below in the developer console of your web browser:
You can review the full API for the window.gosat
object here.
"Connecting" or "logging in" to GoSat Wallet effectively means "to access the user's Bitcoin account(s)".
You should only initiate a connection request in response to a direct user action, such as clicking a button. You should always disable the "connect" button while the connection request is pending. You should never initiate a connection request on page load.
We recommend that you provide a button to allow the user to connect GoSat Wallet to your DAPP. Clicking this button should call the following method:
Connect the current account.
Parameters
none
Returns
Promise
returns string[]
: Address of current account.
Example
Get address of current account
Parameters
none
Returns
Promise
- string
: address of current account
Example
get network
Parameters
none
Returns
Promise
- string
: the network. livenet
and testnet
Example
switch network
Parameters
network
- string
: the network. livenet
and testnet
Returns
none
Example
Get publicKey of the current account.
Parameters
none
Returns
Promise
- string
: publicKey
Example
Get BTC balance
Parameters
none
Returns
Promise
- Object
:
confirmed
- number
: the confirmed satoshis
unconfirmed
- number
: the unconfirmed satoshis
total
- number
: the total satoshis
Example
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
Example
Send BTC
Parameters
toAddress
- string
: the address to send
satoshis
- number
: the satoshis to send
options
- object
:
feeRate
- number
: the network fee rate
Returns
Promise
- string
: txid
Example
Send Inscription
Parameters
options
- Object
:
id
- string
: the id of Inscription.
address
- string
: the receiver address.
Returns
Promise
- Object
:
txid
- string
: the txid
Example
sign message
Parameters
msg
- string
: a string to sign
Returns
Promise
- string
: the signature.
Example
Push Transaction
Parameters
options
- Object
:
rawtx
- string
: rawtx to push
Returns
Promise
- string
: txid
Example
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
Example
Push transaction
Parameters
psbtHex
- string
: the hex string of psbt to push
Returns
Promise
- string
: txid
Example
The accountsChanged
will be emitted whenever the user's exposed account address changes.
The networkChanged
will be emitted whenever the user's network changes.