@ledgerhq/ledger-wagmi-connector
is a connector for the popular
wagmi library based on the Ledger Connect Kit,
@ledgerhq/connect-kit.
This connector can be used to add a Ledger button to your DApp. Have a look at the Ledger developer portal for more information on Connect Kit and the Ledger button.
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';
const { chains } = configureChains(defaultChains, [
publicProvider()
]);
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 yarn installed.
yarn install
Build the Connector
yarn build
Check code quality with
yarn lint
Have a look at the wagmi repo and the wagmi doc to learn more on connectors and wagmi.