-
Notifications
You must be signed in to change notification settings - Fork 619
[SDK] Add documentation for create7702MinimalAccount function #7996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| export const create7702MinimalAccount = (args: { | ||||||||||||
| client: ThirdwebClient; | ||||||||||||
| adminAccount: Account; | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.