πŸ› οΈ Examples

Example apps that show how Superfluid can be used

🟒 Official Examples

Fork-able apps from the main repo:

  • Dividend Rights Token - Distribute IDA shares using an ERC20 token

  • Holy Grail - Whoever holds this NFT receives a CFA stream (see 🦾 Super Apps)

  • Continuous Auction - The winner is whoever has the largest CFA stream

  • Developer Playground - A full-stack playground built with RedwoodJS

  • and more...

Click here to see all the official examples:

πŸ§‘β€πŸ€β€πŸ§‘ Community Examples

Show off your app here! We don't maintain these, so if you run into problems, be sure to check package versions.

πŸ’‘ Ideas

Want ideas? Check out hack.superfluid.finance to connect with other community members and brainstorm ideas.

βœ‚οΈ Code Snippets

Constant Flow Agreement

import SuperfluidSDK from '@superfluid-finance/js-sdk';
import { Web3Provider } from '@ethersproject/providers';
​
const testFlow = async () => {
const walletAddress = await window.ethereum.request({
method: 'eth_requestAccounts',
params: [
{
eth_accounts: {}
}
]
});
const sf = new SuperfluidSDK.Framework({
ethers: new Web3Provider(window.ethereum),
tokens: ['fDAI']
});
await sf.initialize();
const carol = sf.user({
address: walletAddress[0],
token: '0x8ae68021f6170e5a766be613cea0d75236ecca9a'
});
await carol.flow({
recipient: '0xA8f3447922d786045CB582B0C825723B744a54df',
flowRate: 385802469135802
});
const details = await carol.details();
console.log(details);
};
​
testFlow();

Instant Distribution Agreement

import SuperfluidSDK from '@superfluid-finance/js-sdk';
import { Web3Provider } from '@ethersproject/providers';
import { BigNumber } from '@ethersproject/bignumber';
​
const testPool = async () => {
const walletAddress = await window.ethereum.request({
method: 'eth_requestAccounts',
params: [
{
eth_accounts: {}
}
]
});
const sf = new SuperfluidSDK.Framework({
ethers: new Web3Provider(window.ethereum),
tokens: ['fDAI']
});
await sf.initialize();
const carol = sf.user({
address: walletAddress[0],
token: '0x8ae68021f6170e5a766be613cea0d75236ecca9a'
});
await carol.createPool({ poolId: 1 });
await carol.giveShares({
poolId: 1,
shares: 100,
recipient: '0xA8f3447922d786045CB582B0C825723B744a54df'
});
await carol.distributeToPool({
poolId: 1,
amount: BigNumber.from(100).toString()
});
};
testPool();