Skip to content
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

Safe4337Pack is supported to Polygon Amoy Chain #1105

Open
nufailTanjiro opened this issue Jan 20, 2025 · 1 comment
Open

Safe4337Pack is supported to Polygon Amoy Chain #1105

nufailTanjiro opened this issue Jan 20, 2025 · 1 comment

Comments

@nufailTanjiro
Copy link

Description

I am getting module not available for chain 80002 when executing a safe userop transaction using @safe-global/relay-kit

Environment

  • Safe Core SDK versions:

    • relay-kit: "^3.3.1"
  • Environment:

    • non-browser

Steps to reproduce

import { Safe4337Pack } from "@safe-global/relay-kit";
import { concat, toHex } from "viem";

const SIGNER_ADDRESS = "SIGNER_ADDRESS "; // ...
const SIGNER_PRIVATE_KEY =
  "SIGNER_PRIVATE_KEY "; // ...


const PIMLICO_API_KEY = "PIMLICO_API_KEY ";
const RPC_URL = `https://api.pimlico.io/v2/80002/rpc?apikey=` + PIMLICO_API_KEY;

const safe_userop = async () => {
  const safe4337Pack = await Safe4337Pack.init({
    provider: RPC_URL,
    signer: SIGNER_PRIVATE_KEY,
    bundlerUrl: `https://api.pimlico.io/v2/80002/rpc?apikey=${PIMLICO_API_KEY}`,
    options: {
      owners: [SIGNER_ADDRESS],
      threshold: 1,
    },
    // ...
    paymasterOptions: {
      isSponsored: true,
      paymasterUrl: `https://api.pimlico.io/v2/80002/rpc?apikey=${PIMLICO_API_KEY}`,
      sponsorshipPolicyId: "sponsorshipPolicyId",
    },
  });

  // Define the transactions to execute
  const transaction1 = {
    to: SIGNER_ADDRESS,
    data: "0x",
    value: BigInt(0).toString(),
  };

  // Build the transaction array
  const transactions = [transaction1];

  // Create the SafeOperation with all the transactions
  const safeOperation = await safe4337Pack.createTransaction({ transactions });

  const onchainIdentifier = toHex(
    "SAMPLE_TX", 
    { size: 16 }
  );

  safeOperation.data.callData = concat([
    safeOperation.data.callData as `0x{string}`,
    onchainIdentifier,
  ]).toString();

  const identifiedSafeOperation = await safe4337Pack.getEstimateFee({
    safeOperation,
  });

  const signedSafeOperation = await safe4337Pack.signSafeOperation(
    identifiedSafeOperation
  );

  const userOperationHash = await safe4337Pack.executeTransaction({
    executable: signedSafeOperation,
  });

  let userOperationReceipt = null;

  while (!userOperationReceipt) {
    // Wait 2 seconds before checking the status again
    await new Promise((resolve) => setTimeout(resolve, 2000));
    userOperationReceipt = await safe4337Pack.getUserOperationReceipt(
      userOperationHash
    );
  }

  const userOperationPayload = await safe4337Pack.getUserOperationByHash(
    userOperationHash
  );

  console.log("User operation payload: ", userOperationPayload);

  console.log("User operation receipt: ", userOperationReceipt);
};

safe_userop().catch(console.error);

When running this on polygon amoy chain I get this error: (This works when executing in sepolia network)

Image

Expected result

Should be able to execute the userop transaction

@dasanra
Copy link
Collaborator

dasanra commented Jan 20, 2025

This module is missing at our directory for modules

Needs to be added before it can be used in safe-core-sdk safe-global/safe-modules-deployments#44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants