samedi 5 juin 2021

Smart Contracts - Chainlink VRF / @openzeppelin/truffle-upgrades compatibility

Right now i am transforming a basic smart contract into a upgradeable smart contract using @openzeppelin/truffle-upgrades

So i followed all required steps from the docs but one issue remains:

Truffle-Upgrades requires me to replace the constructor with an initializer which is fine for me, but not for the smart contracts imported into my own smart contract, sample:

pragma solidity 0.6.6;

import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";

contract Sample is VRFConsumerBase {
    
    address private owner;
    
    bytes32 internal keyHash;
    uint256 internal fee;
    
    constructor(address _owner)
        VRFConsumerBase(
            0xa555fC018435bef5A13C6c6870a9d4C11DEC329C, // VRF Coordinator
            0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06  // LINK Token
        ) public
    {
        keyHash = 0xcaf3c3727e033261d383b315559476f48034c13b18f8cafed4d871abe5049186;
        fee = 0.1 * 10 ** 18; // 0.1 LINK (Varies by network)
        
        owner = _owner;
    }

    ...

And therefore truffle complains:

../@chainlink/contracts/src/v0.6/VRFConsumerBase.sol:182: Contract `VRFConsumerBase` has a constructor
Define an initializer instead

As it is a third party package i can not replace it :)

Are there any architectural tricks/configurations?

I went through pretty much all docs on chainlink/truffle but did find a solution for this issue.

Thanks!




Aucun commentaire:

Enregistrer un commentaire