Browser Wallet
For connecting, queries and performs wallet functions in accordance to CIP-30.
BrowserWallet
provides APIs for interacting with browser-based wallets in accordance with CIP-30. This standard defines the communication protocol between applications and user wallets, ensuring compatibility and security.
In addition to the CIP-30 APIs, BrowserWallet
includes utility functions that simplify common tasks such as retrieving wallet balances, signing transactions, and managing UTXOs.
This section allows you to explore and test the available APIs for browser wallets, enabling seamless integration into your applications.
Get Available Wallets
Returns a list of wallets available on user's device. Each wallet is an object with the following properties:
- A name is provided to display wallet's name on the user interface.
- A version is provided to display wallet's version on the user interface.
- An icon is provided to display wallet's icon on the user interface.
Example:
Get a list of wallets on user's device
Connect Wallet
This is the entrypoint to start communication with the user's wallet. The wallet should request the user's permission to connect the web page to the user's wallet, and if permission has been granted, the wallet will be returned and exposing the full API for the app to use.
Query BrowserWallet.getAvailableWallets()
to get a list of available wallets, then provide the wallet name
for which wallet the user would like to connect with.
You can also provide an extensions
object to enable specific CIPs. For example, to enable CIP95, you would pass:
Connect to a CIP30 compatible wallet
Get Balance
This API retrieves a list of all assets in the connected wallet. Each asset is represented as an object containing the following properties:
- Unit: A unique identifier for the asset, which can be used to display its name in the user interface.
- Quantity: The amount of the asset held in the wallet.
This information is useful for applications that need to display wallet balances or perform operations involving specific assets.
Example:
Get all assets in the connected wallet
Connect wallet to run this demo
Get Change Address
This API returns an address owned by the wallet that should be used as a change address. A change address is where leftover assets from a transaction are returned during its creation. This ensures that any unspent assets are sent back to the connected wallet.
Applications can use this API to manage transaction outputs effectively, ensuring proper handling of change during transactions.
Get address that should be used for transaction's change
Connect wallet to run this demo
Get Collateral
This API retrieves a list of UTXOs (unspent transaction outputs) controlled by the wallet that can be used as collateral inputs for transactions involving Plutus scripts. The returned UTXOs must meet or exceed the specified ADA value target.
If the target cannot be met, an error message will be returned explaining the issue. Wallets may return UTXOs with a greater total ADA value than requested but must never return UTXOs with a smaller total value.
This functionality is essential for applications that need to create transactions requiring collateral inputs.
Example response:
Get list of UTXOs that used as collateral inputs for transactions with plutus script inputs
Connect wallet to run this demo
Get Network ID
This API retrieves the network ID of the currently connected account. The network ID indicates the blockchain network the wallet is connected to. For example:
0
: Testnet1
: Mainnet
Other network IDs may be returned by wallets, but these are not governed by CIP-30. The network ID remains consistent unless the connected account changes.
Applications can use this information to ensure compatibility with the connected network.
Get currently connected network
Connect wallet to run this demo
Get Reward Addresses
Returns a list of reward addresses owned by the wallet. A reward address is a stake address that is used to receive rewards from staking, generally starts from `stake` prefix. Example:
Get stake addresses
Connect wallet to run this demo
Get Unused Addresses
Returns a list of unused addresses controlled by the wallet. For example:
Get addresses that are unused
Connect wallet to run this demo
Get Used Addresses
Returns a list of used addresses controlled by the wallet. For example:
Get addresses that are used
Connect wallet to run this demo
Get UTXOs
Return a list of all UTXOs (unspent transaction outputs) controlled by the wallet. For example:
Get UTXOs of the connected wallet
Connect wallet to run this demo
Sign Data
This endpoint utilizes the CIP-8 - Message Signing to sign arbitrary data, to verify the data was signed by the owner of the private key.
signData
takes two arguments, the first one is the payload to sign and the second one is the address (optional).
By default, we get the first wallet's address with wallet.getRewardAddresses()
, alternativelly you can specify the address to use.
Example of a response from the endpoint:
Continue reading this guide to learn how to verify the signature.
Define a payload and sign it with wallet.
Connect wallet to run this demo
Sign Transaction
Requests user to sign the provided transaction (tx
). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign
should be true
if the transaction provided requires multiple signatures.
Create a transaction and sign it
Check out Transaction to learn more on how to use this API.
Submit Transaction
Wallets inherently have the ability to submit transactions. This API allows applications to request the wallet to send a transaction. If the wallet accepts the transaction and successfully sends it, it will return the transaction ID, enabling the application to track its status. In case of errors during submission, the wallet will provide error messages or failure details.
This functionality is useful for applications that need to interact with the blockchain by submitting signed transactions through the user's wallet.
Submit a signed transaction with wallet
Check out Transaction to learn more on how to use this API.
Get Assets
Returns a list of assets in wallet excluding lovelace, example:
Get assets in the connected wallet
Connect wallet to run this demo
Get Lovelace
This API retrieves the Lovelace balance in the connected wallet. Lovelace is the smallest denomination of ADA, where 1 ADA equals 1,000,000 Lovelace.
Applications can use this information to display the wallet's balance or perform operations involving ADA.
Get amount of ADA in connected wallet
Connect wallet to run this demo
Get Policy IDs
This API retrieves a list of policy IDs for all assets in the connected wallet. A policy ID is a unique identifier for a group of assets, often used to manage collections or verify asset ownership.
Applications can use this information to query assets belonging to specific policy IDs or display asset details to the user.
Example response:
Get a list of policy IDs from all assets in wallet
Connect wallet to run this demo
Get a Collection of Assets
This API retrieves a list of assets associated with a specific policy ID. If no assets in the wallet belong to the specified policy ID, an empty list is returned.
Applications can use this API to query assets belonging to a particular policy ID, which is useful for managing collections of assets or verifying ownership.
To obtain a list of all policy IDs in the wallet, use wallet.getPolicyIds()
.
Get a list of assets belonging to the policy ID
Connect wallet to run this demo
Get Supported Extensions
getSupportedExtensions
is a static function that returns a list of CIPs that are supported by a wallet. You can query this function without connecting to a wallet, by providing the wallet name.
You can get the list of wallet on user's device with await BrowserWallet.getAvailableWallets()
.
Get a list of CIPs that are supported by a wallet
Get Extensions
This API retrieves a list of CIP-30 extensions enabled by the connected wallet. CIP-30 extensions define additional capabilities that wallets can support, enhancing their functionality.
Applications can use this information to determine the features supported by the wallet and adapt their behavior accordingly.
Example response:
Get a list of CIPs that are supported by the connected wallet
Connect wallet to run this demo
Get DRep
This API retrieves the key, hash, and bech32 encoding of the DRep ID associated with the wallet. The DRep ID is a unique identifier used for delegation representation in the Cardano blockchain.
Applications can use this information to interact with delegation-related features or display the DRep ID details to the user.
Example response:
Get the key, hash, and bech32 address of the DRep ID
Connect wallet to run this demo
Get Registered Pub Stake Keys
Get a list of registered public stake keys.
Example:
Get a list of registered public stake keys
Connect wallet to run this demo
Get Unregistered Pub Stake Keys
Get a list of unregistered public stake keys.
Get a list of unregistered public stake keys
Connect wallet to run this demo