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

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

Signing produces a signature without preparing or submitting a transaction. Signing requires an active wallet session with a wallet of the method's network family. Verification checks the active wallet by default, or any address you pass.

## Sign and verify a message

```swift theme={null}
let message = "Approve login for example.com"

let signature = try await omsWallet.wallet.signMessage(
    network: .amoy,
    message: message
)

let isValid = try await omsWallet.wallet.isValidMessageSignature(
    network: .amoy,
    message: message,
    signature: signature
)

print("Valid:", isValid)
```

`signMessage` returns a hex-encoded signature. Verification returns `Bool`.

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

```swift theme={null}
let message = "Approve login for example.com"
let signature = try await omsWallet.wallet.signSolanaMessage(message: message)

let isValid = try await omsWallet.wallet.isValidSolanaMessageSignature(
    message: message,
    signature: signature
)

print("Valid:", isValid)
```

## Sign and verify typed data

Represent EIP-712 typed data with public `JSONValue` cases.

```swift theme={null}
let typedData: JSONValue = .object([
    "domain": .object([
        "name": .string("Example"),
        "version": .string("1"),
        "chainId": .integer(80002)
    ]),
    "types": .object([
        "Message": .array([
            .object([
                "name": .string("contents"),
                "type": .string("string")
            ])
        ])
    ]),
    "primaryType": .string("Message"),
    "message": .object([
        "contents": .string("Approve login for example.com")
    ])
])

let signature = try await omsWallet.wallet.signTypedData(
    network: .amoy,
    typedData: typedData
)

let isValid = try await omsWallet.wallet.isValidTypedDataSignature(
    network: .amoy,
    typedData: typedData,
    signature: signature
)

print("Valid:", isValid)
```

Use the same network and exact payload for signing and verification.

## Sign and verify with a Tron wallet

For a selected Tron wallet, use the Tron-specific methods. They take no network. `signTronTypedData` and `isValidTronTypedDataSignature` sign and verify TIP-712 typed data, whose address values may be Base58Check strings.

```swift theme={null}
let message = "Approve login for example.com"
let signature = try await omsWallet.wallet.signTronMessage(message: message)

let isValid = try await omsWallet.wallet.isValidTronMessageSignature(
    message: message,
    signature: signature
)

let typedDataSignature = try await omsWallet.wallet.signTronTypedData(
    typedData: tronTypedData
)

let isTypedDataValid = try await omsWallet.wallet.isValidTronTypedDataSignature(
    typedData: tronTypedData,
    signature: typedDataSignature
)
```

`tronTypedData` is a `JSONValue` built the same way as the EIP-712 example above.

## Understand verification context

Every verification method takes an optional `walletAddress`:

* With `walletAddress`, verification needs no wallet session and checks that address.
* Without it, the SDK uses the active wallet's address, so a wallet of the method's network family must be active.

```swift theme={null}
let isValid = try await omsWallet.wallet.isValidMessageSignature(
    network: .amoy,
    walletAddress: "0x1111111111111111111111111111111111111111",
    message: message,
    signature: signature
)
```

Signing always needs an active wallet of the method's network family. Indexer reads accept any address without a session.
