@apophis-sdk/keplr-signer
v0.1.0-alpha.2
Published
[Keplr](https://keplr.app) integration for the [Apophis Cosmos SDK](../../README.md).
Downloads
165
Readme
@apophis-sdk/keplr-signer
Keplr integration for the Apophis Cosmos SDK.
Installation
Install with your favorite package manager's equivalent of:
npm install @apophis-sdk/core @apophis-sdk/walletconnect-signer
You will likely also want to install a frontend integration such as @apophis-sdk/preact.
Usage
Using a proper frontend integration, usage is simple:
import { Any, signals, signers, type Asset, type NetworkConfig } from '@apophis-sdk/core';
import { WalletModal } from '@apophis-sdk/preact';
import { KeplrDirect } from '@apophis-sdk/keplr-signer';
import { render } from 'preact';
signers.push(KeplrDirect);
const assets: Record<string, Asset> = /* your assets here */;
const network: Record<string, NetworkConfig> = /* your network config here */;
const networks = Object.values(network);
signals.network.value ??= /* your network config here */;
// render a `WalletSelector` or `WalletModal`
render((
<div>
<UserAddress />
{!signals.account.value && <WalletModal />}
<button onClick={handleClick}>Click me!</button>
</div>
), document.getElementById('app')!);
function handleClick() {
if (!signals.signer.value || !signals.network.value) return;
const network = signals.network.value;
const signer = signals.signer.value; // agnostic of signer implementation
const tx = signer.tx([
Any.encode(/* your message here */),
]);
await tx.estimateGas(network, signer, true);
await tx.sign(network, signer);
await tx.broadcast(); // signer & network are stored internally when signed successfully
}