> For the complete documentation index, see [llms.txt](https://ret2basic.gitbook.io/ctfnote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ret2basic.gitbook.io/ctfnote/web3-security-research/foundry/remappings.md).

# Remappings

{% embed url="<https://youtu.be/7DK75j8csTA>" %}

## Solmate (forge remappings)

Install solmate:

```bash
forge install rari-capital/solmate
```

Create an ERC20 contract:

```solidity
pragma solidity ^0.8.17;

import "solmate/tokens/ERC20.sol";

contract Token is ERC20("name", "symbol", 18) {}
```

Build:

```bash
forge build
```

See what libraries have been installed:

```bash
$ forge remappings

ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
solmate/=lib/solmate/src/
```

Here `solmate` is remapped to `lib/solmate/src/`.

## OpenZeppelin Contracts (remappings.txt)

Some libraries, such as OpenZeppelin contracts, should be installed via npm:

```bash
mkdir node_modules && npm i @openzeppelin/contracts
```

We run `mkdir` first because node modules can be install locally or globally. Reference:

{% embed url="<https://stackoverflow.com/questions/14032160/npm-install-module-in-current-directory>" %}

In contract, import OpenZeppelin `Ownable`:

```solidity
import "@openzeppelin/contracts/access/Ownable.sol";
```

We have to create a `remappings.txt` file for this import statement to make sense:

```
@openzeppelin/=node_modules/@openzeppelin
```

Update our contract:

```solidity
pragma solidity ^0.8.17;

import "solmate/tokens/ERC20.sol";

contract Token is ERC20("name", "symbol", 18) {}

import "@openzeppelin/contracts/access/Ownable.sol";

contract TestOz is Ownable {}
```

Build it:

```bash
forge build
```

<figure><img src="/files/7jYRq5mcxhoGE7DF5hCy" alt=""><figcaption><p>Build succeeded</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://ret2basic.gitbook.io/ctfnote/web3-security-research/foundry/remappings.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
