Smart Contract Development Thread

Hi Everyone,

Over the past few weeks I’ve sourced ideas for different Clarity smart contracts from the Blockstack community at large, and want to share all of them here. My idea is we can use this initial list to decide on the best 3-5 “template” Clarity smart contracts to create near term. These are not super specific contracts, but rather general templates that many can tweak to serve a specific use case. An example would be a pay-per-view contract.

Ideally the result of this exercise is an initial set of Clarity smart contracts, with documentation, that enable a developer to quickly get up and running with Clarity, and implement things like novel business models, by the end of March. Blockstack PBC may offer some bounties or rewards for building the contracts and documentation, but the engineering bandwidth will need to come from the community.

If there is a working group that would like to take this on, please ping @jrmith and myself. The list:

  • Pooling contract for Stacking
  • License
  • DAO Contracts (Moloch DAO, but on Blockstack, for profit DAO, open source DAO)
  • Escrow contract
  • Contract to generate a nonfungible token
  • Contract to generate a fungible token
  • Business model Contracts: pay per view contract, subscription contract, media access contract etc…
  • Barter contract
  • Vesting contract (put assets in a contract, and it pays them back or out to others on a specified vesting schedule)
  • http communication from a contract with timers
  • Crypto collateralized stablecoin contract
  • Contract for access control to a data collection
  • Testing framework similar to JUnit for java
7 Likes

My personal favorite from the above is the broader “Business models” category of contracts. Think it would be valuable if there were a set of ~3 business model contracts (something like subscription, pay per use, pay once and done contracts) that enabled an app creator to quickly plug a business model into their app.

A neat idea for a tutorial around these could be to take Zero to Dapp tutorial and the Animal Kingdom app, and add a section at the end where you choose a business model for the kingdom you just created.

6 Likes
  • Stacks Pooling for sure.
  • Pay per read - like a faucet, but the page viewer is rewarded only if a question is answered correctly which proves, for example, the content on the page was read.
4 Likes

Thanks Brad. Interesting idea with the pay-per-read.

How would that work - user pays a smart contract, is given access to read some content, and then if they enter a correct response to a question on the content they get some of what they paid the contract back?

Pay-per-view via smart contract does not sound very privacy preserving. Looking for the first user to pay to view my Nuddle posts.

Would it be possible to implement something like Blockstack Legends, probably some kind http call things?

Token contracts are already available, aren’t they ? What about a market contract to transfer NFTs?

2 Likes

When implementing a business model, is it a business model for the app developer or for the data creator? Would pay-per-view result in income for sigle, or an alternative presentation layer of the posts or would it result in income for the creator of the content or for both?

2 Likes

Interesting point to consider. Business model for the creator and the users or/and the users of the user…
Kind of cooperation and reciprocity, the principles of all that has been created.

I don’t believe a template for a contract to create an NFT or fungible token exists as of right now with Clarity.

Great question, and I think you could answer it in a number of different ways depending on the contract you built.

An obvious starting place are contracts that enable business models for app creators, as there’s an existing market to serve there for Blockstack apps.

A contract that also allows the creator of the content to earn income would also be interesting and a good one to make. Many more possibilities as well.

For the initial set of contract templates, my gut feeling is to go with the simplest versions first, but still valuable to articulate all the possible permutations and evolution a simple contract might take.

Source code for tokens and NFTs is here: https://github.com/blockstack/clarity-js-sdk/tree/master/packages/clarity-tutorials/contracts/tokens

Source code for a one-time payment or subscription license is here: https://github.com/friedger/oi-license

Sourc ecode for Blockstack Naming System (BNS) is here [WIP]: https://github.com/blockstack/blockstack-core/blob/feature/bns/core-contracts/contracts/bns.clar

3 Likes

To be honest @friedger I was thinking about this as a sorta way to do something similar to the advertisement model (businesses pay to put content in front of users) and they can opt to view/read it or not by clicking a link/button that indicates something like “advert w/0.10 STX reward” or “read a message from our sponsor for 0.1 STX reward”. And then the user is getting rewarded instead of a cloud platform provider in the normal web advertising model. But I really didn’t give it a lot of thought. There may very well be reasons why it’s a bad idea.
This could also be done in a revenue sharing way - where the user gets a reward and the site/app gets some too (a commission %) ?

No. What I was thinking about was like the current web ad model. A 3rd party is willing to pay to put content in front of users and so is the paying side of the contract. If a user clicks through and views the text/video/audio content and answers the question then they get the payout/reward and possibly some part also goes to the site/host or app. Again, really just trying to apply the current Web 2.0 ad model to the decentralized Web 3.0 sites/apps.

1 Like

A stablecoin as you listed I think also might be very useful if it’s possible to do securely.

1 Like

Your list probably already covers this scenarios, but I wanted to double-check with more common Web 2.0 names:

  • Pay to access file
  • Pay to access 3rd party file (like on the user Gaia Hub, for example) and take a commission
  • One-time payment to enable certain features
  • Paid subscription to enable certain features
  • Donation + a way to show everyone that donated
3 Likes

@friedger that’s awesome. What’s the difference, if there is any, between that source code and a template contract any developer could use in their app? Has anyone tried deploying one of those contracts to the Clarity Test Net yet?

@fluidvoice got it, and I do think that’s a cool use case. Yes can be used for ads, but can also be used to incentivize any type of content consumption. Could be used for educational purposes for instance.

@sdsantos These are great, and agree it’s worth listing out the business models in a bit more detail. Would love to see your list exist as a sort of “business model package” app creators could leverage.

2 Likes

Can anyone elaborate on potential used cases for Blockstack enabled Clarity Smart Contracts . Also how would blockstack address the legal aspects of these contracts ? or will that be upto the app dev team? . Some of these contracts may have legal aspects that are traditionally under govt supervision . How will that be managed ?

No way do we want Blockstack to address legal or any part of smart contract implementation.

No central gatekeepers.

And I’m not sure why this would even be a consideration. Does anyone else operate with this model?

WRT to governments, developers should talk to a lawyer in their own jurisdiction about what they can legally do. While the contract may be decentralized, I’m not sure that matters to your local laws.

1 Like

smart contracts will probably be contextualized in an additional written electronic agreement in natural language just to cover ambiguity .

I just look at it as - code that manipulates, moves value.
I think you’d just need to make sure you don’t run afoul of any money-laundering laws.

1 Like

How’s the Blockstack authenticator and smart contract works together? I hope we can have full example how to sign transaction using blockstack account or how to pay for something using STX or custom token.

Last, what happens to Gaia storage when blockstack launch the smart contract? is it going to be the place to store files like image and the smart contract will store the database part?

1 Like