Installation

Overview

To protect your protocols with Venn, you'll need the to:

  1. Make sure you've integrated the Firewall SDK with your smart contracts

  2. Registered your smart contracts onchain with Venn

  3. Install the DApp SDK on your Frontend

We've build tools and SDKs to streamline each of these steps, providing the ultimate developer experience without compromising security.

Quick Setup

1. Venn CLI

To kick things off, start by installing the Venn CLI by running:

npm i -g @vennbuild/cli

You will use this CLI to add the Firewall SDK to your smart contracts, as well as register your smart contracts onchain with Venn.

The CLI will make the venn command available globally.

2. Firewall SDK

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.

Run the following command from the root folder of your project:

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 {
        ...
    }
}

Now that your smart contracts include the Firewall SDK, deploy them as you normally would onto any network, and you're ready to move on to registering them onchain with Venn.

3. Register With Venn

This step 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.

Before You Begin

  1. Make sure your smart contracts are deployed and that you have completed the Firewall SDK setup 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 use the policyAddress in the next step when setting up your DApp Frontend

4. DApp SDK

Now that your smart contracts are protected by Venn, only approved transactions can be executed onchain.

Setup

To streamline the process of approving transactions from a DApp Frontend, install the DApp SDK:

npm i @vennbuild/venn-dapp-sdk

Create An Instance

import { VennClient } from '@vennbuild/venn-dapp-sdk';

const vennURL           = process.env.VENN_NODE_URL;
const vennPolicyAddress = process.env.VENN_POLICY_ADDRESS;

const vennClient = new VennClient({ vennURL, vennPolicyAddress });
  • vennURL: a URL pointing to a Venn node operator

  • vennPolicyAddress: the policyAddress you got from the "Register With Venn" step above

Approving Transactions

const approvedTransaction = await vennClient.approve({
    from,
    to,
    data,
    value
});

// You can now send the approvedTransaction as you normally would
const receipt = await wallet.sendTransaction(approvedTransaction);

Reference Documentation

Last updated