Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions packages/@magic-sdk/provider/src/modules/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<Send7702TransactionResponse>(
createJsonRpcRequestPayload(MagicPayloadMethod.Send7702Transaction, [params]),
);
}
}
1 change: 1 addition & 0 deletions packages/@magic-sdk/types/src/core/json-rpc-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
60 changes: 60 additions & 0 deletions packages/@magic-sdk/types/src/modules/wallet-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}