Closed JongCleo closed 2 years ago
Hi!
Great question. It's not smart enough, however, before you call fund with link, you'll often call deploy_mocks, which will deploy a mock LINK token.
In our deploy scripts, we call get_contract
which calls the deploy_mocks
if on a local network:
Ah silly oversight on my part, thanks @PatrickAlphaC for pointing that out.
Just to be super clear for anyone else that got confused:
In a development, local blockchain context:
In the LinkToken constructor,
https://github.com/PatrickAlphaC/smartcontract-lottery/blob/8876d504b707883f148f9a8cac7a287b90d0f5df/contracts/test/LinkToken.sol#L14
Contract allocates the entire token supply of 1 billion LINK tokens to Msg.sender
(our wallet)
fund_with_link()
is called and transfer 0.1 LINK from our wallet to the Lottery contract, leaving our balance at 999.99 million LINK
https://github.com/PatrickAlphaC/smartcontract-lottery/blob/8876d504b707883f148f9a8cac7a287b90d0f5df/scripts/helpful_scripts.py#L81
When
fund_with_link()
is called on a live testnet like Rinkeby,get_account
resolves to our real metamask wallet, which is probably loaded with LINK from a chainlink faucet.When
fund_with_link()
is called on a local blockchain network, is ganache smart enough to generate LINK on demand from its test account?