Wagmi is a collection of React hooks for Ethereum Virtual Machine (EVM) compatible networks that makes it easy to work with wallets, contracts, transactions, and signing. Base Account integrates perfectly with Wagmi, allowing you to use all your familiar hooks.You can jump ahead and use the Base Account Wagmi Template to get started.
To create a new wagmi project, you can use the command line:
Report incorrect code
Copy
Ask AI
npm create wagmi@latest
2
Override the Base Account SDK version
To get access to the latest version of the Base Account SDK within Wagmi, you can use the following command to override it:
Report incorrect code
Copy
Ask AI
npm pkg set overrides.@base-org/account="latest"# OR manually add to package.json:# "overrides": { "@base-org/account": "latest" }
Or you can use a specific version by adding the version to the overrides:
Report incorrect code
Copy
Ask AI
npm pkg set overrides.@base-org/account="2.2.0"# OR manually add to package.json:# "overrides": { "@base-org/account": "2.2.0" }
3
Install the dependencies
Install the dependencies with your package manager of choice:
Report incorrect code
Copy
Ask AI
npm install
If this is not your first installMake sure to delete your node_modules and package-lock.json and run a new install to ensure the overrides are applied.
To get access to the latest version of the Base Account SDK within Wagmi, you can use the following command to override it:
Report incorrect code
Copy
Ask AI
npm pkg set overrides.@base-org/account="latest"# OR manually add to package.json:# "overrides": { "@base-org/account": "latest" }
Or you can use a specific version by adding the version to the overrides:
Report incorrect code
Copy
Ask AI
npm pkg set overrides.@base-org/account="2.2.0"# OR manually add to package.json:# "overrides": { "@base-org/account": "2.2.0" }
2
Install the dependencies
Install the dependencies with your package manager of choice:
Report incorrect code
Copy
Ask AI
npm install viem wagmi @tanstack/react-query
If this is not your first installMake sure to delete your node_modules and package-lock.json and run a new install to ensure the overrides are applied.
This is a simple example to get you started.
You will need to add your own backend logic to verify the signature and authenticate the user.You can find a complete example in the Base Account Wagmi Template.