Skip to main content

Migrating from 3.1.x to 3.2.0

info

The Datil-test and Datil-dev testnets are now live and are superseding the Manzano and Cayenne testnet respectively.

The Datil mainnet is now live and superseding the Habanero mainnet, ready to store real world assets.

Check out the migration docs to learn how you can start building on the Datil networks today.

info

This migration guide is outdated and refers to a previous version of the Lit SDK. If you are looking for the most updated version of the Lit SDK, you can view it on GitHub.

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);
info

Not finding the answer you're looking for? Share your feedback on these docs by creating an issue in our GitHub Issues and Reports repository or get support by visiting our Support page.