cardano-wallet-connect-solidjs-component
Install it:
npm i @harmoniclabs/cardano-wallet-connect-solidjs-component @solid-primitives/storage
# or
yarn add @harmoniclabs/cardano-wallet-connect-solidjs-component @solid-primitives/storage
# or
pnpm add @harmoniclabs/cardano-wallet-connect-solidjs-component @solid-primitives/storage
Use it:
import CardanoWalletConnectComponent from '@harmoniclabs/cardano-wallet-connect-solidjs-component'
Example:
import { createSignal, createEffect } from 'solid-js'
import { makePersisted } from '@solid-primitives/storage';
import { CardanoWalletConnectComponent } from 'cardano-wallet-connect-solidjs-component';
export type WalletInfo = {
walletName: string;
}
function App() {
const [connectedWallet, setConnectedWallet] = makePersisted(createSignal<WalletInfo | null>(null), {
name: 'cardanoWallet',
serialize: JSON.stringify,
deserialize: JSON.parse,
});
async function getWalletAddress() {
const connectedWalletName = connectedWallet()?.walletName;
if (!connectedWalletName) return;
const wallet = await (window as any).cardano[connectedWalletName].enable();
const getUsedAddresses = await wallet.getUsedAddresses();
console.log("getUsedAddresses: ", getUsedAddresses[0]);
}
return (
<div>
<CardanoWalletConnectComponent showName={true}/>
</div>
);
}
export default App;