New Release: Subscription Smart Contract for Terra Blockchain by AzoyaLabs

in #crypto2 years ago

Azoyalabs - OG.png

AzoyaLabs is a Terra Blockchain-focused company, intent on building innovative Defi, NFT and Gaming products for the Web3.

We believe Web3 is a community-based collaboratory effort, which is why we develop and share Smart Contracts and Website templates to do our part in this push for the emergence of a new system.

Today we are happy to announce the initial release for our Subscription contract for Terra and other CosmWasm-based blockchains!

The contract and its documentations are available on our github.
It has also been deployed on the bombay-12 testnet. We have executed a series of sample transactions to showcase the use of the contract: see the Sample Transactions section.

subscription_valid.PNG

Here’s a quick writeup on our thinking while creating this contract and a few insights into how it works.

What’s in a subscription?

A subscription is a pass for a paywall which locks content. A subscription can be necessary to read news, play games or access any kind of content and can be a vital element of a company’s business plan to get recurring revenue.
To create a subscription contract, we need a few things:

  • Setting/updating subscription options
  • Allow user subscription
  • Getting current subscription status of a user
  • Withdrawing profits from user subscriptions

Defining Subscription Options
A subscription option can be defined as a combination of duration and price.
There are 2 ways to create a subscription:

  • Use a base cost for a chosen unit of time. The duration of the subscription will therefore be: amount_funds_sent / base_cost_per_unit
  • Create restricted combinations of duration and cost, such as 1 month subscription for 30 UST or 1 year subscription for 300 UST

We decided to go with the second method as it easily allows to replicate the common system of having marginally decreasing cost of subscription for longer term subscriptions (for example, having a 20% off on per-month subscription cost for a lump payment for a 1 year subscription, compared to month by month subscription).

This gives us the first pillar of our subscription options: Duration.

We went a bit further to actually enable the definition of different assets for subscription, meaning it is possible to give a discount if the subscription is paid for in e.g. Luna instead of UST.

Getting User subscription Status and Subscription Options

We have specified queries to get current user subscription status as well as existing subscription options for ease of development.

Any contract or user can query the contract using QueryMsg::SubscriptionStatus{addr: String} to get the current status of a user’s subscription. See sample Transactions and Sample Responses below for examples of use.

Using these queries, it’s possible to instantly know whether the subscription is valid, and the time remaining in seconds (expiration_timestamp is UNIX timestamp in seconds).

It’s also obviously possible to get available subscription options.

Sample Transactions
Add a subscription option
Subscribe
Remove a subscription option
Withdraw

Sample Responses
Sample response for QueryMsg::SubscriptionOptions{}

subscription_options_code.PNG

Sample response for QueryMsg::SubscriptionStatus{addr: String}

subscription_status_code.PNG

Improvements
The way the contract is currently set up, subscribing requires a round sum payment. We are working on allowances to allow periodic transfers from the user wallet instead of a one-time payment which would make longer term subscriptions more practical for common usage.

What’s Next
We are currently working on other projects, such as a NFT Lottery contract. We believe that a subscription system, along with a lottery that could require a subscription would be a great match for projects to distribute value to users.
We are also maintaining and developing TerraDefi, a liquidation dashboard for the Anchor Protocol

We hope you’ll find this contract useful, follow us on Twitter to get future updates on our work!

About TerraDefi
TerraDefi is a liquidation dashboard for the Anchor Protocol on the Terra Blockchain. We provide batch-bidding, convenient bid tracking and reduced fees for users.
Website: https://TerraDefi.azoyalabs.com
Twitter: https://twitter.com/AzoyaLabs/

About AzoyaLabs
AzoyaLabs is a Terra Blockchain-focused company, intent on building innovative Defi, NFT and Gaming products for the Web3.
Website: https://AzoyaLabs.com
Twitter: https://twitter.com/AzoyaLabs/

Sort:  

This is a one-time notice from SCHOOL OF MINNOWS, a free value added service on steem.
Getting started on steem can be super hard on these social platforms 😪 but luckily there is some communities that help support the little guy 😊, you might like school of minnows, we join forces with lots of other small accounts to help each other grow!
Finally a good curation trail that helps its users achieve rapid growth, its fun on a bun! check it out. https://plug.sh/somlanding/

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 64081.52
ETH 3398.85
USDT 1.00
SBD 2.62