> ## 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.

# Kotlin SDK sign and verify

> Sign and verify EVM, Solana, or Tron messages and typed data.

Signing creates a signature without submitting a transaction. Each wallet family has its own methods: the EVM methods require an active Ethereum wallet, and the Solana and Tron methods require an active wallet of that family. Calling a method with an active wallet of another family throws `OMSWalletValidationException` before any request.

Verification can target any wallet. Pass `walletAddress` to verify a signature from a specific address, even while signed out. Omit it to verify against the active wallet's address, which then requires an active session and a wallet of the method's family.

## Sign and verify a message

The message API accepts only `String`. It does not provide a byte-array or hexadecimal-message overload.

```kotlin theme={null}
import technology.polygon.omswallet.Network

val message = "Approve login for Example App"
val signature = omsWallet.wallet.signMessage(
    network = Network.AMOY,
    message = message,
)

val valid = omsWallet.wallet.isValidMessageSignature(
    network = Network.AMOY,
    message = message,
    signature = signature,
)

println("Valid: $valid")
```

Verify with the exact original string and network. Verification returns `false` for a signature that OMS does not validate; request or session failures throw an `OMSWalletException`.

To verify a signature from a specific wallet, pass its address:

```kotlin theme={null}
val valid = omsWallet.wallet.isValidMessageSignature(
    network = Network.AMOY,
    message = message,
    signature = signature,
    walletAddress = "0x1111111111111111111111111111111111111111",
)
```

## Sign and verify a Solana message

For a selected Solana wallet, use the Solana-specific methods. Off-chain messages do not take a network because they are not cluster-specific.

```kotlin theme={null}
val message = "Approve login for example.com"
val signature = omsWallet.wallet.signSolanaMessage(message)

val valid = omsWallet.wallet.isValidSolanaMessageSignature(
    message = message,
    signature = signature,
)

println("Valid: $valid")
```

## Sign and verify EIP-712 typed data

Typed data uses `JsonElement`. Build the complete EIP-712 payload expected by the application and contract:

```kotlin theme={null}
import kotlinx.serialization.json.Json
import technology.polygon.omswallet.Network

val typedData = Json.parseToJsonElement(
    """
    {
      "domain": {
        "name": "Example App",
        "version": "1",
        "chainId": 80002
      },
      "types": {
        "EIP712Domain": [
          { "name": "name", "type": "string" },
          { "name": "version", "type": "string" },
          { "name": "chainId", "type": "uint256" }
        ],
        "Message": [
          { "name": "contents", "type": "string" }
        ]
      },
      "primaryType": "Message",
      "message": {
        "contents": "Approve login for Example App"
      }
    }
    """.trimIndent(),
)

val signature = omsWallet.wallet.signTypedData(
    network = Network.AMOY,
    typedData = typedData,
)

val valid = omsWallet.wallet.isValidTypedDataSignature(
    network = Network.AMOY,
    typedData = typedData,
    signature = signature,
)
```

Use the same typed-data value and network for verification. `isValidTypedDataSignature` also accepts `walletAddress`. Verification does not create a transaction.

## Sign and verify Tron messages and typed data

For a selected Tron wallet, use the Tron-specific methods. They do not take a network.

```kotlin theme={null}
val message = "Approve login for Example App"
val signature = omsWallet.wallet.signTronMessage(message)

val valid = omsWallet.wallet.isValidTronMessageSignature(
    message = message,
    signature = signature,
)
```

`signTronTypedData` and `isValidTronTypedDataSignature` sign and verify TIP-712 typed data. Build the complete TIP-712 payload as a `JsonElement`, as in the EIP-712 example. Address values in the payload may be Base58Check strings that start with `T`.

```kotlin theme={null}
val typedSignature = omsWallet.wallet.signTronTypedData(tronTypedData)

val typedValid = omsWallet.wallet.isValidTronTypedDataSignature(
    typedData = tronTypedData,
    signature = typedSignature,
)
```

Both Tron verification methods accept an optional Base58Check `walletAddress`.
