Forking
Creating a copy of the mainnet to be used within our internal environment
use dummy acc
but do not deploy mocks
add env variable: FORKED_BLOCKCHAIN_ENV
Create mainnet-fork-dev, add to brownie networks
add fork network to brownie [call it mainnet-fork-dev]
add it to development category
brownie networks add development mainnet-fork-dev cmd=ganache-cli host=http:// 127.0.0.1 fork='https://mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID' accounts=10 mnemonic=brownie port=8545
the single quotes in the fork link -> run as is
without single quotes: our env variable would be actualized into the URL
Infura forking typically has issues, so alchemy is suggested:
brownie networks add development mainnet-fork-dev cmd=ganache-cli host=http://127.0.0.1 fork=https://eth-mainnet.alchemyapi.io/v2/j13raIIaPyTnV9ZVv2UnQm48PUFcPDkL accounts=10 mnemonic=brownie port=8545
** mainnet-fork-dev is a development env. it wont have anything in deployment. cannot interact with existing contracts.
Note: brownie comes with mainnet-fork
, no idea what the setup is. PatrickACollins: he deletes and use mainnet-fork-dev as default.
Run testing
brownie test --network mainnet-fork-dev
use our own dummy accounts
deploy new instances of our contracts (fork is dev).
ensure ganacheUI isn't running, else we cannot reference the cloned mainnet contracts
can take awhile for the forked node to respond. cos its coming from alchemy API. wait till you get response.
-- also, if you have ganache running, close it.
-- for some reason brownie attaches to it instead of pulling data from the fork host API.
-- test then fails, cos' there are no deployed contracts to pull price.
Git stuff
git init -b main (init branch called main) git config user.name "" git config user.email "calnix.289@gmail.com"
::push :: git add . _> cache files to staging area git status -> shows files in staging to be pushed
git commit -m 'first commit' git remote add origin git push -u origin main
Last updated