Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init Guide on Managing Auth Method for a PKP that Owns Itself #305

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

spacesailor24
Copy link
Contributor

This is the corresponding guide for this code example

It covers:

  1. Mint a new PKP using an EOA
    • Provided as the environment variable: process.env.ETHEREUM_PRIVATE_KEY_A
  2. Add a Custom Authentication Method to the PKP that authenticates a signed SIWE message and verifies it's signed by ETHEREUM_PRIVATE_KEY_A
    • This is done by adding a Lit Action as a permitted Authentication Method for the PKP by uploading our Lit Action code to IPFS
  3. Verify the Custom Authentication Method is permitted to be used for the PKP
  4. Transfer ownership of the PKP NFT from ETHEREUM_PRIVATE_KEY_A to the PKP's Ethereum address
  5. Get PKP Session Signatures using the Custom Authentication Method from step 2
  6. Transfer some test Lit tokens from ETHEREUM_PRIVATE_KEY_A to the PKP's Ethereum address
    • This is necessary because we're interacting with the PKP Permissions contract on Lit's Chronicle chain to add and remove Authentication Methods, and we're required to pay gas for these onchain transactions
  7. Initialize and connect a PKP Ethers Wallet using the PKP Session Signatures from step 5
  8. Send a transaction to Chronicle to add a second Custom Authentication Method that authenticates a signed SIWE message and verifies it's signed by ETHEREUM_PRIVATE_KEY_B
    • This transaction executes the addPermittedAction function on the PKP Permissions contract
  9. Verify the Custom Authentication Method is permitted to be used for the PKP
  10. Get PKP Session Signatures using the Custom Authentication Method from step 8
  11. Initialize and connect a PKP Ethers Wallet using the PKP Session Signatures from step 10
  12. Send a transaction to Chronicle to remove the Custom Authentication Method from step 2 as a permitted method to be used with the PKP
  13. Verify the Custom Authentication Method from step 2 is no longer permitted

@spacesailor24 spacesailor24 marked this pull request as ready for review July 2, 2024 23:17
Copy link

netlify bot commented Jul 2, 2024

Deploy Preview for lit-dev-docs ready!

Name Link
🔨 Latest commit cc57bd6
🔍 Latest deploy log https://app.netlify.com/sites/lit-dev-docs/deploys/668495496a824400082deec9
😎 Deploy Preview https://deploy-preview-305--lit-dev-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@awisniew207 awisniew207 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only note I have is that some blocks of code did not have any imports when they used methods in the Lit SDK. For example, the first two blocks and Transferring PKP Ownership to Itself. I'm sure the imports are elsewhere in the doc, but perhaps we want them anyways?

Great explanations on every part of the code. Reference links, splitting the code into blocks, and taking it piece-by-piece were appreciated for reading.

@spacesailor24
Copy link
Contributor Author

The only note I have is that some blocks of code did not have any imports when they used methods in the Lit SDK. For example, the first two blocks and Transferring PKP Ownership to Itself. I'm sure the imports are elsewhere in the doc, but perhaps we want them anyways?

Great explanations on every part of the code. Reference links, splitting the code into blocks, and taking it piece-by-piece were appreciated for reading.

@awisniew207 Thanks Andrew, updated! The Transferring PKP Ownership to Itself doesn't need imports since it's just using variable defined in the snippet before it

@a1ttech
Copy link
Contributor

a1ttech commented Jul 3, 2024

My only comment is where this guide lives. I think we should add it as a subset of the user wallets section, versus creating a whole new dropdown. What do you think?

@DashKash54
Copy link
Contributor

My only comment is where this guide lives. I think we should add it as a subset of the user wallets section, versus creating a whole new dropdown. What do you think?

Agreed otherwise it's confusing what's the difference between User Wallets and PKPs if they have separate sections

@spacesailor24

@spacesailor24
Copy link
Contributor Author

@DashKash54 This is what Eli and I settled on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants