Bitcoin Dapps Integration
Welcome to Coin98 Extension Wallet Developer Guide. This documentation contains guides for developers to get started developing on Coin98 Extension Wallet.
To detect Coin98 Extension with Bitcoin
To detect whether your browser is running Coin98 Extension, please use:
Connecting to Coin98 Wallet
"Connecting" or "logging in" to Coin98 Wallet effectively means "to access the user's Bitcoin account(s)".
You should only initiate a connection request in response to 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 Coin98 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 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
sendBitcoin
Send BTC
Parameters
toAddress
-string
: the address to sendsatoshis
-number
: the satoshis to sendoptions
-object
: (optional)feeRate
-number
: the network fee rate
Returns
Promise
-string
: txid
Example
signMessage
sign message
Parameters
msg
-string
: a string to signtype
-string
: (Optional) "ecdsa" | "bip322-simple". default is "ecdsa"
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 signoptions
autoFinalized
-boolean
: whether finalize psbt after signing, default is truetoSignInputs
-array
:index
-number
: which input to signaddress
-string
: (at least specify either an address or a publicKey) Which corresponding private key to use for signingpublicKey
-string
: (at least specify either an address or a publicKey) Which corresponding private key to use for signingsighashTypes
-number[]
: (optionals) sighashTypes
Returns
Promise
-string
: the hex string of signed psbt
Example
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 signoptions
-object
[]: the options of signing psbtautoFinalized
-boolean
: whether finalize psbt after signing, default is truetoSignInputs
-array
:index
-number
: which input to signaddress
-string
: (at least specify either an address or a publicKey) Which corresponding private key to use for signingpublicKey
-string
: (at least specify either an address or a publicKey) Which corresponding private key to use for signingsighashTypes
-number[]
: (optionals) sighashTypes
Returns
Promise
-string[]
: the hex strings 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