How to export Contracts do enable importing them in other projects (like OpenZeppelin)

Hi. We want to organize our contract families similar to OpenZeppelin to collect base contracts in a separate repository in order to import them in custom projects.

I can't find anything that describes how to do that. Every tutorial I could find is rather about "how to import external contracts" but not "how to export contracts".

I have seen in OpenZeppelin repository, that they have created a bunch of JS-scripts regarding the release process, but it is not easy to understand if it is more related to OZ or if we should exactly do the same on our side.

So what is our requirement:

I. we want to have a repository on GitHub that contains a bunch of smart contracts
II. we want to be able to import these contracts into new projects like this:

  1. Shell: npm install @companyName/our-basecontracts
  2. Solidity: import @companyName/our-basecontracts/permissions.sol

Can someone pleeeeease push me into the right direction, how to start?

Thank you very much in advance!

Hey @itinance
you can import contracts directly from girhub repos doing this:

import "";

Instead, if you want an import using npm you need to public the package to NPM

1 Like