Stacks local development environment for clarity contracts
Development environment for Stacks smart contracts with support for unit tests and integration tests
- ➤ Local testnet
- ➤ Getting started
- ➤ Development of smart contracts
- ➤ Unit tests
- ➤ Integration tests
- ➤ Contributors
- ➤ License
The docker folder contains a docker-compose configuration to run a local testnet Stacks blockchain environment from scratch
This starts the following private testnet components:
- Postgres database
- Bitcoin -
puppet chain - Stacks node
- Stacks api
- Local stacks blockchain explorer
It contains two docker-compose files:
- bns.yaml
- docker-compose.yaml
If you want to import BNS data you should run
$> docker-compose -f bns.yaml pull
$> docker-compose -f bns.yaml build
$> docker-compose -f bns.yaml up
This will import bns data into the /bns-data folder.
Moving forward, starting the stack:
$> docker-compose pull
$> docker-compose build
$> docker-compose up
Note:
If you do not want to import bns data, then you will need to comment out the environment line BNS_IMPORT_DIR: /bns-data from the stacks-blockchain-api container, otherwise the container will panic if it doesn't find the files
If you did import the bns data, you need to uncomment (if previously commented out) the environment line above and be aware that the stacks-blockchain will experience Connection refused problems from stacks-blockchain-api for the duration of bns data import. After the import, the API will become ready and accept events from stacks-blockchain node
When getting started with developing smart contracts, you need to first install the packages by calling
./install.sh
This installs a certain version of clarity-cli we're using to interact with the smart contracts locally in unit-test mode
The contracts folder contains some example smart contracts already included.
When developing/updating a new smart contract you need to generate:
- Abi json file
- Typescript interface file
- Index file exposing a neat and simple way of accessing the smart contract interface
You can do all that by running:
yarn generate
When writing unit tests you can use the examples included in /test/counter.test.ts
When writing integration tests you can use the example included in /test/integration.test.ts
The way we run it is:
First, start the local testnet by doing
$> cd docker && docker-compose up
Wait until the local testnet is fully started and then execute the integration test
$> yarn integration
| Doru Cioclea Octavian | You? |
| 🔥 |
Licensed under ISC.
