A Flow Dapp that allows projects create on-chain staking-based fundraisers (ISPO - "Initial Stake (Pool) Offering") where users willing to support them can lock their FLOW which would be staked by the smart contract, funding the project from the rewards accrued by the delegations. After the ISPO ends, the users in can claim as a reward a certain amount of a fungible token associated with the ISPO, proportional to their locked FLOW and get back the FLOW their originally locked.
For contracts/transactions/scripts, check the cadence folder. The core is the ISPOManager contract which consists of several resources:
IspoAdmin
- through which projects create ISPOs (IspoAdmin
resource) where they specify for how long the ISPO will be active and provide the token vault resource for the token they plan to distribute as a reward to the delegators. This resource is stored on the respective project's account and aISPO
resource is stored in theISPOManager
contract, containing the token vault and ISPO data (name, epoch range, etc.)IspoClient
- this is the resource through which users can delegate to the ISPO of their choice. A user provides there a vault resource with the FLOW they are willing to lock and it gets directly transformed into a delegation to the Flow staking node (specified in theISPO
resource, therefore allFLOW
for an ISPO is delegated to the same node). Once the ISPO is closed, the user can through this resource claim the reward token and get the FLOW released. Since "undelegating" is a multi-step proces, the contract transfers instead the full delegation resource to user's account, allowing them to unstake or re-stake their Flow from their wallet of choice.
- FCL setup and configuration
- Wallet Discovery (including Dev Wallet on Emulator)
- CLI private key separation for security
- Flow.json loading for contract placeholders
- Deployment
- Mainnet deployment
- JS Testing
- Clone/Fork 🏗 scaffold-flow repository to your local machine:
git clone https://github.com/onflow/scaffold-flow.git
- install required packages:
cd scaffold-flow
yarn
You will be able to run you app locally on the flow emulator immediately after forking! For running on Testnet, you will need to make some configuration changes.
- In your terminal, use this Flow-CLI command to initialize the flow blockchain emulator:
flow emulator start
- In a different terminal, use this Flow-CLI command to initilize the Dev Wallet:
flow dev-wallet
- In a different terminal, use this Flow-CLI command to deploy and manage your contracts. This listener will automatically update and redeploy your contracts as you work!
flow dev
Ensure your account address is prefixed with
0x
. Add the prefix if missing."default": { "address": "0x0000000000000000", // confirm this address has the prefix "key": "0000000000000000000000000000000000000000000000000000000000000000" },
- In a different terminal (Last one, promise!), use this command to deploy your contract(s) and initialize the App:
yarn dev
- You're done! Checkout the App at http://localhost:3000
flow emulator
flow project deploy
flow transactions send ./cadence/transactions/admin/mintRewardToken.cdc 1000.0
flow transactions send ./cadence/transactions/admin/createISPO.cdc "testISPO" 5 10 "ispoExampleRewardTokenVault" "ispoExampleRewardTokenReceiver" "ispoExampleRewardTokenBalance" 1000.0
flow scripts execute ./cadence/scripts/getISPOInfos.cdc
flow transactions send ./cadence/transactions/admin/destroyISPO.cdc