Code Monkey home page Code Monkey logo

uniswap-v3-sdk-tutorial-ts's Introduction

Uniswap V3 SDK swap tutorial in TypeScript, Ethers.js

Swapping tokens on EVM-compatible blockchains: Mainnet, Polygon, testnets Goerli, Rinkeby. You can read blog post on this tutorial with detailed explanation.

To run this example:

  1. npm install to install dependencies.

  2. Customize package.json. Basically, you need to change 5 parameters of run task from scripts section

    1. --chain-id is chain ID of Ethereum chain you work with.
    2. --amount-in amount of input token you want to swap. Change according to your balance โ€“ there is no check
    3. --token-in-address smart contract address of input token
    4. --token-out-address smart contract address of output token
    5. --wallet-address your actual wallet address โ€“ replace [YOUR_WALLET_ADDRESS].

    In scripts sections you can see sample configurations for few networks (start-matic, start-rinkeby, start-goerli). In scripts-comments sections you'll find descriptions of each configuration.

  3. Create .env file and put up there the following code according to network you gonna use:

    API_URL = "API_URL from https://www.alchemy.com"
    PRIVATE_KEY = "WALLET_PRIVATE_KEY"
    

    Replace API_URL with URL from Alchemy, WALLET_PRIVATE_KEY by your wallet' private key (you can get it from Metamask).

    (Don't publish these keys anywhere in public!)

  4. Run configuration for certain network, e.g. npm run start-matic for Matic (Polygon) network. Please note the tutorial is for demostration purposes and it misses lots of checks.


Happy hacking!

If you have a question or something does not work, you can ask in comment section in my blog or post an issue.

uniswap-v3-sdk-tutorial-ts's People

Contributors

techgeorgii avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.