Firewall Documentation
Home
  • Overview
  • Quick Start
    • Using Function Modifiers
    • Using Proxy Patterb
  • Concepts
  • Configuration
    • Governance
    • Firewall Configuration
    • Policy Administration
  • How It Works
  • Smart Contracts
    • Firewall.sol
    • FirewallConsumer.sol
    • FirewallProxyAdmin.sol
    • FirewallTransparentUpgradableProxy.sol
  • Policies
    • Admin Notary
    • Whitelist
    • Approved Calls
    • Approved Patterns
    • Balance Guard
    • EOA Only
    • Method Block
    • Custom Protector
    • Non Reentrant
    • Combined Policies
  • Addresses
  • Glossary
  • Support
  • FAQ
Powered by GitBook
On this page
  • Step By Step
  • Example
  • Next Steps
  1. Quick Start

Using Function Modifiers

PreviousQuick StartNextUsing Proxy Patterb

Last updated 11 months ago

Step By Step

  1. Install the Ironblocks CLI Tool into your project by running: npm install @ironblocks/cli

  2. From your project's root directory, run the Firewall Integration command: npx ib fw integ -d ./contracts

    1. ib is

    2. fw integ runs the Integration command for the Firewall module of our tool

    3. -d ./contracts points to your smart contracts directory

  3. Running the command above will make the following changes in your project:

    1. Auto-Install the Firewall's dependencies

    2. Make your contracts inherit from

    3. Add the modifier to any external function (excluding view functions)

  4. That's it! Your smart contracts are now ready to use Ironblocks' Firewall.

Example

The following smart contract shows a typical integration of our Firewall into a consumer protocol:

pragma solidity ^0.8.19;

import "@ironblocks/firewall-consumer/FirewallConsumer.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Address.sol";

//
// STEP 1: Inherit from our FirewallConsumer
//
contract SampleConsumer is FirewallConsumer, Ownable {

    mapping (address => uint) public deposits;
    
    constructor() {}
  
    //
    // STEP 2: Add the "firewallProtected" modifier to functions you wish to protect
    //
    function deposit() external payable firewallProtected {
        deposits[msg.sender] += msg.value;
    }

    function withdraw(uint amount) external firewallProtected {
        deposits[msg.sender] -= amount;
        Address.sendValue(payable(msg.sender), amount);
    }

    function setOwner(address newOwner) external onlyOwner firewallProtected {
        _transferOwnership(newOwner);
    }
}

Next Steps

Head on to the section to learn more about security policy management.

Review our

Configuration
Smart Contracts
Ironblocks' CLI tool
FirewallConsumer
firewallProtected