Skip to content

Commit

Permalink
add create wallet button examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nateReiners committed May 9, 2024
1 parent d90d158 commit 6b49da8
Showing 3 changed files with 51 additions and 1 deletion.
46 changes: 46 additions & 0 deletions docs/pages/guides/create-wallet-button.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Add a Create a Wallet button to your appChainIds

## With wagmi

```tsx
import { useConnect } from "wagmi";

export function WagmiCreateWalletButton() {
const { connectors, connect } = useConnect();

return <button onClick={() => connect({ connector: connectors[0] })}>Create a Wallet</button>;
}
```

Upon successful connection, access account information via the [`useAccount`](https://wagmi.sh/react/api/hooks/useAccount) hook.

## Without wagmi

```tsx
import { CoinbaseWalletSDK } from "@coinbase/wallet-sdk";

const sdk = new CoinbaseWalletSDK({
appName: "My Dapp",
appLogoUrl: "https://example.com/logo.png",
appChainIds: [84532],
});

const provider = sdk.makeWeb3Provider();

interface CreateWalletButtonProps {
handleSuccess: (res: any) => void;
handleError: (error: any) => void;
}

export function CreateWalletButton({ handleSuccess, handleError }: CreateWalletButtonProps) {
const connectToSmartWallet = async () => {
try {
const [address] = await provider.request<string[]>({ method: "eth_requestAccounts" });
handleSuccess(address);
} catch (error) {
handleError(error);
}
};
return <button onClick={connectToSmartWallet}>Create a Wallet</button>;
}
```
2 changes: 1 addition & 1 deletion docs/pages/guides/update-existing-app.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Update an existing project
If your project or its dependencies are already using
Coinbase Wallet SDK beta, just add the following to `package.json`.
Coinbase Wallet SDK, just add the following to `package.json`.
```json
"resolutions": {
"@coinbase/wallet-sdk": "npm:@coinbase/wallet-sdk@4.0.0-beta.12"
4 changes: 4 additions & 0 deletions vocs.config.ts
Original file line number Diff line number Diff line change
@@ -61,6 +61,10 @@ export default defineConfig({
text: "Update an existing app",
link: "/guides/update-existing-app",
},
{
text: "Add Create Wallet Button",
link: "/guides/create-wallet-button",
},
{
text: "Signature Verification",
link: "/guides/signature-verification",

0 comments on commit 6b49da8

Please sign in to comment.