Implementation of financial primitive Commitments to Future Cashflows on Substrate. C2FC is a new financial primitive and a DeFi equivalent of cashflow financing. C2FC bridges traditional finance and Web3 by providing DeFi and Web3 entrepreneurs with capital to grow. For more details read about C2FC here.
Connect to local node:
- Go to admin tools / settings.
- Select remote node/endpoint to connect to =>
Local Node
. - Press
Save & Reload
curl https://sh.rustup.rs -sSf | sh
#!/usr/bin/env bash
set -e
mkdir akropolis
cd akropolis
git clone https://github.com/akropolisio/akropolis-polkadot.git ./node
# or git clone git@github.com:akropolisio/akropolis-polkadot.git ./node
cd node
# Install required tools:
./scripts/init.sh
# Build the WebAssembly binary:
./scripts/build.sh
# Build all native code and install:
cargo install --force --path ./ akropolis
cd ..
# Build chain-spec and export:
akropolis build-spec --chain akropolis > spec.json
#!/usr/bin/env bash
akropolis --chain akropolis \
--telemetry-url wss://telemetry.polkadot.io/submit/ \
--rpc-cors all \
--name "AkropolisC2FC-NodeName" \
--base-path ./base \
--keystore-path ./keystore \
--listen-addr /ip4/0.0.0.0/tcp/30333 \
--bootnodes \
/ip4/178.128.225.241/tcp/30333/p2p/QmbdSLdQ5yyRG5kCLLUCDyG7FUwbqtHngRWCJyG6yULWax \
/ip4/157.230.35.215/tcp/30333/p2p/QmbmedQMeErSiQH2AFXyb9MSNxtUNJAdH6CY6hWcdKuXJi
Prerequisites:
You should have accounts with positive balance to test creation / transfer / exchange of C2FC (let's create this account with seed //Alice
, //Bob
, //Charlie
).
Core elements of C2FC on Substrate implementation:
- User accounts
- FreePromise
- Promise
- Bucket
- Resitrar (Storage-module C2FC)
Creation of C2FC consists of two steps: at first, you create Free Promise and then assign a payee to it (Promise stage). While C2FC is in the Free Promise stage, it hasn’t recipient of payments (issuer is a recipient).
-
go to Extrinsics
-
Alice creates Bucket:
- select using the selected account => Alice
- select submit the following extrinsic
C2FC
::createBucket()
Submit Transaction
-
Bob creates Promise:
- select using the selected account => Bob
- select submit the following extrinsic
C2FC
::createPromise(value, period)
wherevalue
: amount of regular paymentperiod
: periodicity of regular payment
Submit Transaction
-
Bob creates temporary Promise:
- select using the selected account => Bob
- select submit the following extrinsic
C2FC
::createPromiseUntil(value, period, until)
wherevalue
: amount of regular paymentperiod
: periodicity of regular paymentuntil
: date (block) of last payment
Submit Transaction
-
Bob makes changes to Promise:
- select using the selected account => Bob
- select submit the following extrinsic
C2FC
::editPromise(promise_id, value, period)
wherepromise_id
: id (hash) of Bob's promisevalue
: amount of regular paymentperiod
: periodicity of regular payment
Submit Transaction
-
Bob stakes tokens in order to ___ the Promise:
- select using the selected account => Bob
- select submit the following extrinsic
C2FC
::stakeToPromise(promise_id, amount)
wherepromise_id
: id (hash) of Bob's promiseamount
: size (amount) of stake
Submit Transaction
- select submit the following extrinsic
C2FC
::withdrawStaken(promise_id)
wherepromise_id
: id (hash) of Bob's promise
Submit Transaction
-
Alice sells his Bucket:
- select using the selected account => Alice
- select submit the following extrinsic
C2FC
::setPrice(bucket_id, new_price)
wherebucket_id
: id (hash) of Bob's promisenew_price
: price of the Bucket
Submit Transaction
- select using the selected account => Charlie
- select submit the following extrinsic
C2FC
::buyBucket(bucket_id, max_price)
wherebucket_id
: id (hash) of Alice's promisemax_price
: Charlie's maker price
Submit Transaction
-
Alice transfers Bucket:
- select using the selected account => Alice
- select submit the following extrinsic
C2FC
::transfer(to, bucket_id)
whereto
: receiver of Bucket (Charlie's account)bucket_id
: id (hash) of Alice's Bucket
Submit Transaction
-
Alice is searching Bob's Promise:
- go to ChainState
- select selected state query => C2FC
- use any method with name starts with
freePromise...
freePromisesCount(): u64
: number of open PromisesfreePromisesArray(u64): Hash
: get id (hash) of open Promise by incrementfreePromisesIndex(Hash): u64
: get increment number of open Promisy by it's id (hash)promises(Hash): FreePromise
: get Promise by id(hash)
- click
+
-
Alica adds Bob's Promise to her Bucket:
- select using the selected account => Alice
- select submit the following extrinsic
C2FC
::acceptPromise(promise_id, bucket_id)
where:promise_id
: id (hash) of Bob's Promisebucket_id
: id (hash) of Alice's Bucket
Submit Transaction
- Bob pays his commitments to Bucket Owner:
- select using the selected account => Bob
- select submit the following extrinsic
C2FC
::fillBucket(bucket_id, deposit)
where:bucket_id
: id (hash) of Alice's Bucketdeposit
: funds, that trasferred from Bob's account to Bucket owner's account
Submit Transaction