elanh / uniswap-trading-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uniswap Trading!

Setting up Truffle and Ganache

  1. Clone this Repo

  2. Create a free Alchemy account

  3. 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
  4. Install Yarn if you don't have it:

    npm install -g yarn
    
  5. Install Truffle

    yarn global add truffle
    
  6. Install Ganache by using their download link.

  7. In Ganache, select the Ethereum quick start, then connect it to your project by following the instructions here.

  8. While in the setting view, select the server tab to enable chain forking with the latest mainnet block:

  9. In your project directory, install the Contract dependencies:

    yarn
    
  10. Instal the dotenv package (to store sensative data)

npm install dotenv --save
  1. 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"
  1. Compile the contracts:
truffle compile
  1. Migrate the contracts onto Ganache:
truffle migrate

Running the trading script

  1. Navigate to the trading_scripts directory

    cd trading_scripts
    
  2. Install the dependencies of all packages:

    yarn
    
  3. Generate the contract types:

    yarn generate-contract-types
    
  4. Run the trading script

    yarn trade --api_url=YOUR_ALCHEMY_API_URL
    

About

License:MIT License


Languages

Language:TypeScript 75.4%Language:JavaScript 17.4%Language:Solidity 7.2%