{"id":20974191,"url":"https://github.com/thirdweb-example/wagmi-thirdweb","last_synced_at":"2025-04-12T01:35:49.655Z","repository":{"id":239251641,"uuid":"799014573","full_name":"thirdweb-example/wagmi-thirdweb","owner":"thirdweb-example","description":"thirdweb pay within a wagmi app","archived":false,"fork":false,"pushed_at":"2024-05-20T20:48:17.000Z","size":137,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T21:15:53.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thirdweb-example.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-11T00:43:58.000Z","updated_at":"2025-03-10T22:30:37.000Z","dependencies_parsed_at":"2024-05-11T01:42:44.565Z","dependency_job_id":"9477ff22-0c0a-4362-9ecf-45f981a04701","html_url":"https://github.com/thirdweb-example/wagmi-thirdweb","commit_stats":null,"previous_names":["thirdweb-example/wagmi-thirdweb-pay","thirdweb-example/wagmi-thirdweb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fwagmi-thirdweb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fwagmi-thirdweb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fwagmi-thirdweb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fwagmi-thirdweb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thirdweb-example","download_url":"https://codeload.github.com/thirdweb-example/wagmi-thirdweb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248504735,"owners_count":21115200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T04:27:07.048Z","updated_at":"2025-04-12T01:35:49.617Z","avatar_url":"https://github.com/thirdweb-example.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Use thirdweb in a WAGMI application\n\nThis repo demonstrates how to use thirdweb Pay or any other thirdweb features within an existing WAGMI application.\n\n## 1. Get an API key\n\nGet yourself a [thirdweb API key](https://thirdweb.com/dashboard/settings/api-keys) and add it to the top of `page.tsx`. We recommend putting this in a .env file.\n\n## 2. Setup the provider\n\nTo use the thirdweb react feature, you need to wrap your application with a `\u003cThirdwebProvider\u003e` like shown in `providers.tsx`.\n\n## 3. Convert the wagmi wallet client\n\nOnce connected with a wagmi connector, you can get the wallet client and convert it to a thirdweb compatible wallet.\n\nOnce you have a thirdweb compatible wallet, you simply set it as 'active' and all the thirdweb components and hooks will then use this active wallet.\n\n```tsx\n// This is how to set a wagmi account in the thirdweb context to use with all the thirdweb components including Pay\nconst { data: walletClient } = useWalletClient(); // from wagmi\nconst { switchChainAsync } = useSwitchChain(); // from wagmi\nconst setActiveWallet = useSetActiveWallet(); // from thirdweb\nuseEffect(() =\u003e {\n    const setActive = async () =\u003e {\n        if (walletClient) {\n            const adaptedAccount = viemAdapter.walletClient.fromViem({\n                walletClient: walletClient as any, // accounts for wagmi/viem version mismatches\n            });\n            const w = createWalletAdapter({\n                adaptedAccount,\n                chain: defineChain(await walletClient.getChainId()),\n                client,\n                onDisconnect: async () =\u003e {\n                    await disconnectAsync();\n                },\n                switchChain: async (chain) =\u003e {\n                    await switchChainAsync({ chainId: chain.id as any });\n                },\n            });\n            setActiveWallet(w);\n        }\n    };\n    setActive();\n}, [walletClient, disconnectAsync, switchChainAsync, setActiveWallet]);\n```\n\nView the full source code in `page.tsx`.\n\n## 4. Use thirdweb normally\n\nYou can now use \u003cPayEmbed\u003e, \u003cTransactionButton\u003e or any other thirdweb component / hook and it will use the active connected wallet to perform transactions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthirdweb-example%2Fwagmi-thirdweb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthirdweb-example%2Fwagmi-thirdweb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthirdweb-example%2Fwagmi-thirdweb/lists"}