Harness the power of OpenZeppelin’s contract to kickstart your smart contact development, wherever you are Table of Contents i. Introductionii. Installing OpenZeppelin locallyiii. Importing contractsiv. Remapping OpenZeppelin pathv. Conclusion IntroductionPhoto by Zoltan Tasi on Unsplash Crypto space enables you a high level of freedom to design your own decentralized architecture for whatever idea you have, but embracing the ecosystem, there are some standards you will need to follow to properly create an asset up to the . Standards like ERC20, ERC721, ERC1155 are some of the technical specifications to guide what functionalities an asset should have. To follow these standards, you can either look into the paper of the ERCs and implement all the functions yourself, or you use the templates from the community. OpenZeppelin provides production-ready code templates that has been tested and reviewed by the Ethereum community and is a trusted source to provide foundation for you to build your project on. This tutorial is for providing guides on installing OpenZeppelin locally in your computer, if you are using web IDE such as Remix, there will be no need for this as they are already taken care for you by the online IDE. Installing OpenZeppelin locally To install OpenZepplin, you will need to have Node.js with npm installed first, you can find it here on the official Node.js website if you have not. After that, the installation is as simple as going to the root directory of your contract folder, and run npm install @openzeppelin/contracts and you are good to go. Importing contracts Importing contacts is easy as well thanks to Solidity import syntax, choose an template you would like to import, such as ERC20 or some of its presets, ERC20PresetMinterPauser that has role-based access implemented, and include that in your contract, // SPDX-License-Identifier: MITpragma solidity >=0.4.22; ... import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; ... and inhert the template in your contract contract Sample_Contract is ERC20 { ... All functionalities from the parent contract will now be included in your contract. Remapping OpenZeppelin path Sometimes having OpenZepplin in its default node_modules path is not ideal. The ability to custom configure the path to look for contracts in OpenZeppelin is necessary for different cases, such as having a monorepo, to contruct a self-defined folder structure, or even to have an one-time global setup. A project often does not only contain the smart contract component, but also components like frontend, backend, database etc. Adopting monorepo structure can help to provide a better organization over the whole project. If you are not familiar with the concept of monorepo, you can read more here. To put it simple, a monorepo structure means that all components of the project are put and maintained in a single repository. If you only install the contracts in your contract folder, you will realized that once you change the folder structure, or open the project in your root folder, your local IDE can no longer scan your imported files. Instead, an error prompting you that the contracts are not found will pop up.error with message files not found To fix these, you can create a new file in your root folder, or whatever location you plan to open your project with, named remappings.txt . In this file, including the following line, @openzeppelin/=<path_to_your_installed_location>/@openzeppelin/ This tells the IDE where to look for your installed contracts and scan for the specified location. Not only can you specify contracts from OpenZeppelin, but you may also include modules like ChainLink, @chainlink/=<path_to_your_installed_location>/@chainlink/ and others. Now the error should be gone after you specify the path to search for the contracts,errors are gone and the files can be scanned Conclusion This is a very simple guide to show you how remappings.txt can help you to organize your import better. You can also refer to my monorepo that has multiple Solidity projects, all pointing to the same import path here. Good luck on your development! Want to Connect? You can find me at Twitter Github Discord. Setting up OpenZeppelin for Solidity in your local environment with path remappings was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this storyHarness the power of OpenZeppelin’s contract to kickstart your smart contact development, wherever you are Table of Contents i. Introductionii. Installing OpenZeppelin locallyiii. Importing contractsiv. Remapping OpenZeppelin pathv. Conclusion IntroductionPhoto by Zoltan Tasi on Unsplash Crypto space enables you a high level of freedom to design your own decentralized architecture for whatever idea you have, but embracing the ecosystem, there are some standards you will need to follow to properly create an asset up to the . Standards like ERC20, ERC721, ERC1155 are some of the technical specifications to guide what functionalities an asset should have. To follow these standards, you can either look into the paper of the ERCs and implement all the functions yourself, or you use the templates from the community. OpenZeppelin provides production-ready code templates that has been tested and reviewed by the Ethereum community and is a trusted source to provide foundation for you to build your project on. This tutorial is for providing guides on installing OpenZeppelin locally in your computer, if you are using web IDE such as Remix, there will be no need for this as they are already taken care for you by the online IDE. Installing OpenZeppelin locally To install OpenZepplin, you will need to have Node.js with npm installed first, you can find it here on the official Node.js website if you have not. After that, the installation is as simple as going to the root directory of your contract folder, and run npm install @openzeppelin/contracts and you are good to go. Importing contracts Importing contacts is easy as well thanks to Solidity import syntax, choose an template you would like to import, such as ERC20 or some of its presets, ERC20PresetMinterPauser that has role-based access implemented, and include that in your contract, // SPDX-License-Identifier: MITpragma solidity >=0.4.22; ... import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; ... and inhert the template in your contract contract Sample_Contract is ERC20 { ... All functionalities from the parent contract will now be included in your contract. Remapping OpenZeppelin path Sometimes having OpenZepplin in its default node_modules path is not ideal. The ability to custom configure the path to look for contracts in OpenZeppelin is necessary for different cases, such as having a monorepo, to contruct a self-defined folder structure, or even to have an one-time global setup. A project often does not only contain the smart contract component, but also components like frontend, backend, database etc. Adopting monorepo structure can help to provide a better organization over the whole project. If you are not familiar with the concept of monorepo, you can read more here. To put it simple, a monorepo structure means that all components of the project are put and maintained in a single repository. If you only install the contracts in your contract folder, you will realized that once you change the folder structure, or open the project in your root folder, your local IDE can no longer scan your imported files. Instead, an error prompting you that the contracts are not found will pop up.error with message files not found To fix these, you can create a new file in your root folder, or whatever location you plan to open your project with, named remappings.txt . In this file, including the following line, @openzeppelin/=<path_to_your_installed_location>/@openzeppelin/ This tells the IDE where to look for your installed contracts and scan for the specified location. Not only can you specify contracts from OpenZeppelin, but you may also include modules like ChainLink, @chainlink/=<path_to_your_installed_location>/@chainlink/ and others. Now the error should be gone after you specify the path to search for the contracts,errors are gone and the files can be scanned Conclusion This is a very simple guide to show you how remappings.txt can help you to organize your import better. You can also refer to my monorepo that has multiple Solidity projects, all pointing to the same import path here. Good luck on your development! Want to Connect? You can find me at Twitter Github Discord. Setting up OpenZeppelin for Solidity in your local environment with path remappings was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story

Setting up OpenZeppelin for Solidity in your local environment with path remappings

2025/09/10 22:25

Harness the power of OpenZeppelin’s contract to kickstart your smart contact development, wherever you are

Table of Contents
i.   Introduction
ii. Installing OpenZeppelin locally
iii. Importing contracts
iv. Remapping OpenZeppelin path
v. Conclusion

Introduction

Photo by Zoltan Tasi on Unsplash

Crypto space enables you a high level of freedom to design your own decentralized architecture for whatever idea you have, but embracing the ecosystem, there are some standards you will need to follow to properly create an asset up to the . Standards like ERC20, ERC721, ERC1155 are some of the technical specifications to guide what functionalities an asset should have.

To follow these standards, you can either look into the paper of the ERCs and implement all the functions yourself, or you use the templates from the community.

OpenZeppelin provides production-ready code templates that has been tested and reviewed by the Ethereum community and is a trusted source to provide foundation for you to build your project on.

This tutorial is for providing guides on installing OpenZeppelin locally in your computer, if you are using web IDE such as Remix, there will be no need for this as they are already taken care for you by the online IDE.

Installing OpenZeppelin locally

To install OpenZepplin, you will need to have Node.js with npm installed first, you can find it here on the official Node.js website if you have not.

After that, the installation is as simple as going to the root directory of your contract folder, and run

npm install @openzeppelin/contracts

and you are good to go.

Importing contracts

Importing contacts is easy as well thanks to Solidity import syntax, choose an template you would like to import, such as ERC20 or some of its presets, ERC20PresetMinterPauser that has role-based access implemented, and include that in your contract,

// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22;
...
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
...

and inhert the template in your contract

contract Sample_Contract is ERC20 {
...

All functionalities from the parent contract will now be included in your contract.

Remapping OpenZeppelin path

Sometimes having OpenZepplin in its default node_modules path is not ideal. The ability to custom configure the path to look for contracts in OpenZeppelin is necessary for different cases, such as having a monorepo, to contruct a self-defined folder structure, or even to have an one-time global setup.

A project often does not only contain the smart contract component, but also components like frontend, backend, database etc. Adopting monorepo structure can help to provide a better organization over the whole project.

If you are not familiar with the concept of monorepo, you can read more here. To put it simple, a monorepo structure means that all components of the project are put and maintained in a single repository.

If you only install the contracts in your contract folder, you will realized that once you change the folder structure, or open the project in your root folder, your local IDE can no longer scan your imported files. Instead, an error prompting you that the contracts are not found will pop up.

error with message files not found

To fix these, you can create a new file in your root folder, or whatever location you plan to open your project with, named remappings.txt .

In this file, including the following line,

@openzeppelin/=<path_to_your_installed_location>/@openzeppelin/

This tells the IDE where to look for your installed contracts and scan for the specified location. Not only can you specify contracts from OpenZeppelin, but you may also include modules like ChainLink,

@chainlink/=<path_to_your_installed_location>/@chainlink/

and others.

Now the error should be gone after you specify the path to search for the contracts,

errors are gone and the files can be scanned

Conclusion

This is a very simple guide to show you how remappings.txt can help you to organize your import better. You can also refer to my monorepo that has multiple Solidity projects, all pointing to the same import path here.

Good luck on your development!

Want to Connect?
You can find me at Twitter Github Discord.

Setting up OpenZeppelin for Solidity in your local environment with path remappings was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.

Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact service@support.mexc.com for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.