# Using Function Modifiers

## Step By Step

1. Install the **Ironblocks CLI Tool** into your project by running:\
   `npm install @ironblocks/cli` \ <br>

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

   1. **`ib`** is [Ironblocks' CLI tool](https://www.npmjs.com/package/@ironblocks/cli)
   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:<br>
   1. Auto-Install the Firewall's dependencies
   2. Make your contracts inherit from [`FirewallConsumer`](/firewall/smart-contracts/firewallconsumer.sol.md)
   3. Add the [`firewallProtected`](/firewall/smart-contracts/firewallconsumer.sol.md#firewallprotected) modifier to any external function *(excluding **`view`** functions)*\ <br>

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

## Example

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

```sol
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);
    }
}
```

<br>

## Next Steps

* Head on to the [Configuration](/firewall/configuration.md) section to learn more about security policy management.<br>
* Review our [Smart Contracts](/firewall/smart-contracts.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ironblocks.com/firewall/quick-start/using-function-modifiers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
