# Upgradeable ERC721

**URL:** <https://forum.openzeppelin.com/t/upgradeable-erc721/1907>\
**Category:** SDK\
**Created:** [December 6, 2019, 10:28pm UTC](https://forum.openzeppelin.com/t/upgradeable-erc721/1907 "2019-12-06T22:28:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucianstroie](https://avatars.discourse-cdn.com/v4/letter/l/51bf81/32.png) [@lucianstroie](https://forum.openzeppelin.com/u/lucianstroie)\
**Post date:** [December 6, 2019, 10:28pm UTC](https://forum.openzeppelin.com/t/upgradeable-erc721/1907/1 "2019-12-06T22:28:27Z")

</div>

I've been able to replicate the SimpleERC721 code example from above with Remix, therefore I will try to keep it as close to that as possible while trying to get that contract to complie with ZepplinOS and Embark.  
I'm using solc 0.5.13

ZeppelinOS:  
I change the code to import from `@openzeppelin/contracts`  
`oz push` gives the following error:

```auto
- Contract SimpleERC721 has an explicit constructor. Change it to an initializer function. See https://docs.openzeppelin.com/sdk/2.5/writing_contracts.html#initializers.
One or more contracts have validation errors. Please review the items listed above and fix them, or run this command again with the --force option.

```

`oz push --force` works and I can compile and submit to ganache cli

Proper way to handle this with upgradeable contracts, thanks @abcoathup:

> [@How do I test the ERC721 function with Open Zeppelin SDK?](https://forum.openzeppelin.com/t/how-do-i-test-the-erc721-function-with-open-zeppelin-sdk/1710/7):
>
> Just a quick answer here (on mobile)looks like nothing is being initialized- so the contract doesn’t even have any minters assigned, hence it won’t let you mint. Look into the contracts that ERC721 inherits from, each one of them needs to be initialized. So for example have a look at one of m contracts: Here I create an erc721 token, but I initialize all the contracts I inherit from in a initialize function. My example is a little more than you need- but there is also a simple test in the f…

Embark:  
Using the exact same code that ran on Remix, pulling the same repo From Github, this is the error from the Embark console:

```auto
change: contracts/SimpleERC721.sol

embark-solc:

assuming Context to be an interface

assuming MinterRole to be an interface

assuming ERC165 to be an interface

assuming IERC165 to be an interface

assuming ERC721MetadataMintable to be an interface

assuming IERC721 to be an interface

assuming IERC721Enumerable to be an interface

assuming IERC721Metadata to be an interface

assuming IERC721Receiver to be an interface

To get more details on interface Smart contracts, go here: https://embark.status.im/docs/troubleshooting.html#Assuming-Contract-to-be-an-interface

deploying contracts

Executing pre-deploy actions...

Pre-deploy actions done. Deploying contracts

[ERC721Full]: Error: attempted to deploy ERC721Full without specifying parameters. check if there are any params defined for this contract in this environment in the contracts configuration file

[ERC721Metadata]: Error: attempted to deploy ERC721Metadata without specifying parameters. check if there are any params defined for this contract in this environment in the contracts configuration file

[SimpleERC721]: Failing call, this could be because of invalid inputs or function guards that may have been triggered, or an unknown error.

deploying SafeMath with 82470 gas at the price of 1 Wei, estimated cost: 82470 Wei (txHash: 0x0c42958f6240833872d389d1c2644a20530399fc3ce8731d2c0ca963e3e54719)

deploying Counters with 81887 gas at the price of 1 Wei, estimated cost: 81887 Wei (txHash: 0x3e3066dc0eb095a044591410a599a297ebe9729d705b33a99aad2966031f0769)

deploying Roles with 78968 gas at the price of 1 Wei, estimated cost: 78968 Wei (txHash: 0x6197f331403e84deba9aeec1087c077c5bf0ec0b625b4de502bfe5620b7f0fc8)

deploying Address with 84189 gas at the price of 1 Wei, estimated cost: 84189 Wei (txHash: 0x17e79b6fc897b91371f2fbb9ad865ed2264fa674aa0ca1f7d00b987d6331808b)

[ERC721]: Failing call, this could be because of invalid inputs or function guards that may have been triggered, or an unknown error.

[ERC721Enumerable]: Failing call, this could be because of invalid inputs or function guards that may have been triggered, or an unknown error.

SafeMath deployed at 0x5Ab333bdE4378939eCE590705D5524e436956a69 using 76654 gas (txHash: 0x0c42958f6240833872d389d1c2644a20530399fc3ce8731d2c0ca963e3e54719)

Roles deployed at 0x229C4CB3071DC0458fA87eEa31AC73Ad5257Bf3a using 76590 gas (txHash: 0x6197f331403e84deba9aeec1087c077c5bf0ec0b625b4de502bfe5620b7f0fc8)

Counters deployed at 0x1EC4B2Bc96FB8C24De8b73719A7E982B7EF2fd7b using 76654 gas (txHash: 0x3e3066dc0eb095a044591410a599a297ebe9729d705b33a99aad2966031f0769)

Address deployed at 0x34B645744Fd871CeBE2a3bA0493528F5F83c1abe using 76654 gas (txHash: 0x17e79b6fc897b91371f2fbb9ad865ed2264fa674aa0ca1f7d00b987d6331808b)

Error deploying contracts. Please fix errors to continue.

Error deploying contracts. Please fix errors to continue.

```

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [December 9, 2019, 5:08am UTC](https://forum.openzeppelin.com/t/upgradeable-erc721/1907/2 "2019-12-09T05:08:35Z")

</div>

Hi @lucianstroie,

OpenZeppelin SDK (previously ZeppelinOS) creates upgradeable contracts.  
I recommend using the latest version which is [OpenZeppelin SDK 2.6](https://forum.openzeppelin.com/t/openzeppelin-sdk-2-6-with-telemetry-opt-in/1734)

If you are using OpenZeppelin SDK and upgradeable contracts you need to use `@openzeppelin/contracts-ethereum-package` rather than `@openzeppelin/contracts`.

> [https://docs.openzeppelin.com/sdk/2.5/linking](https://docs.openzeppelin.com/sdk/2.5/linking)  
> NOTE: Make sure you install `@openzeppelin/contracts-ethereum-package` and not the vanilla `@openzeppelin/contracts`. The latter is set up for general usage, while `@openzeppelin/contracts-ethereum-package` is tailored for being used with the OpenZeppelin SDK. This means that its contracts are [already set up to be upgradeable](https://docs.openzeppelin.com/sdk/2.5/writing-contracts#use-upgradeable-packages).

I recently created an issue to add a warning to users when they create a contract importing `@openzeppelin/contracts`: [OpenZeppelin/openzeppelin-sdk#1297](https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1297).  
There is also a plan to remove this requirement to use the Contracts Ethereum Package version: [Planning the demise of OpenZeppelin Contracts’ evil twin](https://forum.openzeppelin.com/t/planning-the-demise-of-openzeppelin-contracts-evil-twin/1724).

Also with upgradeable contracts we need to use `initializer`s rather than constructors.

> [https://docs.openzeppelin.com/sdk/2.5/writing-contracts](https://docs.openzeppelin.com/sdk/2.5/writing-contracts)  
> You can use your Solidity contracts in the OpenZeppelin SDK without any modifications, except for their _constructors_. Due to a requirement of the proxy-based upgradeability system, no constructors can be used in upgradeable contracts.

An example upgradeable ERC721 is as follows:

## Simple721Token.sol

When the contract is created (`openzeppelin create`) need to ensure it is initialized passing in the address to have the minter role.

Tokens can then be minted by calling (`openzeppelin send-tx`) `mintWithTokenURI`

```auto
pragma solidity ^0.5.0;

import "@openzeppelin/upgrades/contracts/Initializable.sol";

import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/ERC721Full.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/ERC721Mintable.sol";

contract Simple721Token is Initializable, ERC721Full, ERC721Mintable {

    function initialize(address sender) public initializer {
        ERC721.initialize();
        ERC721Metadata.initialize("Simple721Token", "721");
        ERC721Enumerable.initialize();
        ERC721Mintable.initialize(sender);
    }
}

```

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [December 16, 2019, 12:03am UTC](https://forum.openzeppelin.com/t/upgradeable-erc721/1907/3 "2019-12-16T00:03:13Z")

</div>

Hi @lucianstroie,

I wanted to check how you were getting on with this?

---

<div class="post-metadata">

**Author:** ![spalladino](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/spalladino/32/22_2.png) [@spalladino](https://forum.openzeppelin.com/u/spalladino)\
**Post date:** [January 22, 2020, 2:32pm UTC](https://forum.openzeppelin.com/t/upgradeable-erc721/1907/4 "2020-01-22T14:32:46Z")

</div>

Hey @lucianstroie! Starting with [2.7 RC](https://forum.openzeppelin.com/t/openzeppelin-cli-2-7-rc-0-available/2133), the OpenZeppelin CLI will warn if you try to use the vanilla `@openzeppelin/contracts` instead of `@openzeppelin/contracts-ethereum-package`. This is temporary though, as we are working on [unifying both of them](https://forum.openzeppelin.com/t/planning-the-demise-of-openzeppelin-contracts-evil-twin/1724). Give the new RC a try and let us know what you think!

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [February 19, 2020, 1:43am UTC](https://forum.openzeppelin.com/t/upgradeable-erc721/1907/5 "2020-02-19T01:43:10Z")

</div>

Hi @lucianstroie,

The CLI now supports deploying regular (non-upgradeable) contracts in the release candidate of [OpenZeppelin CLI 2.8](https://forum.openzeppelin.com/t/openzeppelin-cli-2-8-release-candidate/2297)

Would appreciate if you could give the release candidate a try and let us know what you think!
