Code Monkey home page Code Monkey logo

solidity-template's Introduction

PROJECT STATUS: Technology preview, bug bounty not active.

Solidity Template โ€” Your Smart Contract Starting Point

This project is sponsored by: XXXX XXXX XXXX, your name here. Contact Will for details.

If you are using these contracts, click at top to WATCH this repository for updates and security fixes, and click SPONSOR above to ensure updates and fixes keep coming.

How to use this

  1. Click USE THIS TEMPLATE above to make your own repository based on this template.

  2. Install project and run all tests

    # Install Node 14+
    npm install
    npm test
  3. Add your own application code inside the Contracts folder and tests inside the Tests folder.

  4. Delete stuff you don't need.

  5. Make sure tests still pass.

  6. Deploy and make a GitHub release showing your deployed address.

Introduction

This repository is a starting point for anybody developing their own Solidity smart contracts. It is opinionated. You should use this as your starting point for all your projects.

Reusable utilities

See the contracts/Utilities folder.

Implementations

See the contracts folder. In here are the contracts you would use to deploy your contract and other implementation-specific details.

Run test suite

If you are on an M1 Mac, note that Node.js is currently broken.

Setup

nvm install 12 # see special instructions above for M1 Mac
nvm use 12
npm install

Now run this each time you change contracts or test scripts:

npm run prepare
npm run lint # note, we do not use Prettier style for Solidity
FORCE_COLOR=1 ENABLE_GAS_REPORT=true npm run test
npm run test:inheritance
npm run coverage

Contributing

๐Ÿ’ฐ See our bug bounty at BUG-BOUNTY.md (NOT YET ACTIVE).

This repository is supported by William Entriken. We are accepting contributions of new features to the repository but have not defined yet which new feaures are welcome (!).

Please send pull requests to improve documentation and test cases. Please send issues for anything that might be improved.

Idioms

  • The zero address (0x00...00) is no more special than the one address (0x00...01). If your application treats them differently, document it.
  • Log things that people might reasonably want to look up or index.

References

Style guide

  • Use the Solidity style guide for Solidity code https://docs.soliditylang.org/en/latest/
    • 120 hard limit line length
    • Function parameters start with an underscore (_)
    • NatSpec
      • Align whitespace for tags
      • Align whitespace for @params
      • @param (and state variable @dev) are sentence case without capitalization for the first letter
      • Events
        • @notice sentence case in past-simple tense without a period like "Tokens were transferred"
      • Functions
        • @notice sentence case in present-simple tense without a period like "Finish a sale"
        • @dev sentence case with a period at end
      • State variables
        • @notice (same as @return)
    • Follow Solidity Style Guide where it makes sense
    • When comparing things, prefer to compare what we have versus the requirement, like msg.sender == owner rather than the reverse order.
    • Every require must have a message and start with the name of the contract/library
  • Always use NatSpec with the /// flavor (because Solidity documentation uses that one first, we can assume it is preferred). https://docs.soliditylang.org/en/latest/natspec-format.html
  • Wrap Solidity to 120 columns
  • Prefix private/internal functions & variables with underscore (_)
  • File names and headings are sentence case. Except the name of this project is title case.

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.