Skip to content

HarmonicLabs/cardano-wallet-connect-solidjs-component

Repository files navigation

cardano-wallet-connect-solidjs-component

cardano-wallet-connect-solidjs-component

pnpm

cardano-wallet-connect-solidjs-component

Quick start

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;

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published