@vennbuild/cli
v1.0.10
Published
Venn Network CLI
Downloads
722
Readme
Venn CLI
Venn's command line interface for quick and easy setup of Venn Security Network
🚀 Quick Start
Follow these steps to secure your contracts with Venn:
Install the CLI globally by running:
npm i -g @vennbuild/cli
Auto-import the Firewall into your smart contracts by running:
venn fw integ -d contracts
Deploy your contracts like you normally would to any network
Finally, connect your contracts to Venn by running:
venn enable --network holesky
Table of Contents
- 🚀 Quick Start
- 📦 Installation
- 📚 Usage
- ⚙️ Configuration File
- ⚡ Available Commands
- 💬 Support & Documentation
- 📜 License
📦 Installation
npm install -g @vennbuild/cli
💡 Note: Venn CLI is compatible with Solidity versions
>= 0.8
📚 Usage
There are 3 steps to the integration.
First, add the Firewall SDK to your smart contracts, and deploy them as your would normally deploy to any network.
Next, connect your deployed smart contracts to Venn.
Now that your project is secure, only approved transactions will go through.
To approve transactions, make sure to add the Venn DApp SDK to your DApp's frontend.
Firewall Integration
This integration will add the Firewall SDK to your smart contracts, making sure that they import the relevant modifiers, and apply the modifiers on external functions.
Automatic Integration With CLI
Auto-import the Firewall SDK into all of your smart contracts in one go by running:
venn fw integ -d contracts
This command will scan all your smart contracts under the contracts
folder, and add an import of the VennFirewallConsumer
Firewall SDK.
Before
pragma solidity ^0.8;
contract MyContract {
myMethod() {
...
}
}
After
pragma solidity ^0.8;
import {VennFirewallConsumer} from "@ironblocks/firewall-consumer/contracts/consumers/VennFirewallConsumer.sol";
contract MyContract is VennFirewallConsumer {
myMethod() firewallProtected {
...
}
}
See the Available Commands section below for additional integration options
Venn Integration
This integration will connect your Firewall protected smart contracts to the Venn Network onchain. It does this by sending setup transactions onchain to register your smart contracts with Venn.
Prerequisites
Make sure your smart contracts are deployed and that you have completed the Firewall Integration step above
You will need your private key for this step
Configuration
Create a new file called
venn.config.json
Add the following configuration snippet to it:
{ "networks": { "holesky": { "contracts": { "MyContract1": "0x1234abcd1234abcd1234abcd1234abcd1234abcd", "MyContract2": "0x1234abcd1234abcd1234abcd1234abcd1234abcd", } } } }
- Each key in the
contracts
object is the Name of the contract - Each value in the
contracts
object is the Address of the contract
- Each key in the
Create a new environment variable called
VENN_PRIVATE_KEY
with the private key that deployed your smart contracts⚠️
IMPORTANT: This key must be the same key that deployed the smart contracts
Connect To Venn
Run the following command to connect your Firewall protected smart contracts to Venn:
venn enable --holesky
Your Venn Policy
After successfully connecting to Venn, a new Venn Security Policy will have been created for you.
The address of the policy will be saved in venn.config.json
:
{
"networks": {
"holesky": {
"contracts": {
"MyContract1": "0x1234abcd1234abcd1234abcd1234abcd1234abcd",
"MyContract2": "0x1234abcd1234abcd1234abcd1234abcd1234abcd",
},
// YOUR VENN POLICY ADDRESS
"policyAddress": "0x123..."
}
}
}
You will need this address when integrating the Venn DApp SDK
⚙️ Configuration File
Venn CLI uses venn.config.json
as it's configuration file, expected at the root folder of your project.
Overall, the configuration file has the following structure:
{
"fw": { /* ... */ },
"network": { /* ... */ }
}
Firewall Configuration
For the Firewall integration, you can configure which folders to include or exclude from the integration, using the following configuration:
{
"fw": {
"integ": {
"include": ["my/contracts/folder"],
"exclude": ["tests/fixtures/**/*.sol"],
}
}
}
Include
Acts as a whitelist.
If this configuration is not empty, only files inside the configured folders will be integrated with the Firewall SDK.
Exclude
Acts as a blacklist.
If this configuration is not empty, files inside the configured folders will not be integrated.
Venn Configuration
For the Venn Integration, you configure which networks
to integrate with, and list the contracts that you have deployed per networks:
Smart Contracts
{
"networks": {
"holesky": {
"contracts": {
"MyContract1": "0x1234abcd1234abcd1234abcd1234abcd1234abcd",
"MyContract2": "0x1234abcd1234abcd1234abcd1234abcd1234abcd",
}
}
}
}
Note that the key
is the name of the contract, and the value
is the address of the contract.
Private Key
When Venn CLI registers your smart contracts with Venn onchain, it sends several setup transactions for this registration to happen.
The account that signs these transactions is provided to the CLI by setting the following environment variable:
VENN_PRIVATE_KEY
The account that owns the deployed contracts
⚡ Available Commands
venn
This is the root command.
Available Options
--help
show help information--version
show version information
venn fw integ
Subcommand for managing the Firewall SDK integration with your smart contracts.
Available Options
-f, --file <file path>
specify a single smart contract file for the integration-d, --dir <folder path>
specify a directory of smart contracts for the integration-r, --rec
if specified, will recursively look in<folder path>
from--dir
-v, --verbose
show verbose logging
Examples
A single contract
venn fw integ -f contracts/MyContract.sol
A single folder
venn fw integ -d contracts/vault
All contracts
venn fw integ --r -d contracts
venn enable
Register your Firewall protected smart contracts with Venn.
Available Options
--network <network>
the network where your smart contracts are deployed to
Examples
Enable Venn
venn enable --network holskey
venn disable
Unregister your Firewall protected smart contracts from Venn.
Available Options
--network <network>
the network where your smart contracts are deployed to
Examples
Disable Venn
venn disable --network holskey
💬 Support & Documentation
We're here to help.
Join the discussion on Discord: Venn Discord
Read the docs: Venn Documentation
📜 License
Venn CLI is released under the MIT License.
The Venn CLI showcases how to easily integrate with Ironblocks' Firewall.