diff --git a/packages/@magic-sdk/provider/src/modules/wallet.ts b/packages/@magic-sdk/provider/src/modules/wallet.ts index 902d282f9..df5fe8af1 100644 --- a/packages/@magic-sdk/provider/src/modules/wallet.ts +++ b/packages/@magic-sdk/provider/src/modules/wallet.ts @@ -5,6 +5,8 @@ import { ShowUIPromiEvents, Sign7702AuthorizationRequest, Sign7702AuthorizationResponse, + Send7702TransactionRequest, + Send7702TransactionResponse, } from '@magic-sdk/types'; import { BaseModule } from './base-module'; import { createJsonRpcRequestPayload } from '../core/json-rpc'; @@ -92,4 +94,33 @@ export class WalletModule extends BaseModule { createJsonRpcRequestPayload(MagicPayloadMethod.Sign7702Authorization, [params]), ); } + + /** + * Send an EIP-7702 (Type-4) transaction with an authorization list. + * This allows executing transactions with delegated smart contract implementations. + * + * @param params - The transaction parameters including to, value, data, gas settings, and authorizationList + * @returns Promise resolving to the transaction hash + * + * @example + * ```typescript + * // First, sign the authorization + * const auth = await magic.wallet.sign7702Authorization({ + * contractAddress: '0x000000004F43C49e93C970E84001853a70923B03', + * chainId: 1, + * }); + * + * // Then, send the transaction with the authorization + * const { transactionHash } = await magic.wallet.send7702Transaction({ + * to: '0x...', + * data: '0x...', + * authorizationList: [auth], + * }); + * ``` + */ + public send7702Transaction(params: Send7702TransactionRequest) { + return this.request( + createJsonRpcRequestPayload(MagicPayloadMethod.Send7702Transaction, [params]), + ); + } } diff --git a/packages/@magic-sdk/types/src/core/json-rpc-types.ts b/packages/@magic-sdk/types/src/core/json-rpc-types.ts index 1b5a9218d..0fa45d39b 100644 --- a/packages/@magic-sdk/types/src/core/json-rpc-types.ts +++ b/packages/@magic-sdk/types/src/core/json-rpc-types.ts @@ -130,6 +130,7 @@ export enum MagicPayloadMethod { DisableMFA = 'magic_auth_disable_mfa_flow', GetMultichainPublicAddress = 'magic_get_multichain_public_address', Sign7702Authorization = 'magic_wallet_sign_7702_authorization', + Send7702Transaction = 'eth_send7702Transaction', } // Methods to not route if connected to third party wallet diff --git a/packages/@magic-sdk/types/src/modules/wallet-types.ts b/packages/@magic-sdk/types/src/modules/wallet-types.ts index d2c0c568c..ebd62397d 100644 --- a/packages/@magic-sdk/types/src/modules/wallet-types.ts +++ b/packages/@magic-sdk/types/src/modules/wallet-types.ts @@ -68,3 +68,63 @@ export interface Sign7702AuthorizationResponse { */ signature?: string; } + +/** + * Request parameters for sending an EIP-7702 transaction with authorization list + */ +export interface Send7702TransactionRequest { + /** + * The recipient address + */ + to: string; + + /** + * The value to send in wei (as hex string) + */ + value?: string; + + /** + * The transaction data (calldata) + */ + data?: string; + + /** + * Gas limit for the transaction (as hex string) + */ + gas?: string; + + /** + * Gas limit for the transaction (alias for gas) + */ + gasLimit?: string; + + /** + * Maximum fee per gas for EIP-1559 transactions (as hex string) + */ + maxFeePerGas?: string; + + /** + * Maximum priority fee per gas for EIP-1559 transactions (as hex string) + */ + maxPriorityFeePerGas?: string; + + /** + * Transaction nonce (if not provided, will be fetched from network) + */ + nonce?: number; + + /** + * The list of signed EIP-7702 authorizations to include in the transaction + */ + authorizationList: Sign7702AuthorizationResponse[]; +} + +/** + * Response from sending an EIP-7702 transaction + */ +export interface Send7702TransactionResponse { + /** + * The transaction hash + */ + transactionHash: string; +}