Inspiration

I thought it was a good idea, as crowdfunding is something that can definitely benefit from blockchain: transparency, accountability, trust-minimized processes, and it can benefit even more from automated systems... such as Chainlink Automations.

It is at the crossroads between recurring and one time payments. The former has the advantage that you can cancel it at any time, and gradually support a project or artist, but you need to constantly expect these payments to draw money out of your (bank) account. The latter has the advantage of making a one-time contribution, without worrying about it after, but requires trusting that the project will not be abandoned, change direction, team... Cascade is the best of both worlds, or at least tries to.

This was also a way for me to improve my skills with Chainlink, especially with Automations, as it is a service that I had not yet used extensively. I also wanted to iterate on a fully decentralized backend (other than the host), with all the data grabbed either from the contracts or from the subgraph.

What it does

It is a platform for both projects support and creation. It behaves as an interface between founders and contributors, where the latter can plan their contributions over a specified period, give out their funds to a secured contract, let the payments be sent automatically, and still pull back if they don't feel confident anymore at some point.

As a creator

A project can be submitted with basic information: name, description, links, categories, and both the addresses and shares of the collaborators. It is a submission for a funding campaign, so it is clear from the start how the funds will be distributed. When the project is created, a child contract is generated, and it will hold the contributions and states of withdrawals. Meaning that if a collaborator has a share of 50% of the contributions, they will never be able to withdraw more than 50% of the funds.

As a contributor

The contribution process is a bit more elaborated. As the creators can submit a project, and then withdraw their current share at any time, the contribution system is (can be) automated. A contributor needs to create an account (a smart contract) that will act as an interface. They can then register a Chainlink Keeper from the app, set a payment interval, then the Upkeep will - provided with enough LINK - calculate the contributions to send and transfer them to the projects at the chosen interval. They can always trigger these payments manually, at any time.

A contribution is always created with a fixed amount, and an end date. The calculation will attempt to equally distribute these funds over the selected period, meaning that all the funds would be sent when the period is over. Let's get through the process quickly to understand how it works.

  • The contributor finds a project they want to support. They click "contribute", choose 100 MATIC, and an end date 2 months from now. The 100 MATIC are stored inside the contributor account and the storage is updated in the contract. They have now dedicated these funds to this contribution, with confidence that it is safely stored, and that they can support the project gradually without worrying about monthly deductions from their bank account.
  • One week later, the upkeep is performed: it calculates the appropriate amount, which will be ~12.5 MATIC, and sends it to the project. The contributor could have triggered it a few days earlier, then this previous amount would be deducted, and the project would still end up with the same amount. If there are multiple contributions, the process is exactly the same as all payments are done in a row.
  • The collaborators receive the contribution in their contract. They are two, with an equal share. They had received another 10 MATIC contribution earlier, that the first collaborator had already withdrawn. Now, the first collaborator can withdraw 6.25 MATIC, and the other one can withdraw 11.25 MATIC.
  • If the contributor is happy with it, it will continue until the contribution period is over, and the funds fully sent. However, if they were upset with it and wanted to cancel it right now, they could as well update it, and receive back the remaining ~77.5 MATIC. They could also increase or decrease the contribution amount.

How I built it

The contracts are written in Solidity, using a Hardhat environment, and a test suite with Mocha and Chai. Still the setup from Patrick Collins' course, that might soon be replaced with Foundry! The events are indexed in a subgraph on The Graph network.

The frontend was built from a Next.js starter, and most of the components are customized or raw components from the shadcn/ui components library. It uses ApolloGraphQL to query the subgraph. All the interactions with blockchain are made with wagmi hooks, after the user connected their wallet with ConnectKit.

Challenges I ran into & accomplishments that I'm proud of

I ran into my first challenge even before starting the hackathon. I had been waiting for it since the last one, but the more we approach the starting date, and as I was working on various projects, the more I found myself dragged into non-development considerations. And when it started, I didn't feel like spending the next month and a half focusing on it. Which was not real, and as I finally started working on it after the idea came up, about three weeks ago, I found the motivation that first dragged me into this and keeps me on this space every day again. I do still feel a bit disappointed that I did not start it before, as there are a lot of improvements I could have done, especially including Chainlink Functions into the frontend, for example to create private community-gated contributions.

In any case, I am proud of my accomplishments, and I am glad I finally jumped into the hackathon since it is the best way to get myself a deadline, so I don't lose myself in endless implementations until it becomes impossible to work on it anymore.

I found out that there are a lot of functionalities on which I used to struggle a lot, that I could code without getting the errors I used to get, which was very surprising. I'm thrilled with the new possibilities it opens, and how fast I can progress with good dedication and precise planning during the building process.

What I learned

I learned a tremendous amount once again. First, I feel way more confident with contracts, I learned how to structure my code more efficiently and document everything inside it.

Above all, the Next.js starter with shadcn/ui components was written in Typescript, which I took as an opportunity to stick to it. That was hard at first, but it quickly became incredibly more efficient to write with a type safe process, knowing precisely the kind of variables I could expect. I'm definitely switching to it now. It also uses Tailwind CSS, which I learned as well, and really quickened and simplified the process.

What's next for Cascade

There is still a lot that can be done. In a short term, there are fixes to make on the UI, and other implementations, such as:

  • correctly fetching the data back from the subgraph after an update, to avoid reloading the page to reflect the changes;
  • allowing users to perform updates on their projects (name, description, links, etc) and enabling more information to be stored (e.g. some documents on Arweave/Bundlr or IPFS);
  • abstracting the Chainlink components from the user, for instance by sponsoring the fees for them;
  • even better, sponsoring all the fees for the users, allowing them to connect to the app with a Web2 process as well, eventually with a small fee to cover the upkeeps;
  • using account abstraction instead of a contributor account to stick with a better proved standard;
  • and a lot more...

Built With

  • apollographql
  • chai
  • chainlink
  • connectkit
  • ethers.js
  • graphql
  • hardhat
  • mocha
  • next.js
  • polygon
  • shadcn
  • solidity
  • thegraph
  • typescript
  • wagmi
Share this project:

Updates