Commit bcb1f11d by Francisco Giordano

edit readme with upgrade safe specific content

parent 792dadce
# <img src="logo.svg" alt="OpenZeppelin" height="40px">
# <img src="icon.svg" alt="OpenZeppelin" height="40px" align="left"> OpenZeppelin Contracts Upgrade Safe
[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.openzeppelin.com/contracts)
[![NPM Package](https://img.shields.io/npm/v/@openzeppelin/contracts.svg)](https://www.npmjs.org/package/@openzeppelin/contracts)
[![Coverage Status](https://codecov.io/gh/OpenZeppelin/openzeppelin-contracts/graph/badge.svg)](https://codecov.io/gh/OpenZeppelin/openzeppelin-contracts)
[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.openzeppelin.com/contracts/upgrade-safe)
[![NPM Package](https://img.shields.io/npm/v/@openzeppelin/contracts-upgrade-safe.svg)](https://www.npmjs.org/package/@openzeppelin/contracts-upgrade-safe)
**A library for secure smart contract development.** Build on a solid foundation of community-vetted code.
This repository hosts the Upgrade Safe variant of [OpenZeppelin Contracts], meant for use in upgradeable contracts. This variant is available as separate package called `@openzeppelin/contracts-upgrade-safe`.
* Implementations of standards like [ERC20](https://docs.openzeppelin.com/contracts/erc20) and [ERC721](https://docs.openzeppelin.com/contracts/erc721).
* Flexible [role-based permissioning](https://docs.openzeppelin.com/contracts/access-control) scheme.
* Reusable [Solidity components](https://docs.openzeppelin.com/contracts/utilities) to build custom contracts and complex decentralized systems.
* First-class integration with the [Gas Station Network](https://docs.openzeppelin.com/contracts/gsn) for systems with no gas fees!
* [Audited](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/audit) by leading security firms (_last full audit on v2.0.0_).
[OpenZeppelin Contracts]: https://github.com/OpenZeppelin/openzeppelin-contracts
It follows all of the rules for xref:upgrades-plugins::writing-upgradeable.adoc[Writing Upgradeable Contracts]: constructors are replaced by initializer functions, state variables are initialized in initializer functions, and we additionally check for storage incompatibilities across minor versions.
[Writing Upgradeable Contracts]: https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable
## Overview
### Installation
```console
$ npm install @openzeppelin/contracts
$ npm install @openzeppelin/contracts-upgrade-safe
```
OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/contracts/releases-stability#api-stability), which means your contracts won't break unexpectedly when upgrading to a newer minor version.
### Usage
Once installed, you can use the contracts in the library by importing them:
The package replicates the structure of the main OpenZeppelin Contracts package, but every file and contract has the suffix `UpgradeSafe`.
```solidity
pragma solidity ^0.6.0;
```diff
-import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
+import "@openzeppelin/contracts-upgrade-safe/token/ERC721/ERC721UpgradeSafe.sol";
-contract MyCollectible is ERC721 {
+contract MyCollectible is ERC721UpgradeSafe {
```
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
Constructors are replaced by internal initializer functions following the naming convention `__{ContractName}_init`. Since these are internal, you must always define your own public initializer function and call the parent initializer of the contract you extend.
contract MyCollectible is ERC721 {
constructor() ERC721("MyCollectible", "MCO") public {
}
}
```diff
- constructor() ERC721("MyCollectible", "MCO") public {
+ function initialize() initializer public {
+ __ERC721_init("MyCollectible", "MCO");
}
```
> **Caution**
>
> Use with multiple inheritance requires special care. Initializer functions are not linearized by the compiler like constructors. Because of this, each `__{ContractName}_init` function embeds the linearized calls to all parent initializers. As a consequence, calling two of these `init` functions can potentially initialize the same contract twice.
>
> The function `__{ContractName}_init_unchained` found in every contract is the initializer function minus the calls to parent initializers, and can be used to avoid the double initialization problem, but doing this manually is not recommended. We hope to be able to implement safety checks for this in future versions of the Upgrades Plugins.
_If you're new to smart contract development, head to [Developing Smart Contracts](https://docs.openzeppelin.com/learn/developing-smart-contracts) to learn about creating a new project and compiling your contracts._
To keep your system secure, you should **always** use the installed code as-is, and neither copy-paste it from online sources, nor modify it yourself. The library is designed so that only the contracts and functions you use are deployed, so you don't need to worry about it needlessly increasing gas costs.
......
<?xml version="1.0" encoding="UTF-8"?>
<svg width="180px" height="200px" viewBox="0 0 180 200" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 53.2 (72643) - https://sketchapp.com -->
<title>OZ_icon_color</title>
<desc>Created with Sketch.</desc>
<g id="presentación" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="OZ_icon_color">
<path d="M179.670444,199.932333 L179.670444,147.932333 L123.270887,147.932333 C107.93329,147.932333 93.7259335,156.016333 85.8704806,169.214333 L67.5860074,199.932333 L179.670444,199.932333 Z" id="Stroke-1" fill="#63D2F9"></path>
<polygon id="Stroke-3" fill="#4E5EE4" points="0.166292052 0.1667 0.166292052 52.1667 148.717863 52.1667 179.670543 0.1667"></polygon>
<path d="M71.2615009,81.4347667 L0.329855823,199.932433 L60.7619445,199.932433 L145.583534,58.1667667 L112.212665,58.1667667 C95.4274159,58.1667667 79.8768799,67.0024333 71.2615009,81.4347667 Z" id="Stroke-5" fill="#63B0F9"></path>
</g>
</g>
</svg>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment