This is an attempt to bring together four tools for local development and debugging of smart contracts for Tezos:
- Granary — all-in-one toolkit for smart contract development;
- LIGO — high-level smart-contract language that compiles down to Michelson;
- PyTezos — Python SDK for Tezos;
- Better Call Dev — Michelson contract explorer.
Granary contains Tezos node (with client), and LIGO compiler, and also a set of scripts that control the containers and ease the interaction. It's shipped as npm package, and you need to have docker and node.js v11.4+ previously installed. See granary documentation for additional information.
PyTezos requires python 3.6+ installed and several system libraries: libsodium libsecp256k1 and libgmp . Check pytezos documentation for OS-specific instructions.
Clone the repository and install dependencies:
git clone https://github.com/baking-bad/tezos-nft-sample
cd tezos-nft-sample
npm i
pip install -r requirements.txtWe need to initialize Granary settings before the first launch:
npm run initNow can start the Tezos node:
npm run startAwesome! Next step is adding several accounts and activating protocol:
npm run activate-alphaThat's it! There are few more commands you can use to control the node:
# Stop the node
npm run stop
# Remove all granary settings brought by init
npm run clean
# stop + clean + init + start + activate-alpha
npm run resetIn this sample project we have LIGO sources in src directory and unit tests in tests
LIGO compiler is executed in a docker container, and it compiles all .ligo files in src folder down to Michelson.
npm run compileAtm compilation errors are not visible in the terminal, so you have to open the file to read them, but this will be resolved soon.
After we received Michelson sources we can use PyTezos high-level interface to write unit tests. If you are familiar with the unittest module in Python that will be super easy, if not - also easy :)
npm run testThe following commands are project specific and utilize pytezos-based client module. You can use standard tezos-client instead.
PyTezos client has several useful features, first automatic generation of the initial storage, and secondly implied interface annotations. This means that even if your code is not annotated, if it implements a well-known interface, the necessary annotations will be added to it (optional of course).
python -m client originate
npm run bakeThere will be link in the terminal output containing originated contract id. It will be used in the following calls. The link leads to a page in the Michelson contract explorer (BCD), where you can inspect all the operations, script, and state.
python -m client mint --contract-id={contract_id} --token-id=42
npm run bakepython -m client burn --contract-id={contract_id} --token-id=42
npm run bakeThis is how it's displayed at https://better-call.dev/sandbox/{contract_id}
Ask any question about PyTezos, Better Call Dev in Baking Bad telegram chat: https://t.me/baking_bad_chat

