Gerhard Steenkamp
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # BZZaar Interface A Bonding-curve powered AMM for the buying and selling of BZZ tokens. - App: [bzz.exchange](https://bzz.exchange/) - Smart Contracts: [ethersphere/bzzaar-contracts](https://github.com/ethersphere/bzzaar-contracts) - Swarm whitepaper: [whitepaper](https://www.ethswarm.org/swarm-whitepaper.pdf) - Docs: [docs.ethswarm.org](https://docs.ethswarm.org/docs/) ### Starting App (development) Follow these instructions for local development: get environment variables: ```bash cp .env.goerli .env ``` > Note: There is no alchemy API key included in `.env.example` for security purposes.Please remember to add your own (full URL, not just API key). Your .env file should look something like this: ```env REACT_APP_TOKEN=0x4476dcFD4AFbB9da6598fAAF499B04F7685C8b37 REACT_APP_DAI=0x05F454b4C05d6B72D082a7304444A80b4CA29e4b REACT_APP_CURVE=0x21A661D379AD6EC926c965295C563904F4ed3D2F REACT_APP_ETHBROKER=0xC5036394fC89b9f2437D8F657cAeCC92361bE38e REACT_APP_CHAIN_ID=5 REACT_APP_POLLING_INTERVAL=6000 REACT_APP_GRAPH_ENDPOINT=https: //api.thegraph.com/subgraphs/name/gundamdweeb/arrakis REACT_APP_PORTIS_ID=f373e661-58c6-4781-b43a-77d85d53729e REACT_APP_ALCHEMY_ENDPOINT=https://eth-goerli.alchemyapi.io/v2/<API_KEY> ``` install packages: ```bash yarn install ``` start dev server: ```bash yarn start ``` ## Project structure All main app logic is inside the src directory. ```bash |-- README.md |-- changelog.md |-- package.json |-- src | |-- App.tsx | |-- components | | |-- [React Components] | |-- constants.ts | |-- containers | | |-- [React component Containers] | | |-- [custom hooks] | |-- interfaces | | |-- [Contract ABIs] | |-- store | | |-- services | | | `-- prices.ts | | |-- themeContext | | | |-- ... | | `-- types.ts | |-- transitions.ts | |-- utils.ts | `-- web3 | |-- config.ts | |-- contractServices | | |-- bzz.ts | | |-- curve.ts | | |-- dai.ts | | |-- ethBroker.ts | | `-- helpers.ts | |-- notifications | | |-- eventTypes.ts | | `-- helpers.ts | |-- utils.ts | `-- wallets.ts |-- tests `-- tests.ts ``` ## Project Details > a breakdown of the project and its parts ### 1) Wallets & Web3 Logic ```bash |-- src | `-- web3 | |-- config.ts | |-- utils.ts | `-- wallets.ts ``` This App uses [useDapp](https://usedapp.io/) as the main web3 logic controller. find the docs [here](https://usedapp.readthedocs.io/en/latest/). Under-the-hood useDapp makes use of the popular [Ethers.js](https://github.com/ethers-io/ethers.js/) package as well as [web3-react](https://github.com/NoahZinsmeister/web3-react). `utils.ts` - Here we define somehelper functions to use in our project. `config.ts` - This is an extremely important file. Here we define all relevent contract addresses, chainID, node url to be used in our dapp. We take all this info, combine it with our ABIs and we instantiate Ethers Interfaces & Contracts (classes) to be used when making transactions to the blockchain. In this file we also define a `getConfig` function, the return of which is a config object that is passed to our DappProvider, like so: ```typescript import { DAppProvider } from '@usedapp/core' mport { getConfig } from './web3/config' const DappConfig = getConfig(); ReactDOM.render( <React.StrictMode> <DAppProvider config={DappConfig}> <App /> </DAppProvider> </React.StrictMode>, document.getElementById('root'), ) ``` `wallets.ts` - Here we define all the "connectors" for each wallet we want to support. Each wallet provider has a different API so each one requires a different set of instructions for getting account info, signing transactions etc. If you want to add more connectors for more wallets, please find the relevent connector [here](https://github.com/NoahZinsmeister/web3-react/tree/v6/packages). ### 2) Contract Interactions ```bash |-- src | `-- web3 | |-- contractServices | | |-- bzz.ts | | |-- curve.ts | | |-- dai.ts | | |-- ethBroker.ts | | `-- helpers.ts ``` `contractServices/[contract].ts` - Here we define ALL Read & Write contract functions. These are all hooks that wrap either `useContractCall()` or `useContractFunctions()` functions from useDapp (depending whether it's a read or write function). All functions inside these file are hooks to be called inside `src/containers/modalContainer.tsx`. ### 3) Notifications ```bash | `-- web3 | |-- notifications | | |-- eventTypes.ts | | `-- helpers.ts ``` `eventTypes.ts` - Here we define all the return TYPES (interfaces) of our contract events. For example when we mint tokens, the curve contract emits an event called 'mintTokens' and here we define its interface: ```typescript export interface MintTokens { buyer: string // The address of the buyer amount: BigNumber // The amount of bonded tokens to mint pricePaid: BigNumber // The price in collateral tokens maxSpend: BigNumber // The max amount of collateral to spend } ``` Do this for every event you expect to parse. `helpers.ts` - Here we define some helper functions we'll need to parse event logs and generate data to be shown inside notification popups when we receive a transction receipt (upon success or failure). ### 4) Where is it all used? ```bash |-- src | |-- components | | |-- ... | |-- containers | | |-- ModalContainer.tsx ``` `ModalContainer.tsx` The app is split into Containers and Components. This container is where all contract 'reads' are being consumed and also where contract 'writes' are being called from.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully