Giter Site home page Giter Site logo

0xmilenov / solidity-sandbox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maurelian/solidity-sandbox

0.0 0.0 0.0 1.41 MB

A forkable template repo for easily writing and testing toy contracts

License: MIT License

Shell 40.12% Solidity 59.88%

solidity-sandbox's Introduction

Solidity Sandbox

Picture of a sandbox

Just a simple forge based repo for playing around with and understanding solidity toy code.

See how other's are using it:

Conventions

The whole purpose of this repo is to make it fast and easy to test stuff, and then keep the test code for future reference. Specific test contracts can be chosen for testing. Replace <contract name> with full or partial contract name:

forge test --match-contract <contract name> or forge test --mc <contract name>

Creating a new test

I don't want to have to think about avoiding contract naming collision, so each new test file is prefixed with a number, and all the contract names in that file have that same number as a suffix.

There's now a script to generate a new file with a contract and empty test function. Just run the following replacing <test_name> with the name of your test (file naming conventions apply, avoid spaces). Or omit the test name to invoke interactive mode.

./newTest.sh <test name>

Yul code

Occasionally it's helpful to generate the Yul intermediate representation to understand what's happening underneath the hood. In that case, I'll just use a command like the following to put the IR into the ./ir dir. Using a .sol extension gives pretty decent syntax highlighting for readability.

forge inspect Target16 ir >! ir/bytesArgLenCheck16.yul.sol

Yul code can be compiled with solc --strict-assembly.

Advanced Installation Tip

You can create a bash function that will change directories and call newTest. Add it to your .bashrc file so you can call scratch from anywhere!

scratch() {
  cd <path to solidity-sandbox>
  bash newTest.sh $1
}

solidity-sandbox's People

Contributors

maurelian avatar devtooligan avatar mds1 avatar

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.