This is a framework for getting started with Solidity, deployment of contracts, and unit testing. Basically what the Truffle framework does best.
The approach is the same as fiveogit's great repo solidity-baby-steps
Truffle/web3.js is under heavy development - does it still compile?:
- Download/clone this code repository a. Navigate to the folder in a terminal/command prompt
- Install the dependencies See Installing
- Create a new contract and unit tests
a. Add
contracts/HelloWorld.sol
andtest/HelloWorld.test.ts
b. Optional: Usenode tools/gen.js HelloWorld
to generate a contract called HelloWorld - Run it! See [The development loop](#The development loop)
The web3.js and Truffle frameworks are very comprehensive in functionality, they bundle many other libraries, it is only rational to have your editor auto-complete and type-check as you write/learn. Types are documentation; Self-explanatory code is easier to read and navigate.
Start a local blockchain using Ganache npm run ganache
The general way to develop and continously run the tests goes like this:
- Try entering
ethereum/
and runnpx truffle
to see Truffles help menu appear, it should work - Place a new smart contract in
contracts/
eg.HelloWorld.sol
- Run
npx truffle compile
to compile the solidity (in theethereum/
folder), fingers crossed it compiles!!? - When the solidity compiles, you can then build TypeScript interfaces:
npm run type-contracts
- Write unit tests in TypeScript, have your favorite editor compile it, or run
npm run compile-tests
manually - Run
npx truffle test
to run Truffle unit tests (in theethereum
folder)
- We need to install NodeJS and NPM
- Install the dependencies with
npm install
(no global dependencies required)