GoSat Wallet API
GoSat Wallet API
Welcome to GoSat's Developer Documentation. This documentation is for learning to develop applications for GoSat Wallet.
Getting Started
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.
Browser Detection
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 to GoSat Wallet
"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:
Methods
requestAccounts
Connect the current account.
Parameters
none
Returns
Promise
returns string[]
: Address of current account.
Example
getAccounts
Get address of current account
Parameters
none
Returns
Promise
-string
: address of current account
Example
getNetwork
get network
Parameters
none
Returns
Promise
-string
: the network.livenet
andtestnet
Example
switchNetwork
switch network
Parameters
network
-string
: the network.livenet
andtestnet
Returns
none
Example
getPublicKey
Get publicKey of the current account.
Parameters
none
Returns
Promise
-string
: publicKey
Example
getBalance
Get BTC balance
Parameters
none
Returns
Promise
-Object
:confirmed
-number
: the confirmed satoshisunconfirmed
-number
: the unconfirmed satoshistotal
-number
: the total satoshis
Example
getInscriptions
List inscriptions of current account
Parameters
none
Returns
Promise
-Object
:total
-number
: the total countlist
-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 linktimestamp
-number
: the blocktime of inscription.offset
-number
: the offset of inscription.genesisTransaction
-string
: the txid of genesis transactionlocation
-string
: the txid and vout of current location
Example
sendBitcoin
Send BTC
Parameters
toAddress
-string
: the address to sendsatoshis
-number
: the satoshis to sendoptions
-object
:feeRate
-number
: the network fee rate
Returns
Promise
-string
: txid
Example
sendInscription
Send Inscription
Parameters
options
-Object
:id
-string
: the id of Inscription.address
-string
: the receiver address.
Returns
Promise
-Object
:txid
-string
: the txid
Example
signMessage
sign message
Parameters
msg
-string
: a string to sign
Returns
Promise
-string
: the signature.
Example
pushTx
Push Transaction
Parameters
options
-Object
:rawtx
-string
: rawtx to push
Returns
Promise
-string
: txid
Example
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
Example
pushPsbt
Push transaction
Parameters
psbtHex
-string
: the hex string of psbt to push
Returns
Promise
-string
: txid
Example
Events
accountsChanged
The accountsChanged
will be emitted whenever the user's exposed account address changes.
networkChanged
The networkChanged
will be emitted whenever the user's network changes.
Last updated