Yoroi Wallet’s recent announcement of CIP30 integration brought many exciting changes, some of which are extremely relevant to existing decentralized applications (dApps) and dApp developers who wish to integrate Yoroi into their dApp.
Aside from this, there are also many other Yoroi Wallet user experience improvements that have been made.
This technical blog and accompanying video demo (below) will elaborate more on these, including some of the things most relevant to Cardano dApp builders, and how Yoroi’s CIP30 compatibility makes wallet integration significantly easier.
What is CIP30?
A CIP or Cardano Improvement Proposal is a proposed solution to assist in the evolution of the Cardano ecosystem. It is intended to help improve Cardano’s technical development in a transparent manner.
The CIP program was launched in 2019 by the Cardano Foundation to offer a collaborative way for the Cardano community to give feedback, propose solutions, and take on an active, engaging role in improving Cardano’s overall development.
In an effort to make Cardano dApp development simpler, CIP30 was a specific proposal that had been accepted to form a standard for wallet-web bridges, or dApp connectors, to follow for consistency purposes.
This means that dApps can write code that interacts with Yoroi or any CIP30-compatible wallet.
As long as those wallets follow the CIP30 standard, they can allow their users to choose which wallet they would like to connect with their dApp. The code written by the dApp can mostly be reused, since the wallet APIs will have standardized returned messages.
The official list of compatible CIP30 wallets can be found at https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030
Along with the APIs defined by the CIP30 standard, wallets themselves can choose to implement their own functionality. However, this functionality is recommended to be put under an “experimental” tag, so that dApps who wish to, can use them, but understand that it may only be available on that specific wallet.
This means that a dApp that uses an API from a wallet that is not compatible with the CIP-30 standard won’t be able to integrate the rest of the wallets that are compatible with the CIP-30, because using an experimental API is breaking the CIP30 standard and the compatibility between different wallets.
The details of these APIs are given in https://cips.cardano.org/cips/cip30/#transactionunspentoutput
How does CIP30 work?
Yoroi Wallet, or other CIP-30 compatible wallets, will inject JavaScript code into the webpage that can be called by dApps without them worrying about internal implementations. Since the returned values of each function is specified in detail within the CIP30 document, wallets following the standard should return similar values. dApps inherently need to interact with user wallets, as they need to display information about user’s balances, or some functions that may require users to sign transactions.
For the most part, CIP30 includes the minimum APIs necessary to perform the expected dApp connector functionality.
These can then go on to be used in any way the dApp likes, from NFTs and token management, to the interactions with the plethora of smart contracts that exist on Cardano.
A live video demo
For those who would prefer a more succinct method, we have prepared a video explanation of each API.
To view the full video, view it here https://youtu.be/hJntxhdwAI4
Note: The code used to produce the example dApp in the video is available here https://github.com/Emurgo/dapp-connector-web
But even better, we have deployed this demo dApp so you can play in real-time with all of the CIP30 compatibility features and more.
You can find the dApp at https://dapp-connector-web.emurgo-rnd.com/
You will just need to install Yoroi and start to interact with it.
Initial APIs
- These APIs are there so that users can select which wallet they wish to use. For example, they may have wallets on Yoroi, and the dApp can enable the one the user selects.
“`
cardano.{walletName}.enable()
cardano.{walletName}.isEnabled()
cardano.{walletName}.apiVersion
cardano.{walletName}.name
cardano.{walletName}.icon
“`
`{walletName}` will be `yoroi.
#### Full APIs
- Once the wallet is enabled, the dApp should have access to a full set of APIs from the user’s Yoroi Wallet
**Get Network ID**
“`
api.getNetworkId()
“`
- This will return 0 for testnet and 1 for mainnet.
**Get UTXOs**
“`
api.getUtxos(amount: cbor = undefined, paginate: Paginate = undefined)
“`
- Gets UTXOs of the user. UTXO selection should be implemented so that the dApp can call this API with amount and get the required UTXOs. The amount can allow for multi-assets so NFTs/tokens can be included.
- Fix has been deployed to the extension stores so in the next version 4.13.300 getCollateralUtxo will be renamed to getCollateral as it is defined in the CIP-30 standard.
**Get Collateral**
“`
api.getCollateral(params: { amount: cbor })
“`
- dApps can call this API to get good UTXOs to use as collateral for a specific Plutus transaction.
**Get Balance**
“`
api.getBalance()
“`
- This gets the balance of the wallet, including all assets
**Address APIs**
- The following APIs are fairly self-explanatory.
“`
api.getUsedAddresses(paginate: Paginate = undefined)
api.getUnusedAddresses()
“`
- Yoroi and other wallets are implemented so that addresses aren’t repeatedly used for every transaction, so it is useful to keep track of addresses that have been used, and addresses that are still available.
“`
api.getChangeAddress()
“`
- Change addresses are generally generated once per transaction also, the dApp needs to know this address to send change.
“`
api.getRewardAddresses()
“`
The address used to which to send staking rewards.
Note: The dApp is prepared to work on testnet so that one can’t lose funds by accident using a mainnet wallet. Please use a testnet wallet.
Building a dApp on Cardano? Integrate your dApp with Yoroi Wallet
Developed by EMURGO – a founding entity of Cardano blockchain – Yoroi Wallet is an open-source crypto wallet supporting Cardano ADA that provides users with transparency, increased security, and collaboration.
The most recent Yoroi Wallet Google Chrome Desktop Extension, has full compatibility with CIP 30 and we’re inviting dApps to work with us!
Interested in quickly reaching Yoroi Wallet’s large user base of over 750,000 downloads?
Integrate your dApp with Yoroi Wallet and the CIP-30 integrated dApp Connector.
Just complete the form below and our team will reach out soon to start the process.
Form: Fill out with details to integrate your dApp with Yoroi
About Yoroi Wallet
- Yoroi Twitter: @YoroiWallet
- Yoroi Homepage: https://yoroi-wallet.com/
About EMURGO
- Official Homepage: emurgo.io
- Twitter (Global): @EMURGO_io
- YouTube: EMURGO channel
- Discord: EMURGO Community
- Facebook: @EMURGO.io
- Instagram: @EMURGO_io
- LinkedIn: @EMURGO_io
About Fibo
- Fibo Homepage: https://fibo.art
- Fibo Twitter: @fiboNFT
- Fibo Discord: Fibo Community