• Stars
    star
    107
  • Rank 313,356 (Top 7 %)
  • Language
    Solidity
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ethereum Smart Contract starting template

Ethereum Smart Contract Template

This development quick start template is heavily inspired by Georgios's template. Over time it was migrated to use foundry since dapptools was deprecated.

It requires Foundry installed to run. You can find instructions here Foundry installation.

Installation

GitHub template

It's easiest to start a new project by clicking the "Use this template".

Manual installation

If you want to create your project manually, clone the template in a new folder and cd into it.

Clone the template, install dependencies and make sure tests work:

mkdir cool-dapp
cd cool-dapp
forge init --template https://github.com/cleanunicorn/ethereum-smartcontract-template 
# Install the project's dependencies (libs and yarn packages)
make 
# Run tests
make test 

Features

For Foundry specific features, refer to:

This template comes with an additional set of features explained below.

Solidity libraries

Included libraries in lib:

GitHub Actions

The template already comes with GitHub actions configured, which means that the project will be tested on every push and pull request.

Check the project's actions for an example.

Actions are defined in .github/workflows/ci.yml.

GitHub templates

The template comes with a list of templates:

Commands

  • make setup - initialize libraries and yarn packages
  • make build - build your project
  • make xclean - remove compiled files
  • make lint - lint files
  • make test - run tests
  • make test-gasreport - run tests and show gas report
  • make watch - watch files and re-run tests

Testing

Normally you would run your tests on the local evm engine.

$ make test
forge test --gas-report
[⠊] Compiling...
[⠑] Compiling 19 files with 0.8.13
Compiler run successful

Running 2 tests for OnlyAuthorizedTest.json:OnlyAuthorizedTest
[PASS] testCanChangeOwner() (gas: 11542)
[PASS] testOtherUsersCannotChangeOwner() (gas: 156817)
╭─────────────────┬─────────────────┬──────┬────────┬──────┬─────────╮
│ Caller contract ┆                 ┆      ┆        ┆      ┆         │
╞═════════════════╪═════════════════╪══════╪════════╪══════╪═════════╡
│ Deployment Cost ┆ Deployment Size ┆      ┆        ┆      ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ 114159          ┆ 602             ┆      ┆        ┆      ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ Function Name   ┆ min             ┆ avg  ┆ median ┆ max  ┆ # calls │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ externalCall    ┆ 6419            ┆ 6419 ┆ 6419   ┆ 6419 ┆ 1       │
╰─────────────────┴─────────────────┴──────┴────────┴──────┴─────────╯
╭─────────────────────────┬─────────────────┬──────┬────────┬──────┬─────────╮
│ OnlyAuthorized contract ┆                 ┆      ┆        ┆      ┆         │
╞═════════════════════════╪═════════════════╪══════╪════════╪══════╪═════════╡
│ Deployment Cost         ┆ Deployment Size ┆      ┆        ┆      ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ 133694                  ┆ 607             ┆      ┆        ┆      ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ Function Name           ┆ min             ┆ avg  ┆ median ┆ max  ┆ # calls │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ changeOwner             ┆ 2504            ┆ 3980 ┆ 3980   ┆ 5457 ┆ 2       │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ owner                   ┆ 335             ┆ 335  ┆ 335    ┆ 335  ┆ 1       │
╰─────────────────────────┴─────────────────┴──────┴────────┴──────┴─────────╯
╭─────────────────────────────┬─────────────────┬────────┬────────┬────────┬─────────╮
│ OnlyAuthorizedTest contract ┆                 ┆        ┆        ┆        ┆         │
╞═════════════════════════════╪═════════════════╪════════╪════════╪════════╪═════════╡
│ Deployment Cost             ┆ Deployment Size ┆        ┆        ┆        ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ 741677                      ┆ 3639            ┆        ┆        ┆        ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ Function Name               ┆ min             ┆ avg    ┆ median ┆ max    ┆ # calls │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ setUp                       ┆ 171174          ┆ 171174 ┆ 171174 ┆ 171174 ┆ 2       │
╰─────────────────────────────┴─────────────────┴────────┴────────┴────────┴─────────╯

Changes

Listed in the CHANGELOG.md file which follows the https://keepachangelog.com/en/1.0.0/ format.

Testing forked chain

Work in progress...

More Repositories

1

theo

Ethereum recon and exploitation tool.
Python
339
star
2

karl

Monitor smart contracts deployed on blockchain and test against vulnerabilities with Mythril. It was presented at DEFCON 2019.
Python
309
star
3

mockprovider

Solidity mocking provider for testing
Solidity
60
star
4

abi2signature

Use the ABI of a smart contract to find out the function signatures
JavaScript
53
star
5

mythos

CLI client for the MythX API
TypeScript
21
star
6

flaterra

The Earth is flat but Solidity source code is not. This fixes that.
Python
19
star
7

santoku

Ethereum ABI decoder
Vue
13
star
8

nutcracker

Solidity
7
star
9

ranploy

Generate tx data payload to deploy any random hex string to Ethereum as a smart contract
Python
6
star
10

hardhat-advanced-sample

TypeScript
5
star
11

trustbet

JavaScript
4
star
12

smart-split

Ethereum smart contract splitting received value. Deployed on the main net
JavaScript
4
star
13

ether-wars

Solidity
3
star
14

hitomi

Another web3 console initilizer.
Python
3
star
15

vanity

Go
3
star
16

4byte-update

Solidity
2
star
17

cleanunicorn.github.io

HTML
2
star
18

poacher

Save price data into an InfluxDB
Go
2
star
19

merkle

JavaScript
2
star
20

nodejs-proxy

A nodejs HTTP Proxy
JavaScript
2
star
21

imago

ERC 777 token contract able to morph into anything the owner needs.
JavaScript
2
star
22

ethereum

Ethereum toolbox
Go
2
star
23

transient-storage

Solidity
2
star
24

op-scanner

JavaScript
1
star
25

digital-arbiter

Digital Ocean manager
CoffeeScript
1
star
26

tcrparty-bot

Python
1
star
27

magnus

Sweeper contracts. DO NOT USE IN PRODUCTION
JavaScript
1
star
28

phrase-app-export

PHP
1
star
29

mnemonic-permutation-python

Python
1
star
30

tbtc-v2-testnet-node-setup

1
star
31

gerhard

A generator in the style of Gerhard Richter's Strip.
Python
1
star
32

capture-the-ether

Python
1
star
33

mozaik

Create mozaiked images
PHP
1
star
34

polka-dot-mnemonic-brute

Mnemonic bruteforcer for https://polkadot.network/
TypeScript
1
star
35

rust-learn

Rust
1
star