Open Zeppelin provides security products to build, automate, and operate decentralized applications and has a full suite of battle-tested and audited smart-contracts for the EVM including:
- ERC20
- ERC721
- ERC777
- ERC1155
- Gas Station Network
- Cryptography
- Math
- And more...
You can deploy Open Zeppelin smart contracts on the Avalanche C-Chain via Remix.
When developing locally you install Open Zeppeling via npm
:
npm install @openzeppelin/contracts
Then within the Solidity smart-contract you import
the contract you wish from the node_modules/
directory which was created by the previous npm install
command:
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
However when using Remix we're unable to import
from a local node_modules/
directory because it doesn't exist. Fortunately Remix supports import
ing from Github.
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/token/ERC20/ERC20.sol";
Note: Only use tags which are published in an official release of OpenZeppelin Contracts. On Remix specify the release tag when importing from GitHub or you'll get the latest code in the master
branch. The example below imports v3.3.0.
// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/token/ERC20/ERC20.sol";
contract GLDToken is ERC20 {
constructor(uint256 initialSupply) public ERC20("Gold", "GLD") {
_mint(msg.sender, initialSupply);
}
}
// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract GLDToken is ERC20 {
constructor(uint256 initialSupply) public ERC20("Gold", "GLD") {
_mint(msg.sender, initialSupply);
}
}