Chainlink 101 Course

@thecil, Awesome that did it , thanks buddy. :vulcan_salute:

1 Like

@thecil, Man, just when I think I’m in the clear, lol. I’m having the HDWalletProvider issue again,

I’m trying to deploy lottery contract, I’ve setup Mnemonic, RPC_Url, but error keeps popping up like last time in truffle section of pervious course.

Error: Unknown arguments format passed to new HDWalletProvider. Please check your configuration and try again
    at Object.getOptions (C:\Users\jflor\Documents\Solidity-Lottery\node_modules\@truffle\hdwallet-provider\src\constructor\getOptions.ts:143:11)      
    at new HDWalletProvider (C:\Users\jflor\Documents\Solidity-Lottery\node_modules\@truffle\hdwallet-provider\src\index.ts:68:9)
    at Object.provider (C:\Users\jflor\Documents\Solidity-Lottery\truffle-config.js:28:16)
    at Object.getProvider (C:\Users\jflor\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\provider\index.js:20:1)
    at Object.create (C:\Users\jflor\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\provider\index.js:13:1)
    at TruffleConfig.get [as provider] (C:\Users\jflor\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\config\dist\configDefaults.js:235:1)
    at Object.detect (C:\Users\jflor\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\environment\environment.js:19:1)
    at Object.run (C:\Users\jflor\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:201:1)
    at Command.run (C:\Users\jflor\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\command.js:183:1)

.env file

MNEMONIC='1c49d2330c06ba699edb3ecc24a4f674db2f1b38d7ab699a6d4936..........'
RPC_URL='https://kovan.infura.io/v3/7d82a16ccf554b9a9062...............'

2_deploy.js

const Lottery = artifacts.require('Lottery')
const {LinkToken} = require('@chainlink/contracts/truffle/v0.4/LinkToken')

module.exports = async (deployer, network, [defaultAccount]) => {
    if (!network.startsWith('kovan')){
        console.log('Currently only works with Kovan!')
        LinkToken.setProvider(deployer.provider)
    } else {
        const KOVAN_KEYHASH = '0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4'
        const KOVAN_VRF_COORDINATOR = '0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9'
        const ETH_USD_PRICE_FEED = '0x9326BFA02ADD2366b30bacB125260Af641031331'
        const KOVAN_LINK_TOKEN = '0xa36085F69e2889c224210F603D836748e7dC0088'
        deployer.deploy(Lottery, ETH_USD_PRICE_FEED, KOVAN_VRF_COORDINATOR, KOVAN_LINK_TOKEN, KOVAN_KEYHASH)
        

    }

}

If you can take look for me, Im still trying to put up repository on github, but files to big.
thanks .

I think it might be the hdwalletProvider version, but not that sure, check my package.json which mention the versions of my dependencies, if yours is the same?

would be awesome if you can provide the github repo, you can use github desktop which will be easier to manage.

https://desktop.github.com/

you can check some videos on youtube on how to create a repo using github desktop, keep in mind that there is no need to upload the node_modules folder, so you can ignore it on the .gitignore file.

WARNING!!! :warning: BE SURE TO NOT UPLOAD YOUR .env FILE TO THE PUBLIC REPO, YOUR PRIV KEY COULD GET COMPROMISE! (just ensure you are also ignoring that file).

Carlos Z

@thecil, Hi Carlos, thanks for looking into this, Here is my package json,

I know in the video he following migrations, he talks about package json config.
Only difference is the truffle assertions.

I’ll started on that desktop github,make this easier, thanks again.

Javier

@thecil, Hi Carlos, here is github link.

https://github.com/TotalingArc/Solidity-Lottery

@thecil Hi Carlos, I am having a hard time compiling the contract because of tis error

Error: Truffle is currently using solc 0.6.6, but one or more of your contracts specify "pragma solidity ^0.8.0".

I believe the reason is because openzeppelin’s Ownable version has to be ^0.8.0 while the video is using ^0.6.6. I tried changing the pragma solidity and truffle-config solidity version to ^0.8.0 but it still complains as the chainlink import is using v0.6. Not too sure what my next step should be.

Appreciate your time, thanks!

1 Like

Hey @jeffersonchoi, hope your well.

If you are using truffle, you might have just to change your truffle compiler version, go into your truffle.config.js, search for compiler version and change it to ^0.8.0.

Carlos Z

Hi @thecil,

Thanks for the reply. I tried changing the truffle.config.js version to ^0.8.0, updated all .sol files which contains ^0.6.6 to ^0.8.0 already, but my compiler is still showing errors.

ParserError: Source file requires different compiler version (current compiler is 0.8.12+commit.f00d7308.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
 --> @chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol:2:1:
  |
2 | pragma solidity ^0.6.0;

I believe this is because SafeMathChainLink library is still referencing ^0.6.0, as seen from https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.6/vendor/SafeMathChainlink.sol#L2.

I tried searching in 0.8 directory but was unable to see the SafeMathChainLink file.

Please advice. Thanks!

1 Like

There is a very easy fix, remove the Ownable.sol library and implement your own onlyOwner modifier,

address private _owner;

constructor(...) {
      _owner = msg.sender;
}

modifier onlyOwner {
   ...
  _;
}

This will get rid of the 0.8.0 problem upon compiling