This repository is a compendium of tools, libs and contracts, used to learn more about the midnight network. Tools and utilities are primarily targeted for easier development and debugging the contracts and work with midnight network, and should not be used in production environment.
Code is structured in such way, to expose each concept individually, allowing quick overview how to do (or not to do) things.
Clone the repo, while initializing the submodules:
$ git clone --recurse-submodules [email protected]:a-kyras/cap.git
$ git clone --recurse-submodules https://github.com/a-kyras/cap.gitIf you already cloned the repo, but without submodules, you can initialize them with:
$ git submodule update --init --recursiveAfter that, just install the dependencies, included libraries and contracts:
$ npm i
$ npm run buildEach implemented tool, has its own section in this doc how to use it, with its own README describing supported commands in detail.
All implemented apps have npm script with same name as the name of the tool, and another one with the prefix sa-*. Tooling, by default targets the
testnet environment. The sa- variants will run against local standalone network, simplifying
the work with the tools.
Tooling allowing to work with a Midnight wallet from the command line. Allowing same functionality as the Lace wallet with additional functionality, allowing CLI scripting and convenience. Read more here.
Tooling aggregating common contract operations. Currently supports only pre-compiled contract stored in the contract lib. More info about supported commands here.
Specialized CLI tool, specifically made to work with vesting smart contract.
The testnet environment is slow, often unavailable and often just broken. For better experience I suggest you using a standalone network. This is a single node running on local computer, acting as an independent network.
The default proof server that is suggested to be used with midnight, come with pre-baked parameter up to complexity of 15. The vestment circuit claim
has complexity of k=16. The proof server often fails to download correct parameters, and interactions with this contract is impossible without those
parameters, as all calls to the circuit will fail, as the transaction cannot be proved. For this, it is required to build a proof server with pre-baked parameters
that are download during building of the image.
First, make sure that the submodules are initialized and up-to-date:
$ git submodule update --init --recursiveCheck that folder midnight-proof-server exists, and is non-empty, and that it contains a Dockerfile.
Then build the image, executing this command in the root directory:
$ docker build -f midnight-proof-server/Dockerfile --build-arg CIRCUIT_PARAM_RANGE="10 11 12 13 14 15 16" -t midnight-proof-server:prebaked ./midnight-proof-serverThen just run docker-compose to run all required images:
$ docker compose -f ./standalone.docker-compose.yml up -dMake sure that the components are up and running. In you browser go to:
localhost:6300
loclahost:9944
localhost:8088/health
You should see a positive message there.
There is no dev faucet for the standalone network. Only way to obtain tDust, is to transfer it from the genesis wallet. There is a scrip included to simply do so:
$ npm run create-standalone-genesis-walletYou should see a new file created in the root directory called genesis.sa.wallet.json. You can easily transfer funds from this wallet using the wallet-cli:
$ npm run sa-wallet-cli -- generate -o my.wallet.json --seed 56620405c44b20effc617e66bff8f4f58ac15f2ab0cc0d7ee08a1a1a381dbb3d
$ npm run sa-wallet-cli -- transfer --wallet ./genesis.sa.wallet.json --receiver mn_shield-addr_undeployed1229xz8d0atn5lay5kw9gsv5s2hrtlwmr3n345u924u8r3zllvprsxqxu3dlzq0g5v4qcs7dv8ehv79a47hj4utkwmm5m46cdur2srtyfzvh7xmwu --amount 1000000Or you can just use genesis wallet instead of own wallet, there is no mnemonics for it, so you cannot interoperate it with Lace wallet from browser.