Skip to content

YNX940214/rust-uniswap-v2-tutorial

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Uniswap V2 token swap example in Rust

This repository is the completed result for the article on my blog: TMS Blog - How to swap on Uniswap V2 with Rust Web3. This article describes how to execute a swap transaction of ETH for a token on the Uniswap V2 decentralized exchange.

Set up

This project expects certain environment variables to be set. The easiest way is to create a .env file containing the following values:

INFURA_RINKEBY=wss://rinkeby.infura.io/ws/v3/xxxxxxx
PRIVATE_TEST_KEY=xxxxxxxxxxxx
ACCOUNT_ADDRESS=xxxxxxxxxx

Where INFURA_RINKEBY is an endpoint from your infura.io account. PRIVATE_TEST_KEY is a private key from a crypto wallet / account. And, ACCOUNT_ADDRESS is a wallet account address.

Running the project

Caution: running the project with correct configuration will execute a swap of ETH for DAI without asking for confirmation. This example should be run on an Ethereum test network.

cargo run

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%