SDK Guides
These guides cover the core SDK workflows. Start with the Getting Started for installation and provider setup.
1) Connect to a Wallet (Modal)
Use the modal for the default connection flow.
import React from "react"import { useWalletConnect } from "@dogeos/dogeos-sdk"
export function ConnectButton() { const { openModal, isConnected, disconnect } = useWalletConnect()
return ( <button onClick={() => (isConnected ? disconnect() : openModal())}> {isConnected ? "Disconnect" : "Connect to DogeOS"} </button> )}2) Request a Connection (Programmatic)
If you already have a connector instance, you can request a connection directly. Use the connector you provide in your app’s wallet list.
import { useWalletConnect } from "@dogeos/dogeos-sdk"
export function RequestConnection({ wallet }: { wallet: any }) { const { connect } = useWalletConnect()
const requestConnection = async () => { const result = await connect({ wallet, chainType: "evm", chainId: "0x1", }) console.log("Connected:", result.address) }
return <button onClick={requestConnection}>Request Connection</button>}3) Display the Wallet Address
address is available once the user is connected.
import { useAccount } from "@dogeos/dogeos-sdk"
export function AccountAddress() { const { address, chainId, balance } = useAccount()
if (!address) return <span>Not connected</span>
return ( <div> <div> {address.slice(0, 6)}...{address.slice(-4)} </div> <div>Chain ID: {chainId}</div> <div>Balance: {balance}</div> </div> )}4) Sign a Transaction (EVM)
Use the EIP-1193 provider from currentProvider to sign a transaction. This requires an EVM connection.
import { useAccount } from "@dogeos/dogeos-sdk"
export function SignTransactionButton() { const { address, currentProvider, chainType } = useAccount()
const signTransaction = async () => { if (!currentProvider || !address || chainType !== "evm") return
const chainId = await currentProvider.request({ method: "eth_chainId" }) const transaction = { to: address, from: address, value: "0x0", data: "0x", chainId, }
const signed = await currentProvider.request({ method: "eth_signTransaction", params: [transaction], })
console.log("Signed transaction:", signed) }
return <button onClick={signTransaction}>Sign Transaction</button>}5) Sign a Message
Use signMessage for message signing.
import { useAccount } from "@dogeos/dogeos-sdk"
export function SignMessageButton() { const { signMessage } = useAccount()
const sign = async () => { const signature = await signMessage?.({ message: "Welcome to DogeOS!", nonce: Math.random().toString(36).slice(2), }) console.log("Signature:", signature) }
return <button onClick={sign}>Sign Message</button>}Other EVM Provider Calls
Use currentProvider.request for standard EVM actions like:
eth_chainIdwallet_switchEthereumChaineth_signTypedData_v4eth_sendTransaction
import { useAccount } from "@dogeos/dogeos-sdk"
export function GetChainIdButton() { const { currentProvider } = useAccount()
const getChainId = async () => { if (!currentProvider) return const chainId = await currentProvider.request({ method: "eth_chainId" }) console.log("Chain ID:", chainId) }
return <button onClick={getChainId}>Get Chain ID</button>}Additional Account Actions
Sign in With Wallet
import { useAccount } from "@dogeos/dogeos-sdk"
export function SignInButton() { const { signInWithWallet } = useAccount()
const signIn = async () => { const token = await signInWithWallet({ scheme: "https", domain: window.location.host, statement: "Sign in to DogeOS", version: "1", nonce: Math.random().toString(36).slice(2), issuedAt: new Date().toISOString(), resources: ["https://docs.dogeos.com"], }) console.log("Sign-in token:", token) }
return <button onClick={signIn}>Sign In With Wallet</button>}Switch Chains (EVM)
switchChain returns true on success, false on failure.
import { useAccount, type Chain } from "@dogeos/dogeos-sdk"
export function SwitchChainButton({ chainInfo }: { chainInfo: Chain }) { const { switchChain } = useAccount()
const onSwitch = async () => { const success = await switchChain({ chainType: "evm", chainInfo }) if (!success) { console.error("Failed to switch chain") } }
return <button onClick={onSwitch}>Switch Chain</button>}