Deploying upgradeable erc721 smart contract

Hi. I am trying to deploy and use the ERC721Rarible smart contract, on binance smart chain testnet, which exists in token/erc721 folder of this repo of rarible. https://github.com/rariblecom/protocol-contracts/tree/master/tokens. After doing a simple compile and migrating all contracts using truffle I got an address for the adminupgradeabilityproxy contract. Now to read and interact with the smart contract I am confused whivh contract to verify using truffle plugin verify?

This is the migrations file

const { deployProxy } = require('@openzeppelin/truffle-upgrades');

const ERC721Rarible = artifacts.require('ERC721Rarible');

module.exports = async function (deployer) {
  await deployProxy(ERC721Rarible, ["Rarible", "RARI", "ipfs:/", ""], { deployer, initializer: '__ERC721Rarible_init' });
};

Hello @Maham_Zaidi

To verify your implementation behind the proxy. Use the address of the proxy in etherscan. On the top right you will see a button named more options. Click verify Proxy. Then click Verify. It will fail, telling your that the implementation is not verified at a given address. Use this address to verify your implementation

3 Likes

@madeindreams This is the link of my proxy contract https://testnet.bscscan.com/address/0x3361419192a630943abc555aea9002fa4a08c442. I did as you told and it me option “Is this a proxy?” instead of verify proxy. I selected the option anyway and it gave me the message:

The implementation contract at 0x953f3440eb9854c7e006d6c4d4375732134f43ad does not seem to be verified.

However when I looked at the output from running the truffle migrate --reset --network bscTestnet I couldn’t see this address anywhere. I am new to the whole concept of upgradeable contracts but what I actually want to accomplish is that I have a proxy contract for my ERC721Rarible.sol contract.

The address returned by the deployment are the address of the proxy contract. The address 0x953f3440eb9854c7e006d6c4d4375732134f43ad

Is what you want to verify. This is your unverified implementation!

I don’t know why we have to get the address like that. I was also expecting my script to return the address of my implementation.

@madeindreams How can we verify this implementation? Because I dont know what is this address referring to

This address is the contract you deployed. The implementation is your contract. The proxy is just a gate keeper.

@madeindreams So it means according to my migrations file, I first have to verify ERC721Rarible.sol and then do the later work.

The verification will allow you to view the contract functions from Etherscan but everything should work even if not verified.

I’m deploying these on binance smart chain testnet.

Well not sure how they process verification but the mechanics should remain the same, proxy wise. I think the proxy verification process on Etherscan is recent. Not sure about Binance integration.

Hi @Maham_Zaidi,

BSCScan supports proxies. You can verify the implementation contract using Hardhat: https://www.binance.org/en/blog/verify-with-hardhat/

@abcoathup I followed this tutorial of yours and tried to deploy my implementation contracts

This is my migrations file:

const { deployProxy } = require('@openzeppelin/truffle-upgrades');
async function main() {

  const Box = await ethers.getContractFactory("ERC721Rarible");

  console.log("Deploying ERC721Rarible...");

  const box = await upgrades.deployProxy(Box, ["Rarible", "RARI", "ipfs:/", ""], {initializer: '__ERC721Rarible_init' });

  console.log("ERC721Rarible deployed to:", box.address);

}

main()

  .then(() => process.exit(0))

  .catch(error => {

    console.error(error);

    process.exit(1);

  });

After running npx hardhat run --network testnet migrations/2_initial_erc721.js command it gave me this error

Deploying ERC721Rarible...
ProviderError: max code size exceeded
    at HttpProvider.request (D:\rarible-hardhat\protocol-contracts\tokens\node_modules\hardhat\src\internal\core\providers\http.ts:46:19)
    at HDWalletProvider.request (D:\rarible-hardhat\protocol-contracts\tokens\node_modules\hardhat\src\internal\core\providers\accounts.ts:142:34)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at EthersProviderWrapper.send (D:\rarible-hardhat\protocol-contracts\tokens\node_modules\@nomiclabs\hardhat-ethers\src\internal\ethers-provider-wrapper.ts:13:20)

Okay I reduced the optimizer runs from 200 to 1 and now it compiled successfully.

Deploying ERC721Rarible...
ERC721Rarible deployed to: 0x182aE9C966473a674Be7dA2662cA728bB6faa9CF

Now I am trying to verify the contract using npx hardhat verify --network testnet 0x182aE9C966473a674Be7dA2662cA728bB6faa9CF but it says

Error HH303: Unrecognized task verify

For more info go to https://hardhat.org/HH303 or run Hardhat with --show-stack-traces

@Maham_Zaidi Do you have the default network set to your tesnet in the hardhat.config?

Or did you try to put the address right after the verify argument?

Also, this should be your proxy address and you want to verify the proxy on Etherscan then verify your implementation.

1 Like

@madeindreams Please see the comment above. I have used the --network option after the verify argument. My networks are defined below: I get the same error if I try to verify my proxy first. Also, I haven’t specified the default network

networks: {

 testnet: {

   url: `https://data-seed-prebsc-1-s1.binance.org:8545`,

   accounts: {mnemonic: mnemonic}

 },

 mainnet: {

   url: `https://bsc-dataseed.binance.org/`,

   accounts: {mnemonic: mnemonic}

 }

}