Skip to main content
Version: v3.x.x

Migrating from 3.1.x to 3.2.0

info

Habanero Mainnet and Manzano Testnet are now live. Check out the docs on migration to learn how you can start building on Habanero and Manzano today.

Removed controllerSessionSigs

Instead of receiving the sessionSigs directly, now they will obtain it from the client and its auth context. This way we are unifying that management and using them from a common storage instead of making the user handle it directly. For more information, please check this PR.

The affected entities are the ones that extends the PKPBase class (starting with PKP...), including PKPEthersWallet and PKPClient, etc.

3.1.x or older


const AUTHSIG = {
"sig": "0x...",
"derivedVia": "web3.eth.personal.sign",
"signedMessage": "localhost wants you to sign in with your Ethereum account:\n0x...\n\nHello World\n\nURI: https://localhost/login\nVersion: 1\nChain ID: 1\nNonce: eoeo0dsvyLL2gcHsC\nIssued At: 2023-11-17T15:04:20.324Z\nExpiration Time: 2215-07-14T15:04:20.323Z",
"address": "0x..."
};

const PKP_PUBLIC_KEY = `0x...`;

const sessionKeyPair = client.getSessionKey();
const authNeededCallback = async (params) => {
const response = await client.signSessionKey({
statement: params.statement,
authMethods: [
{
authMethodType: 1,
accessToken: JSON.stringify(AUTHSIG),
},
],
pkpPublicKey: PKP_PUBLIC_KEY,
expiration: params.expiration,
resources: params.resources,
chainId: 1,
});
return response.authSig;
};

const resourceAbilities = [
{
resource: new LitActionResource('*'),
ability: LitAbility.PKPSigning,
},
];

const sessionSigs = await client.getSessionSigs({
chain: 'ethereum',
expiration: new Date(Date.now() + 60_000 * 60).toISOString(),
resourceAbilityRequests: resourceAbilities,
sessionKey: sessionKeyPair,
authNeededCallback,
});

const pkpWallet = new PKPEthersWallet({
pkpPubKey: PKP_PUBLIC_KEY,
controllerSessionSigs: sessionSigs,
controllerAuthMethods: [],
});

await pkpWallet.init();

const signature = await pkpWallet.signMessage(TO_SIGN);

3.2.0


const AUTHSIG = {
"sig": "0x...",
"derivedVia": "web3.eth.personal.sign",
"signedMessage": "localhost wants you to sign in with your Ethereum account:\n0x...\n\nHello World\n\nURI: https://localhost/login\nVersion: 1\nChain ID: 1\nNonce: eoeo0dsvyLL2gcHsC\nIssued At: 2023-11-17T15:04:20.324Z\nExpiration Time: 2215-07-14T15:04:20.323Z",
"address": "0x..."
};

const PKP_PUBLIC_KEY = `0x...`;

const authNeededCallback = async (params) => {
const response = await client.signSessionKey({
statement: params.statement,
authMethods: [
{
authMethodType: 1,
accessToken: JSON.stringify(AUTHSIG),
},
],
pkpPublicKey: PKP_PUBLIC_KEY,
expiration: params.expiration,
resources: params.resources,
chainId: 1,
});
return response.authSig;
};

const resourceAbilities = [
{
resource: new LitActionResource('*'),
ability: LitAbility.PKPSigning,
},
];

const pkpWallet = new PKPEthersWallet({
pkpPubKey: PKP_PUBLIC_KEY,
rpc: "https://chain-rpc.litprotocol.com/http",
litNetwork: globalThis.LitCI.network,
authContext: {
client: client,
getSessionSigsProps: {
chain: 'ethereum',
resourceAbilityRequests: resourceAbilities,
authNeededCallback,
},
},
});

await pkpWallet.init();

const signature = await pkpWallet.signMessage(TO_SIGN);