-
Clone this Repo
-
Create a free Alchemy account
-
Create a mainnet Alchemy app called
uniswap trading
- You can make the description whatever you want
- Let's keep our app in development for now
- Make sure you select "mainnet" for your network so we pull real data from the blockchian
- Once your app is created you can view your API key anytime by selecting your app and clicking "view key" in the top right corner
-
Install Yarn if you don't have it:
npm install -g yarn
-
Install Truffle
yarn global add truffle
-
Install Ganache by using their download link.
-
In Ganache, select the Ethereum quick start, then connect it to your project by following the instructions here.
-
While in the setting view, select the server tab to enable chain forking with the latest mainnet block:
- Toggle the chain forking switch
- Paste your Alchemy API key under the custom url: https://eth-mainnet.alchemyapi.io/v2/{YOUR_API_KEY}
- Set the block number to the latest number found using our composer. Hit "send request" to view the latest block number in hex format, you'll have to convert it to decimal when inputting it into ganache.
-
In your project directory, install the Contract dependencies:
yarn
-
Instal the dotenv package (to store sensative data)
npm install dotenv --save
- In your project directory, create a
.env
file, adding the following lines of code to it, replacing each value with your unique mnemonic, account address, and alchemy url:
MNEMONIC = "your mnemonic fron ganache"
MAINNET_FROM_ADDRESS = "any account address provided in ganache"
ALCHEMY_MAINNNET_URL = "your alchemy api url"
- Compile the contracts:
truffle compile
- Migrate the contracts onto Ganache:
truffle migrate
-
Navigate to the
trading_scripts
directorycd trading_scripts
-
Install the dependencies of all packages:
yarn
-
Generate the contract types:
yarn generate-contract-types
-
Run the trading script
yarn trade --api_url=YOUR_ALCHEMY_API_URL