-Script to perform an ERC20 token swap utilizing the 1Inch Api -Configured for https://localhost:7545 Ethereum Mainnet Fork (via Ganache) -Uses Ethers.jS
- Node
- Ethers (Blockchain Interaction)
- Truffle (Development Framework)
- Ganache-cli (For Local Blockchain)
- Alchemy (For forking the Ethereum mainnet)
- Install NodeJS, I recommend using node version 16.5.0 to avoid any potential dependency issues
- Install Truffle, In your terminal, you can check to see if you have truffle by running
truffle --version
. To install truffle runnpm i -g truffle
. - Install Ganache-cli. To see if you have ganache-cli installed, in your command line type
ganache-cli --version
. To install, in your command line typenpm install ganache-cli --global
$ npm install
You will need to fork the Ethereum Mainnet onto your local machine. The command below will do just this, while unlocking the account address which you provide.
- Please note, whichever address you choose to unlock, must be cooresponding to the UNLOCKED_ACCOUNT variable in 1inch_Swap.js
In your terminal run:
ganache-cli -f wss://eth-mainnet.alchemyapi.io/v2/<Your-App-Key> -u <UNLOCKED_ACCOUNT_ADDRESS> -p 7545
The script will run using UNLOCKED_ACCOUNT. Must match whichever account you chose to unlock when forking.
$ truffle exec ./scripts/1inch_Swap.js`