-
Notifications
You must be signed in to change notification settings - Fork 4
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
[Design]: Stacks Txn Sponsorship in sBTC-v1 #42
Comments
Re: Areas of Ambiguity
|
Yeah, it's also something we can implement at a later date without requiring significant breaking changes to apps that use the sponsoring server. |
Conversation is changing a bit. There are now two different things that needs STX sponsorship:
|
In the ticket linked below we discuss how the sBTC operation related contract calls will be paid for; now this discussion is here to decide how gas fees should be paid given the user only has sBTC and no STX. After an impromptu discussion the best path forward seems to be providing clarity developers with two clarity contract "patterns":
This won't meet everyone's needs, but will make sBTC-v1 functional for apps that build upon it. It will be their responsibility to maintain the funds necessary to make the contract calls for their app to run. |
Building off your last comment @AshtonStephens , I think we also want to note that this can be demarcated into a few different problems to solve:
|
I'm hoping to help us get more understanding about what our plans are regarding allowing users to pay with sBTC in return for having their transaction sponsored. I know that apps can answer these questions however they want, but if we're planning on building this to support sBTC-paid withdrawals at launch, I think it would be good to get more clarity.
|
Given the additional scope and complexity of this feature, we've decided to remove this feature as required for the launch of sBTC v1. We can find ways to provide guidance to developers, including the example contract linked in the description. Fortunately, because this doesn't effect the core sBTC protocol, this can be implemented after the launch of v1. |
Completing the issue description and arriving at a conclusion is the deliverable of this issue.
Design - Stacks Txn Sponsorship in sBTC-v1
This ticket holds the practical details around implementing the Sponsoring of txn fees with proposal from stacks-network/stacks-core#4235 in sBTC-v1. This includes the sponsorship options as well as any implementation details required for it to be included smoothly.
In the research discussion #38 we concluded that a lean approach without a dynamic market would be the best path forward for sBTC-v1, with the potential for a third party to create a dynamic market at some point in the future.
How should sponsorship look in sBTC-v1?
1. Summary
To support making some sBTC transactions without the need to own or use STX, a "sponsoring server" will be built to provide on-demand sponsorship of certain Stacks-based sBTC transactions.
The funds for these sponsorships will be provided by entities within the Stacks ecosystem.
2. Context & Purpose
Stacks provides a mechanism for "sponsoring" transactions. In a sponsored transaction, the payload is still signed by the end user, but the funds for the STX fee is provided by a different address. This provides a mechanism where the security and authorization of the transaction remains decentralized, while providing a better user experience for users who wish to only own sBTC.
We have deemed that it's important for sBTC users to be able to make certain transactions, such as sBTC withdrawal requests, without owning STX. This provides a more "Bitcoin native" experience and simplifies the adoption of sBTC.
To make a sponsored transaction, the workflow (not specific to this design) is:
sponsored
flag. This slightly alters the authorization payload of the transaction and prevents any fee from being added.To prevent allowing any transaction to be sponsored, which would quickly drain the sponsor's wallet, it is important for the sponsoring server to validate the transaction. For our use cases, we will mainly be validating the contract call details of the transaction.
Relevant Research Discussions
External Resources
Stacks.js function to sponsor a transaction
3. Design
3.1 Proposed Component Design
We will build a "sponsoring server", which is a backend server that provides HTTP endpoints for sponsoring transactions. Because of the highly available libraries for sponsoring and validating transactions, this server will likely be built with Node.JS or some other JS-based runtime, but that decision may be outside the scope of this document.
The sponsoring server will have a configured list of allowable contract calls, which is in the form of a
(contractAddr, functionName)
tuple. If the transaction matches one of those allowed contract calls, the transaction is sponsored.The sponsoring server can be configured to use multiple sponsoring addresses. Using multiple addresses prevents errors that can stem from reaching the chaining limit.
API Endpoints
There are two main endpoints that need to be provided to end-users:
POST /sponsor-tx
: sponsor a transaction, which is provided in the payload of the HTTP callGET /status
: An endpoint that provides information about whether the sponsoring server is available to sponsor transactions.POST /sponsor-tx
Attached in the JSON payload of this endpoint is the signed, but not sponsored, transaction. This transaction is provided in hex format.
The transaction payload is first validated. For the most part, validation is based on the contract call payload of the transaction, but the sponsoring server can be flexible enough to easily add other rules like blocklisted addresses. If the transaction is not validated, a 400 status code is returned.
Next, the sponsoring server selects which internal wallet will be used for sponsoring transactions. The wallet selects the wallet that has:
If there are no available wallets, a 500 status code is returned.
Then, the server determines the fee to be used for the transaction. This uses the fee estimation RPC endpoint provided by Stacks nodes.
Finally, the server sponsors the transaction and returns a 200 response with the sponsored transaction (in hex).
GET /status
The status endpoint is primarily provided to inform sBTC applications whether they should request sponsored transactions or not. This is important because the transaction payload is different for non-sponsored transactions, and so applications need to make different transactions.
The primary result provided by this endpoint is a "true/false" about whether the server is available to sponsor transactions. This result is based on whether:
sBTC applications will use this endpoint when preparing to sign a transaction:
sponsored: true
3.1.1 Design Diagram
3.1.2 Considerations & Alternatives
Using a dynamic fee market, where users pay in sBTC in return for having transactions sponsored, was deemed too complex for v1. It's also possible to implement a fee market after the launch of v1.
3.2 Areas of Ambiguity
Closing Checklist
The text was updated successfully, but these errors were encountered: