Skip to content

ironblocks/cli

Repository files navigation

Venn CLI

NPM Version TypeScript Jest ESLint
Discord X License

Venn's command line interface for quick and easy setup of Venn Security Network

👉 What is Venn?

venn enable

🚀 Quick Start

Follow these steps to secure your contracts with Venn:

  1. Install the CLI globally by running:

    npm i -g @vennbuild/cli
  2. Auto-import the Firewall into your smart contracts by running:

    venn fw integ -d contracts
  3. Deploy your contracts like you normally would to any network

  4. Finally, connect your contracts to Venn by running:

    venn enable --network holesky

Table of Contents

📦 Installation

npm install -g @vennbuild/cli

💡 Note: Venn CLI is compatible with Solidity versions >= 0.8

📚 Usage

There are 3 steps to the integration.

  1. First, add the Firewall SDK to your smart contracts, and deploy them as your would normally deploy to any network.

  2. Next, connect your deployed smart contracts to Venn.

  3. 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

  1. Make sure your smart contracts are deployed and that you have completed the Firewall Integration step above

  2. You will need your private key for this step

Configuration

  1. Create a new file called venn.config.json

  2. 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
  3. 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.

📜 License

Venn CLI is released under the MIT License.

The Venn CLI showcases how to easily integrate with Ironblocks' Firewall.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •