Skip to content

Commit 61fddef

Browse files
[SDK] Add documentation for create7702MinimalAccount function (#7996)
1 parent 14fe9ee commit 61fddef

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

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

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

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

0 commit comments

Comments
 (0)