@@ -123,24 +123,30 @@ async def privy_sign_and_send(
123123 # Convert key to PKCS#8 PEM format for SDK compatibility
124124 pem_key = _convert_key_to_pkcs8_pem (privy_auth_key )
125125
126- # Generate authorization signature using SDK
126+ # IMPORTANT: The body must match exactly what the SDK sends to the API
127+ # signAndSendTransaction requires caip2 for Solana
127128 url = f"https://api.privy.io/v1/wallets/{ wallet_id } /rpc"
128129 body = {
129130 "method" : "signAndSendTransaction" ,
130131 "params" : {"transaction" : encoded_tx , "encoding" : "base64" },
132+ "caip2" : "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" ,
133+ "chain_type" : "solana" ,
131134 }
132135 auth_signature = get_authorization_signature (
133136 url = url ,
134137 body = body ,
135- privy_app_id = privy_client .app_id ,
136- privy_authorization_key = pem_key ,
138+ method = "POST" ,
139+ app_id = privy_client .app_id ,
140+ private_key = pem_key ,
137141 )
138142
139143 # Use SDK's wallets.rpc method for signAndSendTransaction
140144 result = await privy_client .wallets .rpc (
141145 wallet_id = wallet_id ,
142146 method = "signAndSendTransaction" ,
143147 params = {"transaction" : encoded_tx , "encoding" : "base64" },
148+ caip2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" ,
149+ chain_type = "solana" ,
144150 privy_authorization_signature = auth_signature ,
145151 )
146152
0 commit comments