https://github.com/fadeev/swap
https://github.com/fadeev/swap
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/fadeev/swap
- Owner: fadeev
- Created: 2024-07-10T14:16:36.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-16T08:58:58.000Z (almost 2 years ago)
- Last Synced: 2025-02-15T19:54:27.987Z (over 1 year ago)
- Language: TypeScript
- Size: 443 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Components
```
yarn add @fadeev/swap
```
Should be compatible with a RainbowKit enabled Next.js app, for example:
https://github.com/fadeev/template
Adding a swap component to a app-router Next.js app:
```ts
"use client";
import { ConnectButton } from "@rainbow-me/rainbowkit";
import {
Balances,
useEthersSigner,
useZetaChainClient,
} from "@fadeev/swap/dist";
import { useAccount, useSwitchChain, useChainId, useWalletClient } from "wagmi";
// universal swap app contract on ZetaChain
// https://github.com/zeta-chain/example-contracts/tree/main/omnichain/swap
const contract = "0xb459F14260D1dc6484CE56EB0826be317171e91F";
const url = "ZETACHAIN_EVM_ENDPOINT";
function Page() {
const { address } = useAccount();
const { switchChain } = useSwitchChain();
const chainId = useChainId();
const { data: walletClient } = useWalletClient({ chainId });
const signer = useEthersSigner({ walletClient });
const client = useZetaChainClient({ signer, url });
return (
{client && (
)}
);
}
export default Page;
```