Skip to main content
Note: see the language section for various approaches on writing Solana policies.
For sponsored Solana transactions, start with Solana Rent Sponsorship before applying the examples below. That guide covers account-creation risk, rent refunds, and mitigation strategy for sponsored flows.

Allow IDL-specific program instructions

See Smart Contract Interfaces for more information and examples.

Allow V1 transfers with explicit resource limits

See Solana transactions for transaction construction and V1 config fields for units. Replace the placeholders with your non-root user ID, wallet ID, and Solana addresses before creating these policies. This policy permits one System Program transfer of up to 10,000,000 lamports from one sender to one recipient. It caps the V1 priority fee in unsignedTransaction at 1,000 total lamports and requires explicit resource limits within the stated bounds.
For example, set the V1 transaction config to 200,000 CU, 67,108,864 loaded-account bytes, 32,768 heap bytes, and a 1,000-lamport priority fee. Turnkey preserves these explicit config values during sponsorship. Policies inspect the instructions in unsignedTransaction, so sponsor-added rent-funding instructions do not change this policy’s instruction count.
An absent V1 priority fee reads as zero, but sponsorship can fill a nonzero fee later. Supply the priority fee explicitly, including zero, to make this cap apply to the final sponsored fee. The policy cannot distinguish an absent priority fee from an explicit zero. This policy alone cannot enforce a final sponsored fee cap when callers can omit the fee.
If a V1 resource limit is absent, this policy produces an evaluation error. It also produces an error for legacy/V0, because those transactions have no V1 config fields. The version check does not prevent this access: && and || do not short-circuit.

Allow the same transfer for legacy and V0

If your application also accepts legacy/V0, create this separate policy alongside the V1 policy. It repeats the user, wallet, and transfer restrictions without accessing V1-only fields.
This example permits no customer-supplied Compute Budget instructions. For sponsored legacy/V0 sends, Turnkey can add compute and fee values after policy evaluation. If your application accepts explicit legacy/V0 compute and fee controls, add their instruction checks to this version-scoped policy. A matching explicit allow can authorize a legacy/V0 request despite the V1 policy’s evaluation error. An explicit deny takes precedence over either allow. Review existing allow policies before adding these examples: a broader allow can still authorize transactions that fail these conditions.

Deny V1 until policy migration is complete

This optional policy prevents non-root users from using V1 while you update instruction-based fee policies. It reads only the version field, which is available for all three Solana transaction versions. Remove it when your V1 policies are ready; its explicit deny overrides V1 allow policies.
Test policies with a non-root user; root quorum authorization can bypass policy restrictions. Include V1 transactions with allowed and excessive fees, missing resource limits, and explicit zero fees, plus legacy/V0 regression cases.

Allow Solana transactions that include a transfer from one specific sender

Allow Solana transactions that include a transfer to only one specific recipient

Allow Solana transactions that have exactly one transfer, to one specific recipient

Allow Solana transactions that only use the Solana System Program

Deny all Solana transactions transferring to an undesired address

Allow Solana transactions with specific expected instruction data

Allow Solana transactions whose first instruction involves a specific address

Deny all address table lookups

Deny sending to an address from a table lookup

Solana SPL token transfers — context and examples

Turnkey’s policy engine supports policies for SPL token transfers. Specifically, we support creating policies for the Transfer, TransferChecked and TransferCheckedWithFee instructions across both the Solana Token Program and the Solana Token 2022 Program. Some important context for using SPL token policies with Turnkey: Token Account Addresses For context, Solana implements SPL token balances for a particular wallet address by creating a whole new account called a “token account” which has a pointer in its data field labeled “owner” that points back to the wallet address in question. So to hold a particular token in your Solana wallet, you have to create a new token account meant to hold that token, owned by your Solana wallet. For policies related to the receiving token address of an SPL transfer, the token address receiving the tokens will have to be used, NOT the wallet address that is the owner for the receiving token address. This is because, while both the owning wallet address and the receiving token address are specified in the transfer instruction, the owning wallet address of the recipient token address is not specified. For this we highly recommend using the convention of “associated token addresses” to set policies that, for example, allow SPL token transfers to a particular wallet address. For further context on associated token addresses check out Solana’s documentation on it: https://spl.solana.com/associated-token-account
An example implementation of using a policy to allow transfers to the associated token address of the intended recipient wallet address can be found in our SDK examples here.
Mint Address Accessibility The mint account address of the token will only be accessible when the transaction is constructed using instructions that specify the mint address – TransferChecked and TransferCheckedWithFee. For transactions constructed using the simple Transfer method, the mint account will be considered empty. Here are some example policies for SPL transfers:

Allow a user to sign Solana transactions that include a single instruction which is an SPL token transfer from a particular sending token address

Allow a user to sign Solana transactions only if ALL of the instructions are SPL transfers TO a particular token address

Allow users with a specific tag to sign Solana transactions only if ALL of the instructions are SPL token transfers with a specific address as the owner of the sending token address

Allow a user to sign Solana transactions that include a single instruction which is an SPL token transfer where the atomic units of the transfer are less than a threshold amount

Allow a user to sign Solana transactions only if ALL of the instructions are SPL token transfers where the token mint address is a particular address

Allow a user to sign Solana transactions that includes a single instruction which is an SPL token transfer where one of the multisig signers of the owner is a particular address