0

I want to send some transaction, for example, simple transfer 0.1 ETH from my Safe MultiSig 2/3 wallet to other EOA. I need to do this without SDK, with ethers.js or web3, I checked Safe contract code and tried to sign with ethers.js, but it results with execution reverted: "GS026", that means that signatures are invalid. My code:

const safeTxHash = await safeContract.getTransactionHash(
    someAddress,
    ethers.parseEther("0.1"),
    "0x",
    0,
    0,
    0,
    0,
    ethers.ZeroAddress,
    ethers.ZeroAddress,
    nonce
);
const firstWalletSignature = firstWallet.signMessageSync(ethers.toBeArray(safeTxHash));
const secondWalletSignature = secondWallet.signMessageSync(ethers.toBeArray(safeTxHash));

await safeContract.execTransaction(
    someAddr,
    ethers.parseEther("0.1"),
    "0x",
    0,
    0,
    0,
    0,
    ethers.ZeroAddress,
    ethers.ZeroAddress,
    secondWalletSignature + firstWalletSignature.slice(2)
);

When I create signatures from two owners in Safe UI and insert them raw instead secondWalletSignature and firstWalletSignature in execTransaction call, it works well.

Accordingly, I'm generating signatures incorrectly, but what is my mistake?

1 Answer 1

0

If you do not want to use neither of Safe{Core} SDK's Protocol kit or API Kit, you can make HTTP requests to Safe Transaction Service.

You could also look at the current implementation by Safe of transaction signatures for the SDK as an example of how we do it. Note that this implementation is quite complex and that we strongly advise to follow our standard guidelines (i.e. use the SDK) when dealing with these issues, as it could pose a security risk if wrongly implemented.

Hope it helps; Best, Louis

1
  • For standard iteractions I always will prefer official UI, but currently I'm looking for the way to interact with wallet if UI is down or exploited. By the way, I found that in such case I can simply use onchain hash approval, thanks for an answer! Commented May 3 at 15:21

Your Answer

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

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