Import OpenZeppelin Contracts from GitHub in Remix?

Hello @abcoathup!

Before checking this guide (Deploy a simple ERC20 token in Remix), I tried to import the contracts from github directly through the following URL https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC20/ERC20.sol which I just navigated to, from the open-zeppelin/contracts repository. And that didn’t work.

But with the link you provided, https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.4.0/contracts/token/ERC20/ERC20.sol, the import worked perfectly.

And I tried to compare the two URL’s and found that the link contained blob which I missed.

So what is blob? And also why there’s a 404 error while navigating to https://github.com/OpenZeppelin/openzeppelin-contracts/blob/?

And I know this is something very basic, so please bear with me :slight_smile:

Thanks.

1 Like

Hi @manolingam,

The URL (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC20/ERC20.sol) is the master branch rather than a tag for a specific release. This URL also redirects to https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol

Note: You should only use code published in an official release of OpenZeppelin Contracts, the latest release is 2.4. When importing via GitHub on Remix you can specify the release tag, (otherwise you will get the latest code in the master branch). The example below imports v2.4.0.

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.4.0/contracts/token/ERC20/ERC20.sol

The key part of this URL is the “v2.4.0” which is the tag for the 2.4 release.


Regards Blobs, see the GitHub definition:


Please ask all the questions that you need.
Questions and answers help community now and future readers. :pray:
I am still newish to the workings of Git and GitHub too. :smile:

1 Like

Hi @manolingam,

Checking that the above reply answered your question?
If it did, can you mark it as the solution.
Otherwise please ask a followup. Thanks :pray:

Thanks for the help @abcoathup :slight_smile:
That answered my question!

1 Like