@ledgerhq/ledger-wagmi-connector
is a connector for the popular
wagmi library based on the Ledger Connect Kit,
@ledgerhq/connect-kit.
It can be used to add a Ledger button to your DApp.
Here is an example of a wagmi client using the Ledger wagmi connector.
import { configureChains, defaultChains } from 'wagmi';
import { publicProvider } from 'wagmi/providers/public';
import { LedgerConnector } from '@ledgerhq/ledger-wagmi-connector';
// Configure chains for connectors to support
const { chains } = configureChains(defaultChains, [
publicProvider()
]);
// Set up connectors
export const connectors = {
ledger: new LedgerConnector({
chains,
options: {
enableDebugLogs: false,
// passed to WalletConnect
chainId: 1,
// specify if no rpc, passed to WalletConnect
infuraId: 'YOUR_INFURA_ID',
// specify chain:URL if no infuraId, passed to WalletConnect
rpc: {
1: 'https://cloudflare-eth.com/', // Mainnet
137: 'https://polygon-rpc.com/', // Polygon
}
}
}),
};
You need to have a recent Node.js and pnpm installed.
pnpm install
Build the Connector
pnpm build
Check code quality with
pnpm lint
Have a look at the wagmi repo and the wagmi doc to learn more on connectors and wagmi.