Browser Wallet
For connecting, queries and performs wallet functions in accordance to CIP-30.
These wallets APIs are in accordance to CIP-30, which defines the API for dApps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building dApps.
In this section, you can connect wallet and try APIs for dApps to communicate with your wallet.
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:
With NuFi's support, you can specify the network to connect to. By default, it is set to "preprod". To define the network
:
Available networks are:
- production: https://wallet.nu.fi
- mainnet: https://wallet-staging.nu.fi
- preprod: https://wallet-testnet-staging.nu.fi
- preview: https://wallet-preview-staging.nu.fi
You can also specify the network by providing the URL:
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 dApp 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
Returns a list of assets in the wallet. This API will return every assets in the wallet. Each asset is an object with the following properties:
- A unit is provided to display asset's name on the user interface.
- A quantity is provided to display asset's quantity on the user interface.
Example:
Get all assets in the connected wallet
Connect wallet to run this demo
Get Change Address
Returns an address owned by the wallet that should be used as a change address to return leftover assets during transaction creation back to the connected wallet.
Get address that should be used for transaction's change
Connect wallet to run this demo
Get Collateral
This function shall return a list of one or more UTXOs (unspent transaction outputs) controlled by the wallet that are required to reach AT LEAST the combined ADA value target specified in amount AND the best suitable to be used as collateral inputs for transactions with plutus script inputs (pure ADA-only UTXOs).
If this cannot be attained, an error message with an explanation of the blocking problem shall be returned. NOTE: wallets are free to return UTXOs that add up to a greater total ADA value than requested in the amount parameter, but wallets must never return any result where UTXOs would sum up to a smaller total ADA value, instead in a case like that an error message must be returned.
Example of a response returned by this endpoint:
Get list of UTXOs that used as collateral inputs for transactions with plutus script inputs
Connect wallet to run this demo
Get Network ID
Returns the network ID of the currently connected account. 0
is testnet and 1
is mainnet but other networks can possibly be returned by wallets. Those other network ID values are not governed by CIP-30. This result will stay the same unless the connected account has changed.
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
As wallets should already have this ability to submit transaction, we allow dApps to request that a transaction be sent through it. If the wallet accepts the transaction and tries to send it, it shall return the transaction ID for the dApp to track. The wallet can return error messages or failure if there was an error in sending it.
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
Return the lovelace balance in wallet. 1 ADA = 1000000 lovelace.
Get amount of ADA in connected wallet
Connect wallet to run this demo
Get Policy IDs
Return a list of assets' policy ID. An example response would be:
Get a list of policy IDs from all assets in wallet
Connect wallet to run this demo
Get a Collection of Assets
Returns a list of assets from a policy ID. If no assets in wallet belongs to the policy ID, an empty list is returned. Query for a list of assets' policy ID with 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
Get a list of CIP-30 extensions that have been enabled by the connected wallet.
Example:
Get a list of CIPs that are supported by the connected wallet
Connect wallet to run this demo
Get DRep ID Key
Get the key, hash, and bech32 encoding of the DRep ID. The DRep ID is a unique identifier for the user's wallet.
Example:
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