naszam / wfil

Wrapped Filecoin (WFIL), Team WrapFS at HackFS @ETHGlobal | APOLLO :rocket: @gitcoinco | ETHOnline @ETHGlobal

Home Page:https://wfil.network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#ubuntu 18.04 #npm 12.19.0 #built_with_Truffle #solc 0.6.12 #testnet rinkeby

WFIL

Wrapped Filecoin, ERC20 Wrapper over Filecoin

WFIL is the fist ERC20 wrapper over Filecoin, backed by filecoin deposits on a custodial wallet (1:1 ratio).

The current iteration implements a custodial pattern where users need to send filecoins to a custodial wallet and they'll get automatically the correspondent amount in WFIL to their ethereum addresses.

Future Developments & Features:

We'd like to migrate to a non-custodial pattern where by leveraging on Filecoin smart contracts we'd be able to implement a fully decentralized application.

Extend the Filecoin Wallet into a MetaMask for Filecoin.

One of the features we're considering is to add the permit() function to WFIL to allow meta transactions by leveraging on OpenZeppelin ERC20Permit module (currently in progress) and incentivise adoption in the space.

Applications:

  • Uniswap
  • WFIL as Collateral on MakerDAO
  • De-Fi
  • ...

Mentors

Demo (HackFS)
HackFS
ETHOnline
Demo (APOLLO)
Pitch Deck
Newsletter
Demo (Beta Launch Preview)

Sections

Building Blocks

Smart Contracts Flow-Chart

Implements an ERC20 token by leveraging on OpenZeppelin Library.

It allows the owner of the contract, set as Default Admin to add/remove a Minter via grantRole(), revokeRole() functions by leveraging on AccessControl module by OpenZeppelin.

The contract implements the wrap() function to mint WFIL by passing the recepient address and the amount of Filecoin to wrap as parameters and emitting an event, Wrapped.

The contract also implements the unwrap() function to burn the WFIL by passing the filecoin address and the amount of WFIL to unwrap as parameters and emitting an event, Unwrapped.

The contract inherits OpenZeppelin AccessControl module to set the Pauser role to the owner of the contract that can call the pause(), unpause() functions in case of emergency (Circuit Breaker Design Pattern).

Once the owner call the pause() function, thanks to the _beforeTokenTransfer() hook, _mint(), _burn() and _transfer() internal functions, will revert.

To avoid users from sending WFIL to the contract address, _transfer() has been overidden to make sure the recipient address does not correspond to the contract address, and revert if it does.

To manage the wrapping - unwrapping fee, the contract set the Fee Setter role to the owner of the contract that can set the fee via setFee() and the recipient via setFeeTo(). The fee is public and can be queried via the getter function fee().

A Gnosis Safe Multisig is used to receive and store the wrapping fees and set inside the constructor.

Implements a custodial wallet by leveraging on Lotus APIs.

Via AWS Lambda, allows to automatically wrap/unwrap Filecoin, by minting WFIL from an account set as Minter and call the unwrap method to burn WFIL by the user.

It's also connected via Filscan APIs to Filecoin to check for transactions that are tracked via Textile ThreadDB.

The Frontend has been implemented via Rimble UI & Rimble Web3 Components and deployed on IPFS via Fleek.

Implements a Filecoin client by leveraging on Lotus APIs.

Further developments of the project include building a MetaMask for Filecoin, creating an extension for Chrome.

Setup

Clone this GitHub repository.

Steps to compile and test

  • Local dependencies:
    • Truffle
    • Ganache CLI
    • OpenZeppelin Contracts v3.1.0
    • Truffle HD Wallet Provider
    • Truffle-Flattener
    • Truffle-Plugin-Verify
    • Solhint
    $ npm i
  • Global dependencies:
    • Truffle (recommended):
    $ npm install -g truffle
    • Ganache CLI (recommended):
    $ npm install -g ganache-cli
    • Slither (optional):
    $ git clone https://github.com/crytic/slither.git && cd slither
    $ sudo python3 setup.py install
    • MythX CLI (optional):
    $ git clone git://github.com/dmuhs/mythx-cli && cd mythx-cli
    $ sudo python setup.py install

Running the project with local test network (ganache-cli)

  • Start ganache-cli with the following command (global dependency):
    $ ganache-cli
  • Compile the smart contract using Truffle with the following command (global dependency):
    $ truffle compile
  • Deploy the smart contracts using Truffle & Ganache with the following command (global dependency):
    $ truffle migrate
  • Test the smart contracts using Mocha & OpenZeppelin Test Environment with the following command:
    $ npm test
  • Analyze the smart contracts using Slither with the following command (optional):
    $ slither .
  • Analyze the smart contracts using MythX CLI with the following command (optional):
    $ mythx analyze

Deploy

Deploy on Rinkeby Testnet

  • Get an Ethereum Account on Metamask.
  • On the landing page, click “Get Chrome Extension.”
  • Create a .secret file cointaining the menomic.
  • Get some test ether from a Rinkeby's faucet.
  • Signup Infura.
  • Create new project.
  • Copy the rinkeby URL into truffle-config.js.
  • Uncomment the following lines in truffle-config.js:
    // const HDWalletProvider = require("@truffle/hdwallet-provider");
    // const infuraKey = '...';
    // const infuraURL = 'https://rinkeby.infura.io/...';
    
    // const fs = require('fs');
    // const mnemonic = fs.readFileSync(".secret").toString().trim();
    
  • Install Truffle HD Wallet Provider:
    $ npm install @truffle/hdwallet-provider
  • Deploy the smart contract using Truffle & Infura with the following command:
    $ truffle migrate --network rinkeby
  • Verify WFIL contract on Rinkeby via Truffle Plugin Verify:
    $ truffle run verify WFIL --network rinkeby

Project deployed on Rinkeby

WFIL

Using the DApp

  • Install Ganache GUI.
  • Change Ganache GUI port to 8545.
  • Import Ganache GUI mnemonic into MetaMask.
  • Connect MetaMask to Ganache GUI, adding a custom RPC specifing the Ganache GUI's RPC server URL.
  • Deploy the smart contracts to Ganache GUI:
    $ truffle migrate
    
  • Move to client directory on the project:
    $ cd app
  • Install dependencies:
    $ yarn install
  • Start the Local Web Server:
    $ npm run start

About

Inspiration & References

Authors

Project created by Nazzareno Massari and Cristiam Da Silva.
Team WrapFS for HackFS ETHGlobal Virtual Hackathon.
Logo by Cristiam Da Silva.

About

Wrapped Filecoin (WFIL), Team WrapFS at HackFS @ETHGlobal | APOLLO :rocket: @gitcoinco | ETHOnline @ETHGlobal

https://wfil.network

License:GNU Affero General Public License v3.0


Languages

Language:JavaScript 93.8%Language:Solidity 5.0%Language:HTML 1.0%Language:Shell 0.2%