The Narya CLI tool is a powerful command-line interface that enables you to build and test your smart contract project, and interact with Narya services. In this guide, we'll show you how to install and use Narya CLI to run tests locally.
To install Narya CLI, simply run the following command in your terminal:
curl -L https://raw.githubusercontent.com/NaryaAI/narya-cli/main/script/install | bash
This command downloads and installs Narya CLI to your machine, and adds it to your
If you need to upgrade Narya CLI to the latest version, you can run:
This command will upgrade Narya CLI to the latest version available.
To initialize your Narya project, run:
This command installs the dependencies and Narya SDK, creates a test/invariants directory, and sets up remapping to use the Narya SDK.
To run invariant and property tests, run:
This command compiles your project and runs the tests automatically.
The output will show you the status of the tests, including whether they have passed or failed. For example:
$ narya test Building project... Testing... Tests (4) [√] test/invariants/FundLossTest_1671121896.sol:FundLossTest:invariantCheckFund() [√] test/invariants/FundLossTest_1671156195.sol:FundLossTest:invariantCheckFund() [√] test/invariants/FundLossTest_1671181213.sol:FundLossTest:invariantCheckFund() [✕] test/invariants/OwnerNotChangedTest_1672380141.sol:OwnerNotChangedTest:invariantOwnerNotChanged()  OwnerNotChangedTest::invariantOwnerNotChanged() ├─  OwnerNotChangedTest::getOwner() │ └─ ← 0x0000000000000000000000000000000000000000 └─ ← "Ownership changes!" Total: 4, Success: 3, Fail: 1 Time: 26s The following invariant(s) reverted, it's likely the Narya engine will also fail if push as-is. • File: test/invariants/OwnerNotChangedTest_1672380141.sol, Contract: OwnerNotChangedTest, Function: invariantOwnerNotChanged() A Test report generated at ./reports/report_1672973405.zip. To view the report, visit the following URL and upload the report zip file: https://app.narya.ai/debugger Please refer to the call trace for more information and try running the test again after fixing the issue.
To work with Narya templates, you can use the
narya template subcommand. Narya templates are pre-written invariant tests that you can use to test your smart contract.
To list available templates, run:
To install a specific Narya template, run:
narya template --install <template_name>
Narya CLI collects anonymous usage data and metrics to help improve the tool. If you prefer to opt-out of metrics upload, run:
Alternatively, you can set the environment variable
Now it's time to push the code and run the tests on the powerful cloud engine to battle test your contracts!