Git Product home page Git Product logo

fcl-demo's Introduction

Flow Client Library Demo

This project demonstrates how to use FCL in your webapp and interact with Flow and wallet providers. You can find an online demo Here

Getting Started

Setting up environment

In order for this demo to work, you have to setup the dependencies first:

  • Install Flow CLI Here
    The Flow CLI is a command-line interface that provides useful utilities for building Flow applications. The tool we need in this demo is Flow emulator, a local emulator of Flow blockchain.
  • Install project dependencies
    Run yarn at project root.

Starting the services

  • Start Flow emulator
    Run flow emulator start at project root. Flow CLI uses ./flow.json as config to start up the local Flow emulator.
    The emulator provides a local access node at http://localhost:8080
  • Start FCL dev-wallet
    Run yarn run dev-wallet at project root, which starts FCL dev wallet with private key identical to the one defined in ./flow.json.
    The dev wallet is served at http://localhost:8701
  • Start demo webapp
    Run yarn start at project root and you will see the demo webapp running at http://localhost:3000

Diving into Demo

All the demo cases are located in ./src/demo. Each component is responsible for one example interaction with FCL.

  • GetLatestBlock: Get the information of the latest block produced on Flow blockchain
  • GetAccount: Get the account information for any specified account address
  • ScriptOne: Executes a simple script (read-only)
  • ScriptTwo: Executes a simple script (read-only) but with custom decoder for custom Cadence data structure
  • Authenticate: Handles sign in/out logic with FCL wallet
  • UserInfo: Subscribes to fcl.currentUser() and shows the connected user account information
  • SendTransaction: Sends a simple transaction to Flow. This requires the signatures from the connected user
  • DeployContract: Deploys a contract to the current user's code storage
  • InteractWithContract: Sends a simple transaction that executes a contract method. This requires the signatures from the connected user

Switch to Testnet

You can also test on Flow testnet instead of local emulator. To do so, simply update the FCL config inside ./src/config.js:

fcl.config()
  .put("accessNode.api", "https://access-testnet.onflow.org")
  .put("challenge.handshake", "https://flow-wallet-testnet.blocto.app/authn")

This will use a testnet access node instead of local emulator, and Blocto testnet wallet instead of local dev-wallet.

Contact

If you encounter any questions while trying out Flow, please go to Flow Discord Server, where you can find other developers to help you out.
If you have any problem integrating Blocto wallet, you can also check out Blocto Discord Server

Acknowledgement

  • This project was bootstrapped with Create React App.
  • A lot of the examples were taken from the tutorial in FCL

fcl-demo's People

Contributors

boczeratul avatar dependabot[bot] avatar

Watchers

 avatar  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.