Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,70 @@ async function getDelegationContractAddress(args: {
);
}

/**
* Creates an EIP-7702 account that enables EOA (Externally Owned Account) delegation
* to smart contract functionality. This allows an EOA to delegate its code execution
* to a minimal account contract, enabling features like batch transactions and sponsored gas.
*
* The minimal account leverages EIP-7702 authorization to delegate the EOA's code to a
* MinimalAccount contract, allowing the EOA to execute smart contract functions while
* maintaining its original address and private key control.
*
* @param args - Configuration object for creating the minimal account
* @param args.client - The thirdweb client instance for blockchain interactions
* @param args.adminAccount - The EOA account that will be delegated to the minimal account contract
* @param args.sponsorGas - Optional flag to enable sponsored gas transactions via bundler
*
* @returns An Account object with enhanced capabilities including batch transactions and EIP-5792 support
*
* @example
* ```typescript
* import { createThirdwebClient, sendBatchTransaction } from "thirdweb";
* import { privateKeyToAccount } from "thirdweb/wallets";
* import { create7702MinimalAccount } from "thirdweb/wallets/in-app";
* import { sepolia } from "thirdweb/chains";
*
* // Create a client
* const client = createThirdwebClient({
* clientId: "your-client-id"
* });
*
* // Create an EOA account
* const adminAccount = privateKeyToAccount({
* client,
* privateKey: "0x..."
* });
*
* // Wrap it with a EIP-7702 account
* const minimal7702Account = create7702MinimalAccount({
* client,
* adminAccount,
* sponsorGas: true // Enable sponsored transactions
* });
*
* // Send a batch of transactions
* const result = await sendBatchTransaction({
* account: minimal7702Account,
* transactions: [
* {
* to: "0x...",
* data: "0x...",
* value: 0n,
* chainId: sepolia.id
* },
* {
* to: "0x...",
* data: "0x...",
* value: 0n,
* chainId: sepolia.id
* }
* ]});
*
* console.log("Batch transaction hash:", result.transactionHash);
* ```
*
* @wallet
*/
Comment on lines +159 to +162
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add required stability tag and a short remark per package docs policy.

Public symbols need a custom stability tag; also note the bundler requirement for sponsored gas.

  * @wallet
+ * @beta
+ * @remarks Sponsored gas (`sponsorGas: true`) requires a bundler/paymaster setup that supports the `tw_getDelegationContract` RPC on the target chain.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* ```
*
* @wallet
*/
*
🤖 Prompt for AI Agents
In packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.ts around
lines 160-163, the public symbol is missing the required stability JSDoc tag and
a short remark per package docs policy; add a stability tag (e.g., @stability
experimental or @stability stable as appropriate for the package) directly in
the comment block for this exported wallet symbol and append a one-line remark
noting that sponsored-gas functionality requires using a bundler (i.e.,
"Requires a bundler to use sponsored gas") so documentation and tooling can pick
up both the stability level and the bundler requirement.

export const create7702MinimalAccount = (args: {
client: ThirdwebClient;
adminAccount: Account;
Expand Down
Loading