Installation
Install Sushi via your package manager, a <script>
tag, or build from source.
Package Manager
Install the required packages.
pnpm
pnpm add sushi viem
CDN
If you're not using a package manager, you can also use Sushi via an ESM-compatible CDN such as esm.sh. Simply add a <script type="module">
tag to the bottom of your HTML file with the following content.
<script type="module">
import { getSwap, ChainId } from 'https://esm.sh/sushi'
const swap = await getSwap({
chainId: ChainId.ETHEREUM,
tokenIn: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
tokenOut: '0x6B3595068778DD592e39A122f4f5a5cF09C90fE2',
amount: 1000000000000000000n,
maxSlippage: 0.005
})
console.log(swap)
</script>