Skip to main content

Overview

This page shows how to sign messages using the Turnkey Swift SDK.
The examples below use SwiftUI, but the SDK works with any Swift framework.
You must be authenticated and have an active session in TurnkeyContext.

Signing messages

To sign a transaction using a specific wallet account, use signMessage(signWith:addressFormat:message:...).
SignMessageView.swift
Notes:
  • For Ethereum accounts, signMessage(...) will default to Ethereum-style prefixing unless you override addEthereumPrefix.
  • If you already know the address and its addressFormat, you can call signMessage(signWith: walletAddress,addressFormat: addressFormat,message: message) directly without reading from turnkey.wallets.

Advanced: signing and sending Ethereum transactions

To sign and broadcast Ethereum transactions you can use Web3.swift alongside the Turnkey HTTP client.
This is typically done in a server or other trusted environment. See the full walkthrough in the Swift SDK repo.

Prerequisite

Ensure TurnkeyContext is already configured and provided to your views (e.g., via @EnvironmentObject). The examples below assume an authenticated session is active.

Step 1: setup Web3 and Ethereum address

Step 2: get transaction count (nonce)

Step 3: build the EIP-1559 transaction

Step 4: serialize the transaction to hex

Step 5: sign the transaction with Turnkey

Use the same wallet-selection pattern shown in the message signing example to pick which account to sign with, then call the Turnkey HTTP client.
Once you have the signed transaction, broadcast it with your Web3 client (e.g., eth_sendRawTransaction).