0x0x230x

Untitled

Feb 5th, 2025
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. async createSmartAccount(signer: string) {
  2. if (!this.provider) {
  3. throw new Error('Provider not set');
  4. }
  5.  
  6. const safe4337Pack = await Safe4337Pack.init({
  7. provider: this.provider as any,
  8. bundlerUrl,
  9. options: {
  10. owners: [signer],
  11. threshold: 1,
  12. },
  13. paymasterOptions: {
  14. paymasterUrl,
  15. isSponsored: true,
  16. },
  17. });
  18.  
  19. // 2) Create SafeOperation
  20. const rawTx = {
  21. to: zeroAddress,
  22. data: '0x0000000000000000000000000000000000000000000000000000000000000000',
  23. value: '0',
  24. };
  25.  
  26. const safeOperation = await safe4337Pack.createTransaction({
  27. transactions: [rawTx],
  28. });
  29.  
  30. // 3) Sign SafeOperation
  31. const signedSafeOperation = await safe4337Pack.signSafeOperation(
  32. safeOperation,
  33. );
  34.  
  35. // 4) Execute SafeOperation
  36. const userOperationHash = await safe4337Pack.executeTransaction({
  37. executable: signedSafeOperation,
  38. });
  39. }
Advertisement
Add Comment
Please, Sign In to add comment