Cascading donations

A Soroban smart contract that allows donations to be automatically distributed to other donation contract instances or individuals.

This smart contract allows for the construction of cascading donation schemes for a variety of causes. For example, donations to the supply chain of an open-source library.

Contract workflow

Prerequisites

  • A token contract used by the donation scheme.

  • A donor account within the token balance.

  • Valid accounts for the individuals.

  • Other CascadingDonations contracts, previously registered in the network.

Workflow

  1. Define your distribution rules.

    1. Set up your recipients, they can be single accounts for individuals or other CascadingDonation contracts registered in the network (with a valid contract_id).

    2. Set a custom name for each recipient (max. 10 characters).

    3. Define the portion of the donation that each recipient will receive. Expressed as integer values. (20% -> 20).

  2. Initialize the CascadingDonations root contract including your recipients and donation token.

  3. As a donor, donate to the CascadingDonations root contract.

  4. If the donation scheme has been set up correctly, all recipients should automatically receive their share of the donation.

Note: The donation contracts will maintain the balance of the remaining tokens that are not defined in the distribution rules.

Setup

Soroban setup

For setting up your environment, visit: Soroban Setup

Contract code

Clone this GitHub repository.

Test

For testing the contract run:

cargo test -- --show-output

Last updated