Write, test and deploy high-quality smart contracts to the Stacks blockchain and Bitcoin.
@hugocaillard @MicaiahReid
Special thanks to @friedger and @obycode for the bug reports and the great suggestions
@hugocaillard @MicaiahReid
--no-dashboard
(#1357) (fad5c763)@diempi @hugocaillard @MicaiahReid @tippenein
clarinet console
(#1330) (fdf400b7)Credits
The Nakamoto Preview version of Clarinet can be used to run Nakamoto Neon in the Devnet.
Download the right clarinet-cli binary for your OS in the GitHub release, or build from the chore/upgrade-clarity-vm
branch.
In a Clarinet project (it can be freshly created with clarinet new <project>
), the use_nakamoto
option can be set to true:
# settings/Devnet.toml
# [networks]
# ...
[devnet]
use_nakamoto = true
# ...
The use_nakamoto
setting will use Nakamoto Docker images for stacks-node and stacks-api.
Make sure that the stacking orders setting at the end of this file are set to start at cycle 2. This will ensure that there are some stacked STXs in pox-4 before the switch to epoch-3.0. Which will happen, by default, at Bitcoin block 121. If the stacking orders are not received before the prepare phase of epoch 3.0's first reward cycle, then 3.0 blocks will not be able to be mined.
# settings/Devnet.toml
# [networks]
# ...
[[devnet.pox_stacking_orders]]
start_at_cycle = 2 # stack some stx in cycle 2
duration = 12
wallet = "wallet_1"
slots = 2
btc_address = "mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC"
[[devnet.pox_stacking_orders]]
start_at_cycle = 2
duration = 12
wallet = "wallet_2"
slots = 2
btc_address = "muYdXKmX9bByAueDe6KFfHd5Ff1gdN9ErG"
[[devnet.pox_stacking_orders]]
start_at_cycle = 2
duration = 12
wallet = "wallet_3"
slots = 1
btc_address = "mvZtbibDAAA3WLpY7zXXFqRa3T4XSknBX7"
Start the devnet with clarinet devnet start
(or just clarinet integrate
which is the "old" alias).
The blockchain will do its things and begin to produce Stacks blocks. At Bitcoin block #114, you should see the pox-4 stacking transactions. At Bitcoin block #121, allow some time for the miner to switch to epoch 3.0.0. This is where Nakamoto Neon starts. Note that you will see several Bitcoin blocks with no Stacks blocks during this switchover. Also note that these block numbers could change if you manually modify the configuration.
From there, enjoy the "tenure change" transactions and the fast Stacks blocks. It will basically mine a new Stacks block everytime there's a transaction in the mempool.
This new Clarinet release preview also handles Clarity Wasm in both the Devnet and with the clarinet console
Another stacks-node Docker image is available to use Clarity Wasm in the Devnet. You can set this image in the Devnet config. This version of the node will automatically compile and execute Smart Contract deployed after epoch 3.0 with clarity-wasm.
# settings/Devnet.toml
# [networks]
# ...
[devnet]
use_nakamoto = true
stacks_node_image_url = "blockstack/stacks-blockchain:feat-clarity-wasm-next-devnet"
# ...
In your project's manifest (Clarinet.toml
), make sure to have a countract that is deployed in epoch 3.0, for example:
[contracts.counter]
path = 'contracts/counter.clar'
clarity_version = 2
epoch = 3.0
clarinet console
The clarinet console
will always run the current Clarity interpreter and the new Clarity Wasm runtime side by side, and print the the execution time. It will also print a warning if the results are different. If you see a case where the results are different, please report it to the Clarity-Wasm repo Expect more optimization in Clarity-Wasm soon, but the benefits can already be seen on large transactions. In its current state, it is not unexpected for simple contract calls to be slower in Clarity-Wasm than in the interpreter.
This is a preview release, so please keep in mind that it can lack optimization and stability at many levels.
If you occasionally see that you Devnet gets stuck at Bitcoin block #121 for multiple minutes, just stop it and give it another try.
It may happen that Docker doesn't properly stop the containers for some reason. In this case, you'll need to manually make sure to stop them if your next run of the devnet doesn't start. Running docker network prune
can also help when the network is not properly cleaned up.