Skip to content

Commit 6a7d126

Browse files
[Wallets] Add documentation for create7702MinimalAccount function
1 parent 14fe9ee commit 6a7d126

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,71 @@ async function getDelegationContractAddress(args: {
9696
);
9797
}
9898

99+
100+
/**
101+
* Creates an EIP-7702 account that enables EOA (Externally Owned Account) delegation
102+
* to smart contract functionality. This allows an EOA to delegate its code execution
103+
* to a minimal account contract, enabling features like batch transactions and sponsored gas.
104+
*
105+
* The minimal account leverages EIP-7702 authorization to delegate the EOA's code to a
106+
* MinimalAccount contract, allowing the EOA to execute smart contract functions while
107+
* maintaining its original address and private key control.
108+
*
109+
* @param args - Configuration object for creating the minimal account
110+
* @param args.client - The thirdweb client instance for blockchain interactions
111+
* @param args.adminAccount - The EOA account that will be delegated to the minimal account contract
112+
* @param args.sponsorGas - Optional flag to enable sponsored gas transactions via bundler
113+
*
114+
* @returns An Account object with enhanced capabilities including batch transactions and EIP-5792 support
115+
*
116+
* @example
117+
* ```typescript
118+
* import { createThirdwebClient, sendBatchTransaction } from "thirdweb";
119+
* import { privateKeyToAccount } from "thirdweb/wallets";
120+
* import { create7702MinimalAccount } from "thirdweb/wallets/in-app";
121+
* import { sepolia } from "thirdweb/chains";
122+
*
123+
* // Create a client
124+
* const client = createThirdwebClient({
125+
* clientId: "your-client-id"
126+
* });
127+
*
128+
* // Create an EOA account
129+
* const adminAccount = privateKeyToAccount({
130+
* client,
131+
* privateKey: "0x..."
132+
* });
133+
*
134+
* // Wrap it with a EIP-7702 account
135+
* const minimal7702Account = create7702MinimalAccount({
136+
* client,
137+
* adminAccount,
138+
* sponsorGas: true // Enable sponsored transactions
139+
* });
140+
*
141+
* // Send a batch of transactions
142+
* const result = await sendBatchTransaction({
143+
* account: minimal7702Account,
144+
* transactions: [
145+
* {
146+
* to: "0x...",
147+
* data: "0x...",
148+
* value: 0n,
149+
* chainId: sepolia.id
150+
* },
151+
* {
152+
* to: "0x...",
153+
* data: "0x...",
154+
* value: 0n,
155+
* chainId: sepolia.id
156+
* }
157+
* ]});
158+
*
159+
* console.log("Batch transaction hash:", result.transactionHash);
160+
* ```
161+
*
162+
* @wallet
163+
*/
99164
export const create7702MinimalAccount = (args: {
100165
client: ThirdwebClient;
101166
adminAccount: Account;

0 commit comments

Comments
 (0)