EIP-7702 enables externally owned accounts (EOAs) to delegate their execution to smart contract code. This allows EOA wallets to gain account abstraction capabilities such as transaction bundling, gas sponsorship, and custom permissions.
Privy provides methods to sign EIP-7702 authorizations, which allows your embedded wallets to be upgraded into any smart contract. Learn more about EIP-7702 and how to use it with various account abstraction providers.
EIP-7702 authorization signing is supported in the React SDK, REST API, and Node SDK.
When using Privy’s server-side SDKs to sign EIP-7702 authorizations, you can use the authorization
context to automatically sign requests. Learn more about signing on the
server .
React
React Native
REST API
NodeJS
NodeJS (server-auth)
Java
Rust
Use the useSign7702Authorization hook to sign an EIP-7702 authorization with your user’s wallet. import { useSign7702Authorization } from '@privy-io/react-auth' ;
const { signAuthorization } = useSign7702Authorization ();
Usage import { useSign7702Authorization , useWallets } from '@privy-io/react-auth' ;
function Sign7702Button () {
const { signAuthorization } = useSign7702Authorization ();
const { wallets } = useWallets ();
const handleSign = async () => {
try {
const authorization = await signAuthorization ({
contractAddress: '0x1234567890abcdef1234567890abcdef12345678' ,
chainId: 1 , // Ethereum mainnet
nonce: 0 // Optional, defaults to current nonce
}, {
address: wallets [ 0 ]. address // Optional: Specify the wallet to use for signing. If not provided, the first wallet will be used.
});
console . log ( 'Signed authorization:' , authorization );
// Use the authorization with your AA provider
} catch ( error ) {
console . error ( 'Failed to sign authorization:' , error );
}
};
return (
< button onClick = { handleSign } >
Sign EIP-7702 Authorization
</ button >
);
}
Parameters The address of the smart contract whose code the EOA will delegate to. This is typically an account implementation contract from your AA provider.
The chain ID where the authorization will be used.
The nonce for the authorization. If not provided, the current transaction count for the wallet will be used.
The address of the wallet to use for signing the authorization. Recommended when working with external wallets to ensure reliable functionality. If not provided, the first wallet will be used.
Returns The signed EIP-7702 authorization object containing: The smart contract address the EOA is delegating to.
The chain ID for the authorization.
The nonce used in the authorization.
The r value of the ECDSA signature.
The s value of the ECDSA signature.
The yParity value of the ECDSA signature.
Sign an EIP-7702 authorization using viem and the @privy-io/expo SDK. Usage import { useEmbeddedEthereumWallet } from '@privy-io/expo' ;
import { createWalletClient , custom } from 'viem ;
import { hashAuthorization } from 'viem/utils' ;
import { mainnet } from 'viem/chains' ;
const { wallets } = useEmbeddedEthereumWallet ();
const wallet = wallets [ 0 ]
const provider = await wallet . getProvider ()
const client = createWalletClient ({
account: wallet . address as `0x ${ string } ` ,
chain: mainnet ,
transport: custom ( provider ) // or another provider
});
const authorizationPayload = await walletClient . prepareAuthorization ({
account: selectedWallet . address as `0x ${ string } ` ,
contract: '0x1234567890abcdef1234567890abcdef12345678' ,
chainId: 1 ,
});
const hashedAuthorization = hashAuthorization ( authorizationPayload );
const authorization = provider . request ({
method: 'secp256k1_sign' ,
params: [ hashedAuthorization ]
});
Parameters and Returns Check out the sign raw hash doc for more details. Sign an EIP-7702 authorization by making a POST request to: https://api.privy.io/v1/wallets/ <wallet_id>/rpc
Usage $ curl --request POST https://api.privy.io/v1/wallets/ < wallet_i d > /rpc \
-u "<your-privy-app-id>:<your-privy-app-secret>" \
-H "privy-app-id: <your-privy-app-id>" \
-H "privy-authorization-signature: <authorization-signature-for-request>" \
-H 'Content-Type: application/json' \
-d '{
"method": "eth_sign7702Authorization",
"params": {
"contract": "0x1234567890abcdef1234567890abcdef12345678",
"chain_id": 1,
"nonce": 0
}
}'
A successful response will look like: {
"method" : "eth_sign7702Authorization" ,
"data" : {
"authorization" : {
"address" : "0x1234567890abcdef1234567890abcdef12345678" ,
"chain_id" : 1 ,
"nonce" : 0 ,
"r" : "0x..." ,
"s" : "0x..." ,
"y_parity" : "0"
}
}
}
Parameters method
'eth_sign7702Authorization'
required
The RPC method to execute.
The address of the smart contract whose code the EOA will delegate to.
The chain ID where the authorization will be used.
The nonce for the authorization. If not provided, the current transaction count will be used.
Returns method
'eth_sign7702Authorization'
The RPC method that was executed.
The signed EIP-7702 authorization containing: The smart contract address the EOA is delegating to.
The chain ID for the authorization.
The nonce used in the authorization.
The r value of the ECDSA signature.
The s value of the ECDSA signature.
The yParity value of the ECDSA signature.
Use the sign7702Authorization method on the Ethereum interface to sign an EIP-7702 authorization with an Ethereum wallet. Usage const authorization = await privy . wallets (). ethereum (). sign7702Authorization ( 'insert-wallet-id' , {
params: {
contract: '0x1234567890abcdef1234567890abcdef12345678' ,
chainId: 1 ,
nonce: 0 // Optional
}
});
Parameters and Returns Check out the API reference for more details. The @privy-io/server-auth library is deprecated. We recommend integrating @privy-io/node for
the latest features and support.
Use the sign7702Authorization method on the Ethereum client to sign an EIP-7702 authorization with an Ethereum wallet. sign7702Authorization : async ({ walletId : string , contract : string , chainId : number , nonce ?: number , idempotencyKey ?: string }) => Promise < { chainId , contract , nonce , yParity , r , s } >
Usage const authorization = await privy . walletApi . ethereum . sign7702Authorization ({
walletId: 'insert-wallet-id' ,
contract: '0x1234567890abcdef1234567890abcdef12345678' ,
chainId: 1 ,
nonce: 0 // Optional
});
Parameters Unique ID of the wallet to take actions with.
The address of the smart contract whose code the EOA will delegate to.
The chain ID where the authorization will be used.
The nonce for the authorization. If not provided, the current transaction count will be used.
Returns The chain ID for the authorization.
The smart contract address the EOA is delegating to.
The nonce used in the authorization.
The yParity value of the ECDSA signature.
The r value of the ECDSA signature.
The s value of the ECDSA signature.
To sign an EIP-7702 authorization from your wallet, use the sign7702Authorization method. Usage try {
EthereumSign7702AuthorizationRpcInputParams authorization = EthereumSign7702AuthorizationRpcInputParams . builder ()
. contract ( "0x1234567890123456789012345678901234567890" )
. chainId ( EthereumSign7702AuthorizationRpcInputChainId . of ( 1 ))
. nonce ( EthereumSign7702AuthorizationRpcInputNonce . of ( 1 ))
. build ();
// Example: If wallet's owner is an authorization private key
AuthorizationContext authorizationContext = AuthorizationContext . builder ()
. addAuthorizationPrivateKey ( "authorization-key" )
. build ();
EthereumSign7702AuthorizationRpcResponseData response = privyClient
. wallets ()
. ethereum ()
. sign7702Authorization (
walletId,
authorization,
authorizationContext
);
Authorization authorization = response . authorization ();
} catch ( APIException e ) {
String errorBody = e . bodyAsString ();
System . err . println (errorBody);
} catch ( Exception e ) {
System . err . println ( e . getMessage ());
}
Parameters When defining an EIP-7702 authorization, you may specify the following values on the
EthereumSign7702AuthorizationRpcInputParams builder: The address of the smart contract whose code the EOA will delegate to.
chainId
EthereumSign7702AuthorizationRpcInputChainId
The chain ID where the authorization will be used.
nonce
EthereumSign7702AuthorizationRpcInputNonce
The nonce for the authorization.
Returns The EthereumSign7702AuthorizationRpcResponseData object contains a authorization() field The signed EIP-7702 authorization. The smart contract address the EOA is delegating to.
chainId
EthereumSign7702AuthorizationRpcInputChainId
The chain ID for the authorization.
nonce
EthereumSign7702AuthorizationRpcInputNonce
The nonce used in the authorization.
The r value of the ECDSA signature.
The s value of the ECDSA signature.
The yParity value of the ECDSA signature.
Use the sign_7702_authorization method on the Ethereum service to sign an EIP-7702 authorization. Usage use privy_rs :: { AuthorizationContext , PrivyClient };
let client = PrivyClient :: new ( "app_id" . to_string (), "app_secret" . to_string ()) ? ;
let ethereum_service = client . wallets () . ethereum ();
let auth_ctx = AuthorizationContext :: new ();
let params = EthereumSign7702AuthorizationRpcInputParams {
chain_id : EthereumSign7702AuthorizationRpcInputParamsChainId :: Integer ( 1 ),
contract : "0x1234567890abcdef1234567890abcdef12345678" . to_string (),
nonce : None ,
};
let authorization = ethereum_service
. sign_7702_authorization ( & wallet_id , params , & auth_ctx , None )
. await ? ;
println! ( "7702 authorization signed successfully" );
Parameters and Returns See the Rust SDK documentation for detailed parameter and return types, including embedded examples: For REST API details, see the API reference .