1

I am trying to follow the example from here, mostly to add transaction / sign off-chain: https://github.com/gnosis/safe-core-sdk/blob/main/packages/guides/integrating-the-safe-core-sdk.md

but i got the error: TypeError: Safe.create is not a function

import EthersAdapter from "@gnosis.pm/safe-ethers-lib";
import Safe, { SafeFactory } from "@gnosis.pm/safe-core-sdk";
import { ethers } from "ethers";
import abi from "./abi/abi.js";

const bulkMint = async () => {
    const infuraProvider = new ethers.providers.InfuraProvider("rinkeby", {
        projectId: "..",
        projectSecret: "...",
    });

    const privateKey = "...";
    const wallet = new ethers.Wallet(
        `...`,
        infuraProvider
    );
    const signer = await wallet.connect(infuraProvider);
    const safeAddress = "...";
    const contractAddress = "...";
    let ethAdapterOwner1 = new EthersAdapter({ ethers, signer });

    // error here
    const safeSdk = await Safe.create({
        ethAdapter: ethAdapterOwner1,
        safeAddress: GNOSIS_SAFE_ADDR,
    });
    // rest of irrelevant code
 
};

I am using these: @gnosis.pm/safe-core-sdk: "^2.0.0", @gnosis.pm/safe-ethers-lib: "^1.0.0", @node 16.13

May I know if I am missing anything.

Here is the log for Safe object (console.log(Safe))

{
  ContractManager: [class ContractManager],
  SafeFactory: [class SafeFactory],
  EthSignSignature: [class EthSignSignature],
  standardizeSafeTransactionData: [Getter],
  default: [class Safe]
}
3
  • Hmm that should work. The method is defined here github.com/gnosis/safe-core-sdk/blob/main/packages/…. Can you log the Safe object? (e.g. console.log(Safe))
    – Richard
    Mar 5, 2022 at 10:59
  • hi @Richard, This is the log for safe object: { ContractManager: [class ContractManager], SafeFactory: [class SafeFactory], EthSignSignature: [class EthSignSignature], standardizeSafeTransactionData: [Getter], default: [class Safe] } Mar 5, 2022 at 19:24
  • you need to destructure the default property
    – mikheevm
    Mar 6, 2022 at 18:29

1 Answer 1

0

I had the same issue with the latest safe versions:

"@safe-global/protocol-kit": "^0.1.1", "@safe-global/safe-core-sdk-types": "^1.10.1",

I realized that the Safe object contains a default property which points to the Safe class. I used the ugly trick:

await Safe.default.create(...) which works in js. In ts a bit of type tweaking would be needed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.