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

first steps #1

Merged
merged 18 commits into from
Feb 7, 2024
Merged

first steps #1

merged 18 commits into from
Feb 7, 2024

Conversation

kantp
Copy link
Contributor

@kantp kantp commented Jan 26, 2024

I've put down a design of how the contract keeps track of the off- and on-chain state, and added a method for issuing tokens. Reocation and attestation will follow soon.

kantp added 3 commits January 26, 2024 13:27
- Set up data structures for token metadata
- Introduce an abstraction for off-chain storage of a `MerkleMap`

  This allows us to do dependency injection, so that we can use an in-memory map
  for testing, and real-world implementations can use the solution that best
  fits their needs.

- Implement the first method of the `SoulboundToken` smart contract: issuing a
  new token.
@kantp kantp requested a review from teddyjfpender January 26, 2024 12:31
Comment on lines 6 to 22
/** When a token is issued, issuer and holder should agree on who can revoke the token */
class RevocationPolicy extends Struct ({
type: Field,
}) {
public static types = {
// the issuer has the right to revoke tokens
issuerOnly: Field(0),
// only the holder of the token can revoke it
holderOnly: Field(1),
// a token can only be revoked if issuer and holder agree
both: Field(2),
// tokens are indestructible
neither: Field(3),
};
}

export { RevocationPolicy };
Copy link
Contributor

Choose a reason for hiding this comment

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

There's potentially two ways to use the RevocationPolicy

  • Instead of making this a Struct we can make it another MerkleMap who's root is committed to the contract at deployment time and use a ZkProgram to attest to the RevocationPolicy of the SBT.

  • Alternatively, the SmartContract could have a state that defines the RevociationPolicy (e.g. a hash or field) and a method check if the input Struct argument satisfies those constraints.

* part of the contract state.
*
*/
class SoulboundToken
Copy link
Contributor

Choose a reason for hiding this comment

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

This is looking great!

kantp added 5 commits January 29, 2024 18:41
This should fix the CI build step.
This makes the tests more succinct, and also allows us to
keep the off-chain map in sync.
Also, tried to add a test that demonstrates that verifying a nonexistent token
fails. However, the error that's raised within the smart contract does not get
caught by the test, and the test fails (although running the test shows that the
right thing happens).
@kantp kantp force-pushed the kantp/first-steps branch from 6d14721 to 8d53f37 Compare January 30, 2024 16:43
If we use the plain metadata, the same signed message that was used to issue a
token will be sufficient to revoke it. We introduce a new type,
`SoulboundRequest` that contains the metadata, as well as the request
type (issuing or revoking a token).
@kantp kantp force-pushed the kantp/first-steps branch from 681c146 to 8869f72 Compare January 31, 2024 09:09
@kantp kantp force-pushed the kantp/first-steps branch from 39736e5 to cb3922f Compare January 31, 2024 10:22
@kantp kantp requested a review from teddyjfpender February 5, 2024 10:45
This allows users to validate that a token has existed at a certain point,
without needing to call the contract again.
@kantp kantp merged commit ed5db1a into main Feb 7, 2024
2 checks passed
@kantp kantp deleted the kantp/first-steps branch February 14, 2024 08:53
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.

2 participants