Web Wallet dApp Integration
dApps can easily integrate CLV Web Wallet for transaction & message signing. The SDK @clover-network/web-wallet-sdk is needed for the integration.
The SDK can be installed as follows:
yarn add @clover-network/web-wallet-sdkSubstrate Blockchains Integration
CLV web wallet supports dApps on substrate-based blockchains, such as Polkadot, Kusama, Acala, etc. The sample code is as follows:
import CloverWebInjected from '@clover-network/web-wallet-sdk';
import { web3Enable, web3Accounts, web3FromAddress } from "@polkadot/extension-dapp";
const clvInject = new CloverWebInjected({ zIndex: 99999 });
const initInjector = async () => {
await clvInject.init({
network: {
chainId: '0x1',
},
enableLogging: true,
});
await clvInject.polkadotLogin(); // After this success, the injector has been injected into web page
const injected: any = await web3Enable('clv'); // injector could be get in standard way
}
// sign message
const polkadotSignMessage = async () => {
const polkadotAddress = await web3Accounts({ ss58Format: 42 });
const wrapped = u8aWrapBytes(polkadotAddress.toLowerCase());
const ret = await currentInjected.signer.signRaw({
data: u8aToHex(wrapped),
address: polkadotAddress,
type: "bytes",
});
}
// send transaction
polkadotSignTransaction = async () => {
const wsProvider = new WsProvider('wss://rpc.polkadot.io');
const api = await ApiPromise.create({provider: wsProvider});
const polkadotAddress = await web3Accounts({ ss58Format: 42 });
const currentClvAccount = polkadotAddress
const injected = await web3FromAddress(currentClvAccount)
api.setSigner(injected.signer)
const unsub = await api.tx.balances
.transfer(currentClvAccount, 0)
.signAndSend(currentClvAccount, (result) => {
if (result.status.isInBlock) {
// in block
} else if (result.status.isFinalized) {
unsub();
}
})
}
EVM Blockchains Integration
CLV web wallet supports dApps on EVM blockchains, such as Ethereum, CLV Parachain (P-Chain), Moonbeam and etc. The sample code is as follows:
Solana Blockchain Integration
CLV web wallet supports dApps on Solana. The sample code is as follows:
Last updated