3

I can not verify my test smart contract on BSC Main Network using @chainlink.

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;

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

contract PriceTest {
    AggregatorV3Interface internal priceFeed;
    
    constructor() public { 
    priceFeed = AggregatorV3Interface(0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE); // for BSC Main Net

    }
 
   function getLatestPrice() public view returns (uint256) {
        (,int price,,,) = priceFeed.latestRoundData();
        return uint256(price/100000000);
    }
     
}

What I have done :

  1. Make Flattened file and put in the contract code using truffle-flattener. I did it before for a test net and it's ok.

  2. Copy ABI from remix and pasted to abi.hashex.org

But I tried many time end up with problem in verifying the contract. I think I am not really understand how to put constructor parameter correctly to get the ABI auto-parse. I am quite new to smart contract. Need learn more from experts.

My contract :

https://bscscan.com/address/0x0849a15338a5f0787696cea335757b608ff92a85

Flattened file :

// File: @chainlink\contracts\src\v0.6\interfaces\AggregatorV3Interface.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

interface AggregatorV3Interface {

  function decimals()
    external
    view
    returns (
      uint8
    );

  function description()
    external
    view
    returns (
      string memory
    );

  function version()
    external
    view
    returns (
      uint256
    );

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(
    uint80 _roundId
  )
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

}

// File: contracts\Getprice.sol

pragma solidity ^0.6.7;


contract PriceTest {
    AggregatorV3Interface internal priceFeed;
    
    constructor() public { 
    priceFeed = AggregatorV3Interface(0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE); // for BSC Main Net

    }
 
   function getLatestPrice() public view returns (uint256) {
        (,int price,,,) = priceFeed.latestRoundData();
        return uint256(price/100000000);
    }
     
}
Yusnee
  • 177
  • 11
  • What version did you compile with? Did you try with https://github.com/rkalis/truffle-plugin-verify. – Patrick Collins Sep 19 '21 at 01:26
  • @Patrick I did trial of verification for several smart contract previously including openzeppelin. Of course I have check the compiler version, optimization, SPDX-License, ABI. But this one make me spent all night and still struggle :) – Yusnee Sep 19 '21 at 12:33
  • @Patric I know you are Chainlink DevRel. I have tried on Rinkeby : priceFeed = AggregatorV3Interface(0xcf0f51ca2cDAecb464eeE4227f5295F2384F84ED); // for Rinkeby. Please try this and let me know if you can verify the contract. Thks anyway. – Yusnee Sep 19 '21 at 13:00
  • I'll need to know what compiler version you used to deploy it to verify it, do you know what version you used to compile it? What does your truffle-config look like? – Patrick Collins Sep 19 '21 at 17:38
  • @Patric Compiler on Remix : 0.6.7+commint.b8d736ae and also tried using 0.6.12+commit.275d51765. I deployed it using REMIX, but I also migrate the same file on my project folder using Truffle to get the ABI stored on my contract. Actually it's works fine. Problem is can not verify the contract. – Yusnee Sep 20 '21 at 22:15
  • @Patric I want to know what is the problem in the future if I deploy a smart contract and it works fine but not doing verification on the explorer? Who will complain and do something bad to my contract? Thx – Yusnee Sep 20 '21 at 22:18
  • 1
    BTW verification is Success using 0.6.12+commit.275d51765 on Rinkeby : https://rinkeby.etherscan.io/address/0x85E96D9342bec02bEe348E45eC4aeb3aE5f57a06#code – Yusnee Sep 20 '21 at 22:37
  • Perfect! Then you should be able to verify with the same compiler version on BSC – Patrick Collins Sep 21 '21 at 11:15

0 Answers0