Skip to content

Commit 17e93dd

Browse files
Update dependencies, improve wagmi adapter
1 parent e11b0da commit 17e93dd

File tree

27 files changed

+3013
-295
lines changed

27 files changed

+3013
-295
lines changed

.changeset/grumpy-toes-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/wagmi-adapter": patch
3+
---
4+
5+
Update dependencies, better storage management

.changeset/quiet-gifts-lead.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Update dependencies

apps/wagmi-demo/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_THIRDWEB_CLIENT_ID=

apps/wagmi-demo/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
.env

apps/wagmi-demo/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps = true

apps/wagmi-demo/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Thirdweb Wagmi Adapter
2+
3+
This is a demo of the [thirdweb Wagmi Adapter](https://github.com/thirdweb-dev/js/tree/main/packages/wagmi-adapter).
4+
5+
It demonstrates how to connect [in-app smart wallets](https://portal.thirdweb.com/connect/wallet/sign-in-methods/configure) to a Wagmi app.
6+
7+
Users connect with google, and obtain a ERC-4337 smart account that can be used to interact with the app without paying for gas.
8+
9+
```ts
10+
// src/wagmi.ts
11+
export const config = createConfig({
12+
chains: [chain],
13+
connectors: [
14+
inAppWalletConnector({
15+
client,
16+
smartAccount: {
17+
chain: thirdwebChain(chain),
18+
sponsorGas: true,
19+
},
20+
}),
21+
],
22+
transports: {
23+
[chain.id]: http(),
24+
},
25+
});
26+
```
27+
28+
## Prerequisites
29+
30+
Copy the `.env.example` file to `.env` and set your Thirdweb client ID. You can get your client ID from the [thirdweb dashboard](https://thirdweb.com).
31+
32+
## How to run
33+
34+
```bash
35+
pnpm install
36+
pnpm dev
37+
```

apps/wagmi-demo/biome.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"formatter": {
3+
"enabled": true,
4+
"indentStyle": "space",
5+
"lineWidth": 120
6+
},
7+
"linter": {
8+
"enabled": true
9+
},
10+
"organizeImports": {
11+
"enabled": true
12+
}
13+
}

apps/wagmi-demo/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Create Wagmi</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/src/main.tsx"></script>
11+
</body>
12+
</html>

apps/wagmi-demo/package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "wagmi-inapp",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"lint": "biome check .",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"@tanstack/react-query": "5.90.2",
14+
"@thirdweb-dev/wagmi-adapter": "workspace:*",
15+
"react": "19.1.0",
16+
"react-dom": "19.1.0",
17+
"thirdweb": "workspace:*",
18+
"viem": "2.37.9",
19+
"wagmi": "2.17.5"
20+
},
21+
"devDependencies": {
22+
"@biomejs/biome": "2.0.6",
23+
"@types/react": "19.1.0",
24+
"@types/react-dom": "19.1.0",
25+
"@vitejs/plugin-react": "5.0.4",
26+
"@wagmi/cli": "latest",
27+
"buffer": "^6.0.3",
28+
"typescript": "5.8.3",
29+
"vite": "7.1.7"
30+
}
31+
}

apps/wagmi-demo/src/App.tsx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import {useConnectedWallets} from "thirdweb/react"
2+
import { useAccount, useConnect, useDisconnect, useSendTransaction } from "wagmi";
3+
import { chain } from "./wagmi.js";
4+
5+
function App() {
6+
const account = useAccount();
7+
const { connectors, connect, status, error } = useConnect();
8+
const { disconnect } = useDisconnect();
9+
const { sendTransaction, isPending, isSuccess, isError, error: sendTxError, data: sendTxData } = useSendTransaction();
10+
const wallets = useConnectedWallets();
11+
console.log(wallets);
12+
return (
13+
<>
14+
<div>
15+
<h2>Account</h2>
16+
17+
<div>
18+
status: {account.status}
19+
<br />
20+
addresses: {JSON.stringify(account.addresses)}
21+
<br />
22+
chainId: {account.chainId}
23+
</div>
24+
25+
{account.status === "connected" && (
26+
<button type="button" onClick={() => disconnect()}>
27+
Disconnect
28+
</button>
29+
)}
30+
</div>
31+
32+
<div>
33+
<h2>Connect</h2>
34+
{connectors.map((connector) => (
35+
<button
36+
key={connector.uid}
37+
onClick={() => {
38+
if (connector.id === "in-app-wallet") {
39+
connect({
40+
connector,
41+
chainId: chain.id,
42+
strategy: "google",
43+
});
44+
} else {
45+
connect({ connector, chainId: chain.id });
46+
}
47+
}}
48+
type="button"
49+
>
50+
{connector.name}
51+
</button>
52+
))}
53+
<div>{status}</div>
54+
<div>{error?.message}</div>
55+
</div>
56+
{account && (
57+
<div>
58+
<h2>Transact</h2>
59+
<button onClick={() => sendTransaction({ to: account.address, value: 0n })} type="button">
60+
Send Tx
61+
</button>
62+
<div>{isPending ? "Sending..." : ""}</div>
63+
<div>{isSuccess ? `Success: ${sendTxData}` : isError ? sendTxError?.message : ""}</div>
64+
</div>
65+
)}
66+
</>
67+
);
68+
}
69+
70+
export default App;

0 commit comments

Comments
 (0)