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

Stacks Pay: A Payment Request Standard for Stacks Blockchain Payments #202

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

Conversation

dantrevino
Copy link

Stacks Pay is a proposed standard for wrapping transaction information in a standard way for easy sharing.

@dantrevino dantrevino changed the title Feature/stacks pay Stacks Pay: A Payment Request Standard for Stacks Blockchain Payments Dec 2, 2024
@binxbrigandine
Copy link

Love standardization!

@markmhendrickson
Copy link

Thanks for proposing, @dantrevino! We'll review on the Leather team and provide thoughts.

Copy link

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

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

Great work @dantrevino


contractName, functionName: Wallets MUST ignore these parameters if present.

### `mint`

Choose a reason for hiding this comment

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

What's the rationale for having mint operations as part of this spec? Couldn't this be seen as outside the realm of making payments?

Worried about how malicious contacts with a mint method, that otherwise looks like a SIP-009 contract, tricking users into draining their wallets.

Copy link
Author

Choose a reason for hiding this comment

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

I believe that enabling payments to smart contracts is within the realm of payments. And malicious 'mint' operations can happen anywhere today. At Boom we're putting default post conditions on every request.

Copy link

Choose a reason for hiding this comment

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

@dantrevino as SIP-009 doesn't specify a mint function in the spec this would mean that you can only mint Boom NFTs? As there is no spec for the params it wouldn't work with other platforms mint I guess

Copy link
Author

Choose a reason for hiding this comment

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

Sorry no this is not intended to be a Boom thing. The intention here was to make a generic name ... maybe to be more clear, for the mint function we make the functionName parameter required so that a wallet/app does not have to do the function lookup itself.


Stacks Pay defines several standard operations that specify the type of payment action to be performed. Each operation type has specific required and optional parameters.

### `support`

Choose a reason for hiding this comment

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

Are there not other use cases for a user-defined amount beyond supporting an org/project? Wondering if this name is too scoped to an individual use case, and could better be broader?

Copy link
Author

Choose a reason for hiding this comment

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

Open to other ideas here ... i tried to find a word that would encapsulate tips, donations, and gifts.

Copy link
Member

@whoabuddy whoabuddy left a comment

Choose a reason for hiding this comment

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

Overall looks good, happy to see you're putting this forward! I left a few small comments.

@human058382928 @r0zar @biwasbhandari these encoded URLs describe a Stacks transaction, might be something cool we can do there with @aibtcdev tooling!


**Optional Parameters:**

- recipient: MAY be included; if present, MUST be a valid Stacks address. The NFT will be minted for the specified address.
Copy link
Member

Choose a reason for hiding this comment

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

Where is it minted if this is not specified?

Copy link
Author

Choose a reason for hiding this comment

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

By default, the mint recipient is the user paying for the mint. If you include a recipient, you mint for that recipient.

Comment on lines +139 to +149
### Custom Operations

Applications **MAY** define custom operations for specific use cases. Custom operation types **MUST** be prefixed to prevent naming conflicts (e.g., `'custom-example'`).

- **Handling Unrecognized Operations**: If a wallet encounters an unrecognized operation type, it **SHOULD**:

- **Warn the User**: Inform the user that the operation type is unrecognized.

- **Provide Safe Defaults**: Default to a standard payment flow if possible.

- **Fail Gracefully**: Prevent unexpected behavior or security risks.
Copy link
Member

Choose a reason for hiding this comment

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

Felt like this made it more readable

Suggested change
### Custom Operations
Applications **MAY** define custom operations for specific use cases. Custom operation types **MUST** be prefixed to prevent naming conflicts (e.g., `'custom-example'`).
- **Handling Unrecognized Operations**: If a wallet encounters an unrecognized operation type, it **SHOULD**:
- **Warn the User**: Inform the user that the operation type is unrecognized.
- **Provide Safe Defaults**: Default to a standard payment flow if possible.
- **Fail Gracefully**: Prevent unexpected behavior or security risks.
### Custom Operations
Applications **MAY** define custom operations for specific use cases.
Custom operation types **MUST** be prefixed to prevent naming conflicts (e.g., `'custom-example'`).
**Handling Unrecognized Operations**: If a wallet encounters an unrecognized operation type, it **SHOULD**:
- **Warn the User**: Inform the user that the operation type is unrecognized.
- **Provide Safe Defaults**: Default to a standard payment flow if possible.
- **Fail Gracefully**: Prevent unexpected behavior or security risks.


```
R - required
O - optionalas determined
Copy link
Member

Choose a reason for hiding this comment

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

typo

Comment on lines +199 to +201
Example encoded Stack Pay url:

`stx1wajky2mnw3u8qcte8ghj76twwehkjcm98ahhqetjv96xjmmw845kuan0d93k2fnjv43kjurfv4h8g02n2qe9y4z9xarryv2wxer4zdjzgfd9yd62gar4y46p2sc9gd23xddrjkjgggu5k5jnye6x76m9dc74x4zcyesk6mm4de6r6vfsxqczver9wd3hy6tsw35k7m3a2pshjmt9de6zken0wg4hxetjwe5kxetnyejhsurfwfjhxst585erqv3595cnytfnx92ryve9xdqn2wf9xdqn2w26juk65n`
Copy link
Member

Choose a reason for hiding this comment

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

This was confusing to read before we got to the encoding section. Maybe save the example for later and focus on defining the web+stx format leading into it?

Copy link
Member

Choose a reason for hiding this comment

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

It might help to use triple backticks instead of single on the code for readability, e.g.

stx1wajky2mnw3u8qcte8ghj76twwehkjcm98ahhqetjv96xjmmw845kuan0d93k2fnjv43kjurfv4h8g02n2qe9y4z9xarryv2wxer4zdjzgfd9yd62gar4y46p2sc9gd23xddrjkjgggu5k5jnye6x76m9dc74x4zcyesk6mm4de6r6vfsxqczver9wd3hy6tsw35k7m3a2pshjmt9de6zken0wg4hxetjwe5kxetnyejhsurfwfjhxst585erqv3595cnytfnx92ryve9xdqn2wf9xdqn2w26juk65n

vs

stx1wajky2mnw3u8qcte8ghj76twwehkjcm98ahhqetjv96xjmmw845kuan0d93k2fnjv43kjurfv4h8g02n2qe9y4z9xarryv2wxer4zdjzgfd9yd62gar4y46p2sc9gd23xddrjkjgggu5k5jnye6x76m9dc74x4zcyesk6mm4de6r6vfsxqczver9wd3hy6tsw35k7m3a2pshjmt9de6zken0wg4hxetjwe5kxetnyejhsurfwfjhxst585erqv3595cnytfnx92ryve9xdqn2wf9xdqn2w26juk65n


### Encoding and Decoding

Stacks Pay URLs **MUST** be encoded using **Bech32m encoding** with the human-readable part (HRP) set to `'stx'` and a `limit` of 512. This ensures compatibility and data integrity, making it suitable for QR codes and platforms with URL limitations.
Copy link
Member

Choose a reason for hiding this comment

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

It would be great to have a code snippet or example walking us through getting from parameters -> unencoded URL -> encoded URL and back. Where do we set the HRP and limit? What do I run to encode it?

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.

6 participants