
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
@lit-protocol/pkp-ethers.js-node
Advanced tools
https://www.npmjs.com/package/@lit-protocol/pkp-ethers.js
yarn add @lit-protocol/pkp-ethers.js ethers
https://www.npmjs.com/package/@lit-protocol/pkp-ethers.js-node
yarn add @lit-protocol/pkp-ethers.js-node ethers
import { PKPWallet } from "@lit-protocol/pkp-ethers.js";
const PKP_PUBKEY = "{YOUR PKP UNCOMPRESSED PUBLIC KEY}";
const CONTROLLER_AUTHSIG = await LitJsSdk.checkAndSignAuthMessage({
chain: "mumbai",
});
const pkpWallet = new PKPWallet({
pkpPubKey: PKP_PUBKEY,
controllerAuthSig: CONTROLLER_AUTHSIG,
provider: "https://rpc-mumbai.maticvigil.com",
});
await pkpWallet.init();
const tx = {
to: "0x1cD4147AF045AdCADe6eAC4883b9310FD286d95a",
value: 0,
};
// -- Sign Transaction
const signedTx = await pkpWallet.signTransaction(tx);
console.log("signedTx:", signedTx);
// -- Send Transaction
const sentTx = await pkpWallet.sendTransaction(signedTx);
console.log("sentTx:", sentTx);
// -- Sign Message
const signedMsg = await pkpWallet.signMessage("Secret Message.. shh!");
console.log("signedMsg:", signedMsg);
// -- Verify Signed Messaage
const signMsgAddr = ethers.utils.verifyMessage(msg, signedMsg);
// --- (V3) Sign Typed Data
// Example from https://github.com/MetaMask/test-dapp/blob/main/src/index.js#L1033
const msgParamsV3 = {
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
Person: [
{ name: 'name', type: 'string' },
{ name: 'wallet', type: 'address' },
],
Mail: [
{ name: 'from', type: 'Person' },
{ name: 'to', type: 'Person' },
{ name: 'contents', type: 'string' },
],
},
primaryType: 'Mail',
domain: {
name: 'Ether Mail',
version: '1',
chainId: 80001,
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
},
message: {
from: {
name: 'Cow',
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
},
to: {
name: 'Bob',
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
},
contents: 'Hello, Bob!',
},
};
const { types: typesV3, domain: domainV3, primaryType: primaryTypeV3, message: messageV3 } = msgParamsV3;
// Remove EIP712Domain from types as recommended in https://github.com/ethers-io/ethers.js/issues/687
if (typesV3.EIP712Domain) {
delete typesV3.EIP712Domain;
}
const signedTypedDataV3 = await pkpWallet._signTypedData(domainV3, typesV3, messageV3);
const signTypedDataV3Addr = ethers.utils.verifyTypedData(domainV3, typesV3, messageV3, signedTypedDataV3);
console.log('Signed typed data V3 verified?', signTypedDataV3Addr.toLowerCase() === (await pkpWallet.getAddress()).toLowerCase());
// -- (V4) Sign Typed Data
// Example from https://github.com/MetaMask/test-dapp/blob/main/src/index.js#L1155
const msgParamsV4 = {
domain: {
chainId: 80001,
name: 'Ether Mail',
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
version: '1',
},
message: {
contents: 'Hello, Bob!',
from: {
name: 'Cow',
wallets: [
'0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
'0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF',
],
},
to: [
{
name: 'Bob',
wallets: [
'0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
'0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57',
'0xB0B0b0b0b0b0B000000000000000000000000000',
],
},
],
},
primaryType: 'Mail',
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
Mail: [
{ name: 'from', type: 'Person' },
{ name: 'to', type: 'Person[]' },
{ name: 'contents', type: 'string' },
],
Person: [
{ name: 'name', type: 'string' },
{ name: 'wallets', type: 'address[]' },
],
},
};
const { types: typesV4, domain: domainV4, primaryType: primaryTypeV4, message: messageV4 } = msgParamsV4;
// Remove EIP712Domain from types as recommended in https://github.com/ethers-io/ethers.js/issues/687
if (typesV4.EIP712Domain) {
delete typesV4.EIP712Domain;
}
const signedTypedDataV4 = await pkpWallet._signTypedData(domainV4, typesV4, messageV4);
const signTypedDataV4Addr = ethers.utils.verifyTypedData(domainV4, typesV4, messageV4, signedTypedDataV4);
console.log('Signed typed data V4 verified?', signTypedDataV4Addr.toLowerCase() === (await pkpWallet.getAddress()).toLowerCase());
FAQs
PKP Signer for ethers
The npm package @lit-protocol/pkp-ethers.js-node receives a total of 11 weekly downloads. As such, @lit-protocol/pkp-ethers.js-node popularity was classified as not popular.
We found that @lit-protocol/pkp-ethers.js-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.