Git Product home page Git Product logo

hardhat-starter-kit's Issues

CC0 licence?

Hi there. I was wondering if you would consider switching to a public domain licence like CC0 or the unlicense?

Complying with the MIT licence is often not too hard - if you're using a library then you have an exact copy and you simply preserve the licence declaration. Easy. Not so when creating a derivative work, and this is a template project so all usage is derivative in nature. How do you refer to the code that remains copied from here to attribute the MIT licence?

If a part of that project itself is used to create another derivative work, how is that author to know if they have used any of this project's code, and whether they are subject to its MIT licence? That downstream author, if paying attention to compliance, may be forced to write something like:

Though I am not aware of any specific examples, there may be portions of this   
project that are considered derivative of hardhat-starter-kit. The copyright       
for those portions would be held by pappas999 (c) 2021, and the MIT licence        
below would apply.

(MIT licence goes here)

IANAL, but to the best of my knowledge, project authors are required to do this kind of thing. I think it's a bit silly, and it would be better if we all stopped worrying about attribution in open source licences, and just committed the work to the public domain (assuming having other projects benefit from your work is the goal, of course).

Wdyt?

How to Use Chainlink With Hardhat

Suggesting an issue to have the GitHub repository on this tutorial be replaced with this one as it is the latest hardhat-starter-kit and the one isn't being maintained anymore according to its ReadMe File and the repository name was changed to this one

Add tasks back in

npx hardhat request-random-number --contract shouldn't be a plug-in. It abstracts how this task is happening and isn't something a lot of projects are necessarily going to use. We want to show users how to make this task.
Please add this task back in.

In fact, the majority of these shouldn't be abstracted out. The only tasks that should be tasks are reading price feeds and funding LINK .

Add a `00_deploy_mocks` deploy script

This will deploy mocks IF the chainId is a developChain id, then you can just call like "getAddress" and not duplicate deploy.

Also use:
Use const LinkToken = await deployments.get('LinkToken') in the scripts

Update oracle and jobs for kovan and rinkeby

To the Chainlink devrel node

kovan:
    oracle: '0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8'
    jobId: 'd5270d1c311941d0b08bead21fea7747'
  rinkeby:
    oracle: '0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8'
    jobId: '6b88e0402e5d415eb946e528b8e0c7ba'

Wrong requestId in RandomNumberConsumer unit test

The requestId from

const transaction = await randomNumberConsumer.getRandomNumber()
const transactionReceipt = await transaction.wait(1)
const requestId = transactionReceipt.events[0].topics[1]

is different to the requestId from the RandomNumberConsumer contract if you log and see them

function getRandomNumber() public returns (bytes32 requestId) {
    require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet");
    requestId = requestRandomness(keyHash, fee);
    console.logBytes32(requestId);
  }

image

Remove `stringToBytes32`

We don't need to do this. We should just encode the jobid using ethers.

This is best practice anyways.

Make variable in the constructor `immutable`

immutable variables save on gas, and cannot be changed and we have a number of variables that we won't want to change, like the VRFCoordinator address.

We can also use immutable to set these variables in the constructor.

constant variables cannot be set in the constructor.

npm/yarn to install "chainlink-plugins-fund-link", but with following error

npm install

npm ERR! 404 Not Found - GET https://registry.npmjs.org/@appliedblockchain/chainlink-plugins-fund-link/-/chainlink-plugins-fund-link-0.0.1.tgz
npm ERR! 404
npm ERR! 404 '@appliedblockchain/[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'hardhat-starter-kit'

yarn

error An unexpected error occurred: "https://registry.yarnpkg.com/@appliedblockchain%2fchainlink-plugins-fund-link: Not found".

named accounts

use named accounts instead of that garbaged "if network is kovan -> do this, if network is rinkeby -> do this"

Unit testing of randomness - callback from mock?

Would it be possible to have the fulfillRandomness fire from the mock during tests, so that the following behaviour can be tested in unit-tests? This does not seem to happen in my project. It does not in your starter either.

The contract I would like to create really depends on this random value as its starting point, without alternative public entrypoints to accomodate for testing (the random value not being manipulated from outside factors is crucial when the contract is deployed on a real chain).

How are people testing this today?

Have default network be hardhat

have the default network be hardhat, and have it smart enough to swap addresses based on the network. Including deploying mocks if you're on a local network.

Predictable number for testing

In the RandomNumberConsumerV2 unit test, the result of the number is validated with always being greater than zero.
At first it's fine. but how is it applied for the moment in which it must be tested with a winning or specific number?

assert(firstRandomNumber.gt(ethers.constants.Zero))

Is there any way to provide the number as in the v1 mock?

it("Should successfully request a random number and get a result", async () => { const transaction = await randomNumberConsumer.getRandomNumber() const transactionReceipt = await transaction.wait(1) const requestId = transactionReceipt.events[0].topics[1] const randomValue = 777 await vrfCoordinatorMock.callBackWithRandomness( requestId, randomValue, randomNumberConsumer.address ) assert.equal((await randomNumberConsumer.randomResult()).toString(), randomValue) })

Premium and gas per link variable in the deploy mocks scripts should be clarified

Right now, we deploy the VRFCoordinatorV2Mock as such:

    await deploy("VRFCoordinatorV2Mock", {
      from: deployer,
      log: true,
      args: [
        POINT_ONE_LINK,
        1e9, // 0.000000001 LINK per gas
      ],
    })

POINT_ONE_LINK and 1e9 are not descriptive for what each stands for, they should be something like:

BASE_FEE,
GAS_PRICE_LINK

Respectively, with a link explaining what each means.

Change PRIVATE_KEY to MNEMONIC in env file

The bash environment variable names (in the readme) are inconsistent with the env file. Rename PRIVATE_KEY as MNEMONIC in the env and example env files, or, add them in addition to PRIVATE_KEY.

Remove "Hardcoded" warning in `RandomNumberConsumer.sol` or clarify what it means

hardhat-starter-kit/contracts/RandomNumberConsumer.sol states:

/**
 * THIS IS AN EXAMPLE CONTRACT WHICH USES HARDCODED VALUES FOR CLARITY.
 * PLEASE DO NOT USE THIS CODE IN PRODUCTION.
 */

But it's unclear what it is referring to when it says "Hardcoded values", it doesn't look like there are any hardcoded values, and the contract appears to be fine for a production deployment aside from maybe also having a withdraw function for any LINK in the contract.

Am I missing something which makes this unsuitable for a production deployment (aside from the withdraw function)? Are there any hardcoded values here?

Link for clarity: https://github.com/smartcontractkit/hardhat-starter-kit/blob/main/contracts/RandomNumberConsumer.sol#L5-L8

Random number is always 0

First of all, thanks for putting this demo repo together.

I'm trying to test some smart contracts that interact with VRF locally. Even though I think I've followed the instructions correctly, I keep getting 0 as the randomly generated number, regardless of the seed.

Looking at the code, it seems like this line would be logging You'll either need to wait another minute, or fix something!, but it won't do that either, since the result is being casted into a string.

        const vrfConsumerContract = new ethers.Contract(contractAddr, RandomNumberConsumer.interface, signer)
        let result = BigInt(await vrfConsumerContract.randomResult()).toString()
        console.log('Random Number is: ', result)
        if (result == 0 && ['hardhat', 'localhost', 'ganache'].indexOf(network.name) == 0) {
            console.log("You'll either need to wait another minute, or fix something!")
        }

Is there anything I could be missing?

Thanks!

Change the LINK token to version 0.4

Version 0.6 of the LINK token imports openzeppelin contracts, which can cause conflicts when others want to use OZ packages.

Default to the mock contract using v0.4 of solidity to avoid collision

Remove mumbai

The developer experience on mumbai is not good. I'd much rather developers use kovan, rinkeby, or other instead.

Many are running into odd unexplained errors.

Extract some parts of this project as separate npm packages

I came across this repository while reading the Chainlink documentation about how to set it up with Hardhat. I gotta say you guys did an amazing job setting this up.

I see some bits of it could be extracted in separate npm packages, which could be used in existing set-ups (when someone doesn't start from this project):

  • Network configs and auto-funding logic: could be probably even shared with the truffle set-up
  • Tasks into a hardhat plugin
  • A new task to generate mock contracts and basic deployment scripts (I believe you can't have contracts and deployments as a plugin), somewhat in Golang generator fashion.

If you guys think it might be a good idea, let me know. I am more than happy to help with this.

The repository could still be used as reference of the final implementation though.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.