Code Monkey home page Code Monkey logo

create-eth-app's Introduction

Create Eth App Styled with Prettier Commitizen Friendly License: MIT PRs Welcome

Create Ethereum-powered apps with one command.

Create Eth App works on macOS, Windows, and Linux.
If something doesn’t work, please file an issue.
If you have questions or need help, please ask in our Discord community.

Quick Overview

yarn create eth-app my-eth-app
cd my-eth-app
yarn react-app:start

If you've previously installed create-eth-app globally via yarn global add create-eth-app, we recommend you uninstall the package using yarn global remove create-eth-app and use the yarn create eth-app shorthand to ensure that you use the last version.

Then open http://localhost:3000/ to see your app.
When you’re ready to deploy to production, create a minified bundle with yarn run react-app:build.

yarn react-app:start

Creating an App

You’ll need to have Node 16 or later version on your local development machine (but it’s not required on the server). You can use nvm (macOS/Linux) or nvm-windows to switch Node versions between different projects.

You'll also need Yarn on your local development machine. This is because Create Eth App relies on Yarn Workspaces, a feature not supported by Npm.

To create a new app, you may use the following method:

yarn create eth-app my-eth-app

yarn create <starter-kit-package> is available in Yarn 0.25+

It will create a directory called my-eth-app inside the current folder.

Inside that directory, if you didn't use a custom framework or template, you will get the initial project structure:

my-eth-app
├── README.md
├── node_modules
├── package.json
├── .gitignore
└── packages
    ├── contracts
    │   ├── README.json
    │   ├── package.json
    │   └── src
    │       ├── abis
    │       │   ├── erc20.json
    │       │   └── ownable.json
    │       ├── addresses.js
    │       └── index.js
    ├── react-app
    │   ├── README.md
    │   ├── package.json
    │   ├── node_modules
    │   ├── public
    │   │   ├── favicon.ico
    │   │   ├── index.html
    │   │   └── manifest.json
    │   └── src
    │       ├── App.css
    │       ├── App.js
    │       ├── App.test.js
    │       ├── ethereumLogo.svg
    │       ├── index.css
    │       ├── index.js
    │       ├── serviceWorker.js
    │       └── setupTests.js
    └── subgraph
        ├── README.md
        ├── abis
        │   └── erc20.json
        ├── package.json
        ├── schema.graphql
        ├── src
        │   └── mappings
        │       ├── tokens.ts
        │       └── transfers.ts
        └── subgraph.yaml

Once the installation is done, you can open your project folder:

cd my-eth-app

Frameworks

Create Eth App supports multiple frontend frameworks. See the folders under templates for a complete list of the available options.

You can pass the name of the framework as the value for the --framework command-line argument. Create Eth App defaults to React if no framework is provided manually.

yarn create eth-app my-eth-app --framework vue

Templates

Create Eth App comes with a host of decentralized finance templates pre-filled with contract ABIs, addresses and subgraphs. Go to the templates folder, select any framework from the list and see what templates are available.

You can pass the name of the template as the value for the --template command-line argument.

yarn create eth-app my-eth-app --template compound

Philosophy

  • Minimalistic by design: You are one command away from creating a new Ethereum-powered React app. No intermediary installs, scripts or shims.

  • End-to-End: Create Eth App provides you everything that you need to build and maintain an Ethereum-powered React app at scale, by bringing Yarn Workspaces, Create React App and The Graph under one roof

  • Aimed at Experience Architects: As Kames CG argues in Ethereum Growth's Problem, the Ethereum ecosystem is in a much greater need for top-notch product creators, not smart contract developers. Create Eth App does not enable a smart contract development environment, expecting you to import your own ABIs or build on top of an established protocol like Maker, Compound or Sablier

  • Not Reinventing The Wheel: Under the hood, you use Create React App, one of the most popular and battle-tested frontend development environments.

What’s Included?

Your environment will have everything you need to build a modern Ethereum-powered single-page React app:

  • Smooth project management via Yarn Workspaces
  • Everything included with Create React App: React, JSX, ES6, TypeScript and Flow syntax support
  • Template subgraph that indexes the events emitted by an ERC-20 contract
  • Minimalist structure for managing the smart contract ABIs and addresses
  • Hassle-free updates for the above tools with a single dependency

Popular Alternatives

Create Eth App is a great fit for:

  • Learning how to write Ethereum-powered apps in a comfortable and feature-rich development environment.
  • Starting new Ethereum-powered single-page React applications without wasting time on copy-pasting boilerplates
  • Creating examples with React for your Ethereum-related libraries and components.

But Ethereum is a large ecosystem. Here are a few common cases where you might want to try something else:

  • If you want to try Ethereum in its most basic form, consider using the Remix in-browser IDE
  • If you want to write, test and deploy smart contracts, consider using Foundry or Hardhat
  • If you want to write smart contracts and also build a frontend app, consider using scaffold-eth
  • If you want to get Goerli testETH, consider using the Goerli faucet
  • If you want to deploy to testnet or mainnet, consider using Alchemy, Moralis, Infura or another blockchain platform with RPC endpoints

For alternatives to React in particular, read the official Create React App documentation.

Acknowledgements

We are grateful to the authors of existing related projects from which we drew inspiration:

And also the Vue.js community for the CLI we used to generate our templates:

Contributors

License

Create Eth App is open source software licensed as MIT.

create-eth-app's People

Contributors

0xolishell avatar abcoathup avatar cojocaru avatar dylanjha avatar fabiodmferreira avatar gasolin avatar jakvbs avatar joshuabyler avatar kadenzipfel avatar makoto avatar maxhiker avatar mljlynch avatar paulrberg avatar rnbrady avatar robin-thomas avatar ryanberckmans avatar silvercondor avatar tomafrench avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

create-eth-app's Issues

Strict versioning of templates downloaded to match npm package.

Is your feature request related to a problem? Please describe.

Currently all versions of CEA pull the top commit from the branch set in constants.ts. This leads to some issues in so far as if someone has installed create-eth-app globally rather than using yarn create eth-app the templates they install may not be compatible with the version of CEA they have. (This may not be the recommended way of using CEA but I imagine someone out there is.)

It also means that should a broken commit make its way into the dev branch, it's instantly live and causing problems. We also need to juggle the branch variable between staging and develop and it introduces the possibility of the npm package tracking the staging branch by accident.

Describe the solution you'd like

If we use the url format https://github.com/paulrberg/create-eth-app/tarball/<PACKAGE_VERSION> in templates.ts then yarn create eth-app will always pull the commit at the time of the last push to NPM using the version as stored in package.json.

We could then have the branch based downloading of templates purely as a development tool behind an environment variable.

Add Tailwind for Developer Ergonomics

Tailwind is a utility first framework that allows you to stop writing custom css and rules and classnames.

Think bootstrap or material but without the prescriptive design implementation. Just a modular shorthand syntax for common css rules.

An argument could be made to not add this as it’s certainly not ubiquitous like typescript yet, but everyone (including dev thought leaders on twitter) that uses it seems to agree it is a game changer once you build up the muscle memory of the syntax.

Being able to copy pasta markup and styles in one go without needing to build an inheritance chain of styles saves a ton of time.

Much like JSX early on, you have to suspend your disbelief and just try it for a week straight, and then it clicks.

Implement web3modal in Vue.js templates

If #63 gets merged, it will create a precedent for CEA accepting diverging templates across the UI frameworks. To the end user, the experience is not altered much, but this becomes a tracking nightmare for us - what features are in the React side of the codebase, what features aren't, and ditto for Vue.js.

We should either (1) strive to keep the templates as similar as possible across the UI frameworks or (2) make a concession and give up on Vue.js, to keep development lean in the v1.x releases.

Change the core branch from "develop" to "main"

I like to make "develop" the default branch in most of my version-controlled projects, but in the case of CEA, it would make more sense if we used a better name that would indicate production-readiness.

I'd go with "main", as per GitHub's latest migration from "master".

Abstract scripts from frameworks.

As mentioned in #61, we have two copies of ipfs.js. If we're going to be adding extra helper scripts in future it's worth creating a single folder to store them in.

Make the subgraph opt-in via a boolean flag

A data server is not an ancillary component for many Ethereum apps, so we should reconsider whether including this in the default template makes sense.

We can keep this feature but make it opt-in via a boolean flag, i.e. --subgraph.

Ask for framework and template in interactive mode

Create Eth App is powerful - it lets you choose-your-own-adventure via the --framework and --template CLI arguments. However, these options are not allowed when running Create Eth App with no arguments, i.e. yarn create eth-app or create-eth-app. Should we ask the user about them?

This is meant to be a discussion, since I'm not yet sure if the payoff is worth it.

Include a wallet management framework like Web3 React

@TomAFrench I think you said you'll be working on this as per the splitting of Scaffold Eth into different packages.

Possible candidates:

The last one has a particularly impressive feature: it monitors the mempool so it lets developers know when the end-user overrides an Ethereum transaction with one with a higher gas price (but same nonce). Not sure how useful this is for Ethereum beginners though, or other people interested to bootstrap a new Ethereum-powered frontend app.

Replace hardcoded INFURA_IO with environment variable

WalletConnet currently crashes without a valid Infura id.

We should substitute the hardcoded Infura id with an environment variable and make Web3Modal not crash when the id is not set (ergo when booting a create-eth-app project).

Add missing local dependency

This is related to the HEAD commit on the staging branch, not on develop.

The @project-name/react-app package depends on its corresponding @project-name/contracts package, but the latter is not listed in the former's "dependency" list.

Feature request: merge create-hq20-dapp

Refer to this Twitter discussion for context.

Conflicts:

  • The CEA templates use JavaScript, whereas HQ20 uses TypeScript
  • CEA focuses on UI only, whereas HQ20 also contains smart contracts

Nothing that can't be solved via a productive evening of refactoring though.

Print a hello message

When the install scripts executed successfully, we should welcome the user in a cheerful way.

Maybe "Hello from Create Eth App! Run yarn react-app:start to start development".

We should consider using emojis.

DRY-ify contract ABIs and addresses

For each new DeFi template, the repo grows twice as much as in size because the ABIs and the addresses are duplicated across the UI frameworks.

We should build a template of templates of templates (not kidding), whereby the contract ABIs and the address are pulled out each template source files, and the logic code maps each template to its corresponding contracts (to be specific, the logic code in template.ts).

node version problem?

Bug Description
Got an error:

error [email protected]: The engine "node" is incompatible with this module. Expected version "^8.10.0 || ^10.13.0 || >=11.10.1".
error Found incompatible module

Steps to Reproduce

Just run the command

Additional Context
MacBook, macOS 10.15.3

Smart contract development

In its early days, I was somewhat adamant to keep Create Eth App a frontend-only development tool. However, with time, interesting use cases for smart contract development came to mind: flash loans, buidler setups, etc.

I'm still not convinced that it is worth it, particularly given the complexity it would bring, but I decided to open the GitHub issue to entertain the idea further.

workspaces error on windows

Bug Description

Trying to install create-eth-app on Windows [Version 10.0.18362.720]
workspaces are set default since yarn 1.0.0
still the error occured so tried recommended command and tried to install again

-yarn config set workspaces-experimental true

still error occurs

following error

C:\Users\lazypuppet\mk1>yarn create eth-app my-eth-app
yarn create v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "[email protected]" with binaries:
      - create-eth-app
The Yarn Workspaces feature is necessary for Create Eth App. Please enable it by running this command:

  yarn config set workspaces-experimental true
error Command failed.
Exit code: 1
Command: C:\Users\lazypuppet\AppData\Local\Yarn\bin\create-eth-app
Arguments: my-eth-app
Directory: C:\Users\lazypuppet\mk1
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

Steps to Reproduce

  1. using shorthand yarn create eth-app my-eth-app

Expected Behavior
create-eth-app should have been installed and my-eth-app should be created

version
Windows [Version 10.0.18362.720]
Node.js v12.14.1
yarn version v1.22.4

Check that yarn workspaces are activated

Before yarn 1.0, the workspaces feature was not activated by default. Users had to manually activate it by running this:

yarn config set workspaces-experimental true

Therefore, before claiming that the create-eth-app install script succeeded, we should verify that this config is set to true.

Update Compound template

Since v1.1.0 of CEA has been originally published in February, Compound launched the final phase of their protocol. This includes the new COMP token and other governance modules that are not currently part of CEA's Compound template.

Write a FAQ page

We should have a minimal FAQ Page, similar to faq.sablier.finance. This could also help with making the READMEs smaller and easier to maintain.

Lots of things could be included there: why yarn and not npm, how the subgraph works, how to deploy to IPFS or Vercel, etc.

Testnet faucets

Finding a testnet faucet that works can be a pain, especially when you're new to Ethereum and you don't know the basics.

Giving users an easy way to get testnet ETH or DAI would be nice. Bonus points if we convince the miners running the testnets to sponsor us and make CEA a faucet in its own right.

Rename "dist" to "build" in Vue.js templates

I noticed that #58 adds two files to the codebase that are almost the same except for one line where React uses "build" and Vue.js uses "dist".

I don't think there's any benefit in keeping different names for the build folder of the app.

Optimise the templating system

As explained here, the problem with the current design of the templates in CEA is that the same code can be found in A LOT of places.

If you look at the App.js file of each template in the templates/react folder, you'll notice a symmetry. This is because the point of a DeFI template is to provide the user with the bespoke ABIs and addresses of that specific DeFi protocol, not with different frontend functionality.

This makes for a system that is bulky, brittle and not scalable at all. The current unpacked size of this package is a whopping 878kb. But there is a solution.

We can make good use of handlebars.js (or a similar tool) to design an architecture that's basically a template of templates. There would be a handlebars template for each UI framework that each DeFi template would parse it and input its own handlebars context, producing a consumable js file that the end-user will be provided with.

I implemented a similar system in sablier-subgraph, where there's a handlebars template that I parse and give a different context for Ethereum Mainnet and the four popular testnets.

Set up CI/CD

Testing is manual and laborious today. We can make it better!

I'm thinking of a couple shell scripts that execute on a CI server and runs the installation script for all possible frameworks and templates. E.g.

yarn create eth-app my-aave-app --framework react --template aave
yarn create eth-app my-compound-app --framework react --template compound
...

Add support for other frontend frameworks (specifically Vue)

Is your feature request related to a problem? Please describe.
There's a ton of benefit to having predefined templates with respective ABIs but I'd like to develop my frontend with frameworks other than React, specifically Vue.

Describe the solution you'd like
When running create-eth-app one should have the ability to choose their frontend framework (perhaps by a --framework flag) which would use the respective framework's CLI to generate the project.

Use a CHANGELOG

It's nice for open-source projects to have a detailed CHANGELOG for tracking progress over time.

create meaningful package names

Is your feature request related to a problem? Please describe.

All of the generated packages are being given the rather generic names @package/contracts or @package/react-app.

In the case where someone is doing smart contract dev they may wish to publish packages of the solidity contracts or their artifacts for use by others. Having a meaningful package name pre-filled would be useful.

Describe the solution you'd like

For now we could pull the name of directory in which create-eth-app is building the project in and injecting it to take the place of @project. e.g. create eth-app my-eth-app will result in packages with names such as @my-eth-app/contracts

Some preprocessing would need to be done to ensure it results in a legal package name.

Additional context

This can wait for the time being as the currently generated packages won't be being published to npm at all but it's a nice bit of polish all the same.

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.