-
Notifications
You must be signed in to change notification settings - Fork 133
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
Add FAQ about restricting methods to specific addresses #745
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -111,6 +111,23 @@ this.num.assertEquals(currentState); | |||||
|
||||||
This ensures that the transaction fails if the value of the field in question has changed. | ||||||
|
||||||
### How do I restrict a provable method so that it can be invoked only by a specific address? | ||||||
|
||||||
There are a number of ways to accomplish this: | ||||||
- Provably add a signed child account update. Then, the method can be invoked only with a signature from the predefined address. | ||||||
```TypeScript | ||||||
// in your method create empty signed account update | ||||||
AccountUpdate.createSigned(someAddress); | ||||||
``` | ||||||
|
||||||
```TypeScript | ||||||
// later, sign the tx | ||||||
tx.sign([privateKeyOfAddress]); | ||||||
``` | ||||||
|
||||||
- Require a private key as a private input, and check that `privateKey.toPublicKey().assertEquals(this.address)` | ||||||
- Require a signature as an input. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. by or do we want to set explicitly set the input field permission to signature? (or something else entirely?) I was looking for a doc to link to, and found out that I need to learn more about what this means. Permissions doc https://docs.minaprotocol.com/zkapps/o1js/permissions
Or do we mean something as described in https://docs.minaprotocol.com/zkapps/o1js/interact-with-mina#signing-transactions-and-explicit-account-updates ?
|
||||||
|
||||||
### Can I pass hex values into Fields? | ||||||
|
||||||
Yes, just pass in the appropriate BigInt literal. | ||||||
|
@@ -157,4 +174,4 @@ Pasta curves (Pallas and Vesta). See [Pasta Curves](https://o1-labs.github.io/pr | |||||
|
||||||
### When do I use Provable conditional logic? | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Are there situations in which I would not want to use the Provable versions? If the conditional logic is not part of your provable code, you do not need to use Provable conditional statements. | ||||||
Are there situations in which I would not want to use the Provable versions? If the conditional logic is not part of your provable code, you do not need to use Provable conditional statements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at open PRs and noticed we let this one get stale... do we want to discuss? @garwalsh