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

# Sign and verify with TypeScript

> Sign messages and typed data, then verify signatures for active or explicit wallets.

Signing uses the active wallet session and does not submit a transaction. Signature verification uses the public wallet API. It can verify an explicit wallet without authentication.

## Sign and verify a message

```typescript theme={null}
import { Networks } from '@polygonlabs/oms-wallet'

const message = 'Approve checkout order 1042'

const signature = await omsWallet.wallet.signMessage({
  network: Networks.amoy,
  message,
})

const isValid = await omsWallet.wallet.isValidMessageSignature({
  network: Networks.amoy,
  message,
  signature,
})
```

`signMessage` requires an active session. When verification omits both `walletAddress` and `walletId`, the SDK targets the active wallet ID, so this form also depends on active wallet state.

## Verify an explicit wallet publicly

Pass `walletAddress` or `walletId` to remove the verification call's dependency on an active session. The client still needs the project's publishable key.

```typescript theme={null}
import { Networks, OMSWallet } from '@polygonlabs/oms-wallet'

const publicWallet = new OMSWallet({
  publishableKey: 'YOUR_PUBLISHABLE_KEY',
})

const isValid = await publicWallet.wallet.isValidMessageSignature({
  network: Networks.amoy,
  walletAddress: '0x1111111111111111111111111111111111111111',
  message: 'Approve checkout order 1042',
  signature: submittedSignature,
})
```

This call is read-only and does not establish, restore, or change a wallet session.

## Sign and verify typed data

```typescript theme={null}
import { Networks } from '@polygonlabs/oms-wallet'

const typedData = {
  domain: {
    name: 'Checkout',
    version: '1',
    chainId: 80002n,
  },
  types: {
    Order: [
      { name: 'orderId', type: 'uint256' },
      { name: 'amount', type: 'uint256' },
    ],
  },
  primaryType: 'Order',
  message: {
    orderId: 1042n,
    amount: 1_000_000n,
  },
} as const

const signature = await omsWallet.wallet.signTypedData({
  network: Networks.amoy,
  typedData,
})

const walletAddress = omsWallet.wallet.walletAddress

if (!walletAddress) {
  throw new Error('No active wallet session')
}

const isValid = await omsWallet.wallet.isValidTypedDataSignature({
  network: Networks.amoy,
  walletAddress,
  typedData,
  signature,
})
```

`typedData` is typed as `unknown` in both public parameter interfaces. The SDK accepts a JSON-compatible typed-data object and converts nested `bigint` values to decimal strings for the wallet API. Use the same semantic typed data for signing and verification.

The explicit `walletAddress` above makes verification use the public target path, but `signTypedData` still requires the active session that produced the address. If you already know the target address or wallet ID and signature, you can verify with a newly constructed unauthenticated client as shown for messages.

`isValidMessageSignature` and `isValidTypedDataSignature` return `Promise<boolean>`. A `false` result means the signature did not validate for the supplied target and payload; request or response failures still throw SDK errors.
