Code Monkey home page Code Monkey logo

wfil's Introduction

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

WFIL

Wrapped Filecoin, ERC20 Wrapper over Filecoin

WFIL is the fist ERC20 wrapper over Filecoin, representing a stablecoin on deposits on a custodial Filecoin 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
Pitch Deck

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
    • Solhint
    $ yarn
  • 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

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.

wfil's People

Contributors

naszam avatar cristiam86 avatar

Stargazers

Roman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.