<VersionWarning version="0.1" />

# signMessage

Uses a smart account to sign and calculate an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.

With the calculated signature, you can:

* use `verifyMessage` to verify the signature.
* use `recoverMessageAddress` to recover the signing address from a signature.

## Usage

:::code-group
```ts [example.ts]
import { smartAccountClient } from "./smartAccountClient"

const hash = await smartAccountClient.signMessage({
    message: "build with smart accounts!"
})
```

```ts [smartAccountClient.ts]
import { ENTRYPOINT_ADDRESS_V07, createSmartAccountClient } from "permissionless"
import { privateKeyToSimpleSmartAccount } from "permissionless/accounts"
import { createPimlicoPaymasterClient } from "permissionless/clients/pimlico"
import { createPublicClient, http } from "viem"
import { sepolia } from "viem/chains"

export const publicClient = createPublicClient({
	transport: http("https://sepolia.rpc.thirdweb.com"),
})

// if using a paymaster
const paymasterClient = createPimlicoPaymasterClient({
	transport: http("https://api.pimlico.io/v2/sepolia/rpc?apikey=YOUR_PIMLICO_API_KEY"),
	entryPoint: ENTRYPOINT_ADDRESS_V07,
})

export const simpleSmartAccount = await privateKeyToSimpleSmartAccount(publicClient, {
	privateKey: "0xPRIVATE_KEY",
	factoryAddress: "0x91E60e0613810449d098b0b5Ec8b51A0FE8c8985", // simple version
	entryPoint: ENTRYPOINT_ADDRESS_V07,
})

export const smartAccountClient = createSmartAccountClient({
	account: simpleSmartAccount,
	entryPoint: ENTRYPOINT_ADDRESS_V07,
	chain: sepolia, // or whatever chain you are using
	bundlerTransport: http("https://api.pimlico.io/v2/sepolia/rpc?apikey=YOUR_PIMLICO_API_KEY"),
	middleware: {
		sponsorUserOperation: paymasterClient.sponsorUserOperation, // if using a paymaster
	},
})
```
:::

## Returns

* **Type:**\* `Hex`

The signed message.

## Parameters

### message

* **Type:** `string | { raw: Hex | ByteArray }`

Message to sign.
