Universe Wallet API
Universe Wallet API
Welcome to Universe Wallet's Developer Documentation. This documentation is for learning to develop applications for Universe Wallet.
Getting Started
To develop for Universe Wallet, install Universe Wallet on your development machine. Download here.
Once Universe Wallet is installed and running, you should find that new browser tabs have a window.tapwallet object available in the developer console. This is how your website will interact with Universe Wallet.
Browser Detection
To verify if the browser is running Universe Wallet, copy and paste the code snippet below in the developer console of your web browser:
Copy
if (typeof window.tapwallet !== 'undefined') {
console.log('Tap Wallet is installed!');
}You can review the full API for the window.tapwallet object here.
Connecting to Universe Wallet
"Connecting" or "logging in" to Universe 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 Tap Wallet to your dapp. Clicking this button should call the following method:
Copy
Methods
requestAccounts
Copy
Connect the current account.
Parameters
none
Returns
Promise returns string[] : Address of current account.
Example
Copy
getAccounts
Copy
Get address of current account
Parameters
none
Returns
Promise-string: address of current account
Example
Copy
getNetwork
Copy
get network
Parameters
none
Returns
Promise-string: the network.livenetandtestnet
Example
Copy
switchNetwork
Copy
switch network
Parameters
network-string: the network.livenetandtestnet
Returns
none
Example
Copy
getPublicKey
Copy
Get publicKey of current account.
Parameters
none
Returns
Promise-string: publicKey
Example
Copy
getBalance
Copy
Get BTC balance
Parameters
none
Returns
Promise-Object:confirmed-number: the confirmed satoshisunconfirmed-number: the unconfirmed satoshistotal-number: the total satoshis
Example
Copy
getInscriptions
Copy
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
Copy
sendBitcoin
Copy
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
Copy
sendInscription
Copy
Send Inscription
Parameters
address-string: the receiver address.inscriptionId-string: the id of Inscriptionoptions-Object: (optional)feeRate-number: the network fee rate
Returns
Promise-Object:txid-string: the txid
Example
Copy
inscribeTransfer
Copy
Inscribe BRC-20 TRANSFER Inscription
Parameters
ticker-string: BRC-20 tickeramount-string: the amount to inscribe
Returns
Promise-void:
Example
Copy
signMessage
Copy
sign message
Parameters
msg-string: a string to signtype-string: (Optional) "ecdsa" | "bip322-simple". default is "ecdsa"
Returns
Promise-string: the signature.
Example
Copy
pushTx
Copy
Push Transaction
Parameters
options-Object:rawtx-string: rawtx to push
Returns
Promise-string: txid
Example
Copy
signPsbt
Copy
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) sighashTypesdisableTweakSigner-boolean:(optionals) When signing and unlocking Taproot addresses, thetweakSigneris used by default for signature generation. Enabling this allows for signing with the original private key.
Returns
Promise-string: the hex string of signed psbt
Example
Copy
signPsbts
Copy
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
Copy
pushPsbt
Copy
Push transaction
Parameters
psbtHex-string: the hex string of psbt to push
Returns
Promise-string: txid
Example
Copy
Events
accountsChanged
Copy
The accountsChanged will be emitted whenever the user's exposed account address changes.
networkChanged
Copy
The networkChanged will be emitted whenever the user's network changes.
Last updated