keycard-hardhat-provider
v0.1.3
Published
[Hardhat](https://hardhat.org) plugin for integration with a [Keycard hardware wallet](https://keycard.tech).
Readme
keycard-hardhat-provider
Hardhat plugin for integration with a Keycard hardware wallet.
What
This plugin extends the Hardhat provider enabling it to work with a connected Keycard wallet seamlessly.
Installation
pnpm install --save-dev keycard-hardhat-providerAnd add the following statement to your hardhat.config.js:
require('keycard-hardhat-provider');Or, if you are using TypeScript, add this to your hardhat.config.ts:
import 'keycard-hardhat-provider';Tasks
This plugin creates no additional tasks.
Environment extensions
This plugin adds nothing to the Hardhat Runtime Environment.
Provider extensions
The provider supplied by Hardhat will be extended using
extendProvider,
decorating it to be a KeycardProvider. Any successive calls to extendProvider will be added on top of this.
A KeycardProvider knows how to connect and interact with a Keycard wallet
Usage
The only additional step to make this plugin work is to configure it properly through the Hardhat Config. For example,
in your hardhat.config.js:
require('keycard-hardhat-provider');
module.exports = {
networks: {
hardhat: {
keycardAccount: '0xa809931e3b38059adae9bc5455bc567d0509ab92'
}
}
};If you want to use the provider, you could, for example in a task:
task('sign', 'Signs a message', async (_, hre) => {
const message = '0x5417aa2a18a44da0675524453ff108c545382f0d7e26605c56bba47c21b5e979';
const account = '0xa809931e3b38059adae9bc5455bc567d0509ab92';
const signature = await hre.network.provider.request({
method: 'personal_sign',
params: ['0x5417aa2a18a44da0675524453ff108c545382f0d7e26605c56bba47c21b5e979', account]
});
console.log('Signed message', message, 'for Keycard account', account, 'and got', signature);
});