Skip to content

Clarity Values Guide #877

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

Merged
merged 10 commits into from
Nov 13, 2020
Merged

Clarity Values Guide #877

merged 10 commits into from
Nov 13, 2020

Conversation

reedrosenbluth
Copy link
Contributor

A guide for dealing with Clarity values in JS.

#816

@vercel
Copy link

vercel bot commented Nov 6, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/blockstack/blockstack-docs/mp70yhxmt
✅ Preview: https://blockstack-docs-git-clarity-values-guide.blockstack.vercel.app

@github-actions
Copy link

github-actions bot commented Nov 6, 2020

Blockstack Documentation

Blockstack docs have been deployed with Vercel using the code from this PR!

📝 Changed routes:

…s/clarity-values-guide
Screenshot of /smart-contracts/clarity-values-guide
(view full size)

Built with commit 8a8901e.

Copy link
Contributor

@yknl yknl left a comment

Choose a reason for hiding this comment

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

I think it would be really helpful to document the reverse of constructing Clarity values. For example, if I receive a responseCV from a contract function call. How do I extract the value and how do I work with them in JavaScript?

@agraebe agraebe linked an issue Nov 9, 2020 that may be closed by this pull request
6 tasks
## Clarity Types
The Clarity type system includes the following types:

- `(tuple (key-name-0 key-type-0) (key-name-1 key-type-1) ...)` - a typed tuple with named fields.
Copy link
Contributor

@njordhov njordhov Nov 11, 2020

Choose a reason for hiding this comment

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

This type corresponds to the ECMAScript Record, an immutable mapping from keys to values. The tuple type in Clarity is a misnomer, likely to confuse JS devs as TC39 will also introduce a Tuple type in ECMAScript that is more like an immutable array, notably different from the tuple in Clarity. Consider to clarify that this type is like a record.

Copy link
Contributor

@yknl yknl left a comment

Choose a reason for hiding this comment

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

LGTM, the additional explanation on utilizing Clarity objects in javascript is helpful.

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.

Guide for Clarity values
6 participants