Skip to content

glazec/create-smart-contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create Smart Contract

downloads

create-smart-contract

Quick start

// prerequesite
npm install truffle -g
// quick start
npx create-smart-contract my-contract

What is included?

This scaffold installs and configures some useful frameworks and packages.

Included frameworks and its plugins

Included packages

Configuration file

  • .gitignore
  • .prettierrc
  • hardhat.config.js
  • slither.config.json
  • solcover.js
  • truffle-config.js

npm scripts

  • npm run test: Run tests under /test folder.
  • npm run doc: Generate docs based on doxygen.
  • npm run coverage: Generate code coverage configured by .solcover.js
  • npm run analyze Static analyze smart contracts configured by slither.config.json.Notice:You need install Slither by yourself

Customize

Development setup

git clone https://github.com/glazec/create-smart-contract.git
cd create-smart-contract
npm link

Then create-smart-contract will point to your local version.

Customize dependencies

Modify installPackages in index.js. For example, you only want to install hardhat.

const installPackages = () => {
    return new Promise(resolve => {
        console.log("\nInstalling hardhat\n".cyan)
        shell.exec(`npm install --save-dev hardhat`, () => {
            console.log("\nFinished installing packages\n".green)
            resolve()
        })
    })
}

Customize templates

Add your template to templates/ folder. Then add your your template into templates/templates.js. For example, you would like to add .env. You first put .env into templates/ and modify templates/templates.js. The keys of the exported dict will be the file name.

let fs = require('fs')
let path = require('path')
const gitIgnore = fs.readFileSync(path.resolve(__dirname, './gitignore'))
const solcover = fs.readFileSync(path.resolve(__dirname, './solcover.js'))
const slither = fs.readFileSync(path.resolve(__dirname, './slither.config.json'))
const hardhatConfig = fs.readFileSync(path.resolve(__dirname, './hardhat.config.js'))
const truffleConfig = fs.readFileSync(path.resolve(__dirname, './truffle-config.js'))
const prettier = fs.readFileSync(path.resolve(__dirname, './.prettierrc'))
const package = fs.readFileSync(path.resolve(__dirname, 'package.json'))
const env = fs.readFileSync(path.resolve(__dirname, '.env'))
module.exports = {
    '.gitignore': gitIgnore,
    'solcover.js': solcover,
    'slither.config.json': slither,
    'truffle-config.js': truffleConfig,
    'hardhat.config.js': hardhatConfig,
    '.prettierrc': prettier,
    'package.json': package,
    '.env': env
}