-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: switch chain for injected, wallet-connect version (#17)
- Loading branch information
Showing
10 changed files
with
102 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# TantoKit Wagmi | ||
|
||
## Installation | ||
|
||
With yarn | ||
|
||
``` | ||
yarn add @sky-mavis/tanto-wagmi | ||
``` | ||
|
||
With npm | ||
|
||
``` | ||
npm install @sky-mavis/tanto-wagmi | ||
``` | ||
|
||
## Usage | ||
|
||
### Create Config | ||
Create and export a new Wagmi config using createConfig where chains and transports are set up for the Ronin and Saigon network and roninWallet() connects to the Ronin wallet, waypoint() connect to Ronin Waypoint. | ||
|
||
```javascript | ||
import { roninWallet, waypoint } from '@sky-mavis/tanto-wagmi'; | ||
import { ronin, saigon } from 'viem/chains'; | ||
import { createConfig, http } from 'wagmi'; | ||
|
||
export const config = createConfig({ | ||
chains: [ronin, saigon], | ||
transports: { | ||
[ronin.id]: http(), | ||
[saigon.id]: http(), | ||
}, | ||
connectors: [roninWallet(), waypoint()], | ||
}) | ||
``` | ||
|
||
### Wrap Application with Providers | ||
|
||
```javascript | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { WagmiProvider } from 'wagmi'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
const App = () => ( | ||
<WagmiProvider config={config}> | ||
<QueryClientProvider client={queryClient}> | ||
<YourComponent /> | ||
</QueryClientProvider> | ||
</WagmiProvider> | ||
); | ||
``` | ||
|
||
### Using Wagmi Hooks | ||
```javascript | ||
import { useAccount, useConnect, useDisconnect, useSignMessage } from 'wagmi'; | ||
import { Button } from '@nextui-org/react'; | ||
|
||
const YourComponent = () => { | ||
const { connect, connectors } = useConnect(); | ||
|
||
return ( | ||
<div> | ||
{connectors.map((connector) => ( | ||
<Button onClick={() => connect({ connector })} key={connector.id}> | ||
Connect to {connector.name} | ||
</Button> | ||
))} | ||
</div> | ||
); | ||
}; | ||
``` | ||
|