README
Last updated
Last updated
This package is no longer supported. Please, use the native WalletConnect or HederaWalletConnect.
A JavaScript/TypeScript library for DApps development using Blade Wallet on Hedera Network. Blade Wallet uses the Hedera Signature and Wallet Interface as defined here.
For example usage and testing the below APIs using a Demo App, please go here and setup the app locally:
The hosted version of the Demo App can be used to try out some API calls:
This package is available as a NPM package.
Minimum Hashgraph SDK version 2.16 is needed for this library to work
Also, it is recommended to look through the Hedera documentation.
To interact with the Blade Extension programmatically, instantiate a BladeConnector
object.
It is possible to pass a preferred pairing strategy. By default (ConnectorStrategy.AUTO
), the pairing is handled as follows:
If there is Blade Wallet extension, a wallet user will be asked to select needed accounts;
If there is no Blade Wallet extension, a QR code modal will be shown.
If preferred strategy is extension strategy (ConnectorStrategy.EXTENSION
), the library will throw the error, if the extension was not detected.
If preferred strategy is WalletConnect strategy (ConnectorStrategy.WALLET_CONNECT
), only the QR code modal will be used.
Implementation example:
Implementation example:
To disconnect the session, call .killSession()
method.
Implementation example:
Wallet handshake allows to generate an authentication signature for use on a backend side. It may be useful, when it is important for a backend to make sure, that client user surely has access to a wallet.
Workflow:
Client requests backend for payload to sign, and data to sign with;
Client performs handshake;
Client sends handshake result to backend;
Backend checks signatures.
Implementation example:
Get account ID
To get an account ID, use .getAccountId()
method on the needed signer.
Implementation example:
Get account info
To get detailed info about account, use .getAccountInfo()
method on the needed signer.
Implementation example:
Get account balances
To get info about all the balances of an account, use .getAccountBalance()
method on the needed signer.
Implementation example:
Signing
For signing to be successful, transaction should be actually signed and executed. Some transaction types require premature populating — e.g. TransferTransaction
, TokenCreateTransaction
etc. There are multiple ways to populate and execute transaction. To execute a transaction, you can use the .call()
method, but it is also possible to call the .executeWithSigner()
on a transaction itself.
First approach:
Second approach:
Third approach:
Getting a receipt
It is possible to get a receipt for any executed transaction withing the current network.
Implementation example:
Validation
If there is a need to check transaction validity, .checkTransaction()
method may be useful for that. It checks if node accounts are valid for the current network, and if transaction composed with the account signer, which this method is called on.
Implementation example:
Read the TypeDoc API documentation
This repository is distributed under the terms of the Apache License (Version 2.0). See LICENSE for details.
Method | Description |
---|---|
Method | Description |
---|---|
bladeConnector.createSession(params?: SessionParams)
Create session with Blade Wallet.
bladeConnector.killSession()
Close the session with Blade Wallet.
bladeConnector.getSigners()
Get a list of paired BladeSigner objects.
bladeConnector.onWalletLocked(callback)
Execute a callback when wallet is locked.
bladeConnector.onWalletUnlocked(callback)
Execute a callback when wallet is unlocked.
bladeConnector.onSessionDisconnect(callback)
Execute a callback when a session has been disconnected.
bladeConnector.onSessionExpire(callback)
Execute a callback when a session has expired.
bladeSigner.getAccountId()
Get accountId of the related account.
bladeSigner.getAccountBalance(accountId: AccountId⎮string)
Retrieve account balance by accountId
bladeSigner.getAccountInfo(accountId: AccountId⎮string)
Get information about a Hedera account on the connected network.
bladeSigner.checkTransaction(transaction: Transaction)
Check that a transaction is valid.
bladeSigner.populateTransaction(transaction: Transaction)
Set transaction id and node accounts using the related account.
bladeSigner.call(request: Executable)
Execute a transaction with provider account.
bladeSigner.sign(message: UInt8Array[])
Sign a transaction or a message with the related wallet account.
bladeSigner.signTransaction(transaction: Transaction)
Sign a transaction with the related wallet account.
bladeSigner.getLedgerId()
Ledger Id of the currently connected network.
bladeSigner.getMirrorNetwork()
Get an array of mirror nodes for the current network.
bladeSigner.getNetwork()
Get a map of nodes for the current Hedera network.
bladeSigner.handshake(serverAccountId: string, serverSignature: string, payload: HandshakePayload)
Make secure client-server handshake