OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to implement UUPS with a solidity contract having VRF and automation features?

  • Thread starter Thread starter user2441352
  • Start date Start date
U

user2441352

Guest
I am developping a solidity contract with those inheritances:

  • ERC20
  • ERC20FlashMint
  • VRFConsumerBaseV2Plus
  • AutomationCompatibleInterface

Code:
pragma solidity ^0.8.24;

import "@chainlink/contracts/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@chainlink/contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol";
import "@chainlink/contracts/src/v0.8/vrf/dev/interfaces/IVRFCoordinatorV2Plus.sol";
import "@chainlink/contracts/src/v0.8/automation/interfaces/AutomationCompatibleInterface.sol";

contract ExampleV1 is ERC20, ERC20FlashMint, VRFConsumerBaseV2Plus, AutomationCompatibleInterface {
...
}

I also created a javascript Test file to be able to deploy and simulate all the functions calls of the contract.

I would like to be able to create a new contract ExampleV2 but i struggle to add UUPS capability of Openzeppelin.

Code:
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

If i try to add them into the contract ExampleV1, i get a lot of conflicts telling me that functions exist more than once.

Can someone help me understand how to create a proxy contract with UUPS that will help me upgrade the ExampleV1 to ExampleV2 and also add the code in Javascript to be able to have a complete test in Hardhat deploying first the ExampleV1 and then the ExampleV2.

Thank you for your help.

If needed more information. I would be happy to add details.

Expected result would be:

Develop ExampleV1 (upgradeable)

In the javascript test code:

  • deploy ExampleV1
  • call ExampleV1 functions

Develop ExampleV2 (upgrdeable)

In the javascript test code:

  • deploy ExampleV1
  • call ExampleV1 functions
  • In the same address deploy ExampleV2
  • call ExampleV2 functions

<p>I am developping a solidity contract with those inheritances:</p>
<ul>
<li>ERC20</li>
<li>ERC20FlashMint</li>
<li>VRFConsumerBaseV2Plus</li>
<li>AutomationCompatibleInterface</li>
</ul>
<pre><code>pragma solidity ^0.8.24;

import "@chainlink/contracts/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@chainlink/contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol";
import "@chainlink/contracts/src/v0.8/vrf/dev/interfaces/IVRFCoordinatorV2Plus.sol";
import "@chainlink/contracts/src/v0.8/automation/interfaces/AutomationCompatibleInterface.sol";

contract ExampleV1 is ERC20, ERC20FlashMint, VRFConsumerBaseV2Plus, AutomationCompatibleInterface {
...
}
</code></pre>
<p>I also created a javascript Test file to be able to deploy and simulate all the functions calls of the contract.</p>
<p>I would like to be able to create a new contract ExampleV2 but i struggle to add UUPS capability of Openzeppelin.</p>
<pre><code>import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
</code></pre>
<p>If i try to add them into the contract ExampleV1, i get a lot of conflicts telling me that functions exist more than once.</p>
<p>Can someone help me understand how to create a proxy contract with UUPS that will help me upgrade the ExampleV1 to ExampleV2 and also add the code in Javascript to be able to have a complete test in Hardhat deploying first the ExampleV1 and then the ExampleV2.</p>
<p>Thank you for your help.</p>
<p>If needed more information. I would be happy to add details.</p>
<p><strong>Expected result would be:</strong></p>
<p>Develop ExampleV1 (upgradeable)</p>
<p>In the javascript test code:</p>
<ul>
<li>deploy ExampleV1</li>
<li>call ExampleV1 functions</li>
</ul>
<p>Develop ExampleV2 (upgrdeable)</p>
<p>In the javascript test code:</p>
<ul>
<li>deploy ExampleV1</li>
<li>call ExampleV1 functions</li>
<li>In the same address deploy ExampleV2</li>
<li>call ExampleV2 functions</li>
</ul>
 

Latest posts

B
Replies
0
Views
1
Blundering Ecologist
B
Top