Introduction to Hana's Substrate Provider
Hana Wallet simplifies the integration of Substrate-based dApps by injecting a Substrate provider based on the Polkadot-JS framework. This provider supports all utilities available through the @polkadot/extension-dapp
package, making it easy to leverage Polkadot’s powerful tools within your dApp.
How Hana’s Substrate Provider Works
Polkadot-JS Framework: Hana injects a Substrate provider directly into the webpage, built on the robust Polkadot-JS framework. This allows developers to access all the utilities and features that come with the
@polkadot/extension-dapp
package, enabling seamless integration with Substrate-based blockchains.Utility Support: Hana supports all utilities that are part of the
@polkadot/extension-dapp
package, giving you the flexibility to build advanced dApps with ease. Whether you need to interact with accounts, sign transactions, or access the chain state, Hana has you covered.
Example Code to Integrate with Hana’s Substrate Provider
When integrating Hana with your Substrate-based dApp, especially if you support multiple Substrate wallets, it’s important to identify and use the specific provider for Hana Wallet. Below is an example code snippet to help you get started:
import { web3Enable } from "@polkadot/extension-dapp";
async function enable() {
// Fetch all injected extensions. If you have more than one Substrate wallet
// i.e., Polkadot.JS and Hana Wallet, then both will be returned here const extensions = await web3Enable("My awesome dApp");
// Specifically obtain Hana Wallet provider
const hanaExtension = extensions.find((ext) => ext.name === "hana");
// Get Hana Wallet version
console.debug("hanaExtension version", hanaExtension?.version);
// Example output: 0.1
// Fetch list of accounts from Hana Wallet
hanaExtension?.accounts.subscribe((accounts) => {
console.debug("accounts", accounts);
});
}
Why Use Hana for Your Substrate dApp?
Polkadot-JS Compatibility: By using Hana’s Substrate provider, you gain access to all the tools and utilities provided by the Polkadot-JS framework, ensuring a smooth and powerful integration.
Multi-Wallet Support: Hana easily integrates with other Substrate wallets like Polkadot.JS, allowing developers to support multiple wallet providers within their dApp. This flexibility ensures that users can choose their preferred wallet while still enjoying full functionality.
Advanced Features: Hana’s Substrate provider supports a wide range of advanced features, from account management to transaction signing, making it a comprehensive solution for Substrate-based dApps.
Additional Resources
For more detailed information about the utilities and features available through the Polkadot-JS extension, you can refer to the official documentation here: Polkadot-JS Extension Guide.
Integrating your Substrate-based dApp with Hana Wallet is straightforward and powerful, thanks to Hana’s Substrate provider built on the Polkadot-JS framework. Whether you’re managing accounts or interacting with the blockchain, Hana offers a seamless experience for both developers and users.
Need Help?
If you have any questions or need further assistance, visit our Support Center for more articles and resources, or contact our support team.