> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sophon.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrating with Wagmi

To integrate Sophon Account with Wagmi, you need to install the `@sophon-labs/account-connector` package.

```bash theme={null}
npm install @sophon-labs/account-connector
```

Then, you need to create a new connector:

```ts theme={null}
import { sophon, sophonTestnet } from "viem/chains";
import { createConfig, http, WagmiProvider } from "wagmi";

// Wagmi config
const wagmiConfig = createConfig({
  chains: [sophonTestnet],
  connectors: [sophonSsoConnector("testnet")], // or 'mainnet'
  transports: {
    [sophon.id]: http(),
    [sophonTestnet.id]: http(),
  },
});
```

And that's it, you can now use wagmi hooks and componentes to interact with Sophon Account.

## Signin Messages

Simple message signature is supported:

```ts theme={null}
import { useSignMessage } from "wagmi";

// ...
const { signMessage } = useSignMessage();

// ...
signMessage({
  message: "Hello from Sophon SSO!",
});
```

## Signin Types Messages

Typed data signature is supported:

```ts theme={null}
import { useSignTypedData } from "wagmi";

// ...
const { signMessage } = useSignTypedData();

// ...
signTypedData({
  domain: {
    name: "Sophon SSO",
    version: "1",
    chainId: sophonTestnet.id,
  },
  types: {
    Message: [
      { name: "content", type: "string" },
      { name: "from", type: "address" },
      { name: "timestamp", type: "uint256" },
    ],
  },
  primaryType: "Message",
  message: {
    content: `Hello from Sophon SSO!\n\nThis message confirms you control this wallet.`,
    from: address as `0x${string}`,
    timestamp: BigInt(Math.floor(Date.now() / 1000)),
  },
});
```

<Card title="Wagmi Connector Example" icon="github" href="https://github.com/sophon-org/sophon-account-sso/tree/main/examples/web/wagmi" arrow="true" cta="Read more">
  You can check an example of using a custom Wagmi connector with Sophon
  Account.
</Card>
