This project is a demonstration of a swap on Uniswap V2 (and all forks) using Golang. It does a simple swap using a smart-contract "SwapExecutor" developed in Vyper and Solidity.
- HTTP_RPC - HTTP Rpc Endpoint
- PRIVATE - Private key for the contract executor.
- CONTRACT_ADDRESS - Swap Executor contract address.
- GAS_LIMIT - Gas limit of the swap transaction.
- GAS_PRICE - Gas price of the swap transaction.
- TOKEN_IN - Address of the token in (token to buy with).
- TOKEN_OUT - Address of the token out (token to get).
- AMOUNT_IN - Amount of token in (in wei).
- AMOUNT_OUT_MIN - Amount of token out min (in wei, you can set to 0).
- TO - Address who receives the tokens (you can set the contract).
- ROUTER - Router Address. (ex PancakeSwap, UniswapV2 router).
- CHAINDID - Chain Id of current network. (ex BSC : 56)
git clone https://github.com/deltartificial/simple-swap-go
cd simple-swap-go
- Generate a new bot wallet address and extract the private key into a raw 32-byte format.
- Deploy the included SwapExecutor.sol or SwapExecutor.vy to the blockchain.
- Transfer tokens to the newly wallet address (the swap executor contract creator).
- Customize the environment variables according to your choices.
- You can withdraw the tokens from the contract by calling "recoverTokens()" or "recoverETH()"