IBC
Inter-Blockchain Communication Protocol (IBC) is a blockchain interoperability protocol used by 110+ chains. It enables secure, permissionless, feature-rich cross-chain interactions.
Creating the SDK instance
I'll be using the Stargaze testnet for the examples.
The instance is now connected to the Stargaze testnet and ready to be used.
Connecting your wallet
You can connect your wallet using a mnemonic or a private key as shown below.
When connecting your wallet, you also need to specify the address prefix for your chain and the gas price to be used when creating transactions.
Getting your address
You can get your address using the getAddress
method.
Preparing a transaction
You can prepare a transaction using the preparePay
method.
When creating a transaction, you need to specify the recipient address, the amount to be transferred, and the token denomination.
Preparing multiple transactions
You can prepare multiple transactions using the preparePays
method.
The preparePays
method returns an array of signed transactions ready to be sent to a DEMOS node. The transactions are signed with an incrementing nonce derived from the ledger sequence.
Signing Messages
Verifying signature
Cleaning up
When you're done with the SDK instance, you can disconnect your wallet and RPC connection.
Hacking
You can access the underlying CosmJS objects to have more control over the transactions and interactions with the blockchain.
Here is a list of the objects you can access:
instance.provider
Provides read-only access to blockchain data
instance.wallet
Allows for signing and broadcasting transactions
instance.signer
Manages the private key and signing operations
Example
To get the latest block, you can use the getBlock
method.
API Reference
Last updated