1

According to this guide.

Now we can use code below to sign a safe transaction.

    const txHash = await sdk.getTransactionHash(safeTransaction);
    const signature = await sdk.signTransactionHash(txHash);
    safeTransaction.addSignature(signature);

Seems it signs a hash string with metamask, and metamask will give warning below

Signing this message can be dangerous. This signature could potentially perform any operation on your account's behalf, including granting complete control of your account and all of its assets to the requesting site. Only sign this message if you know what you're doing or completely trust the requesting site

From gnosis safe app behavior, signing with eip-712 seems more reasonable.

Is there any workaround to sign with eip-712 using safe-core-sdk?

2 Answers 2

2

This is in the backlog for the safe-core-sdk. If you need this feature right now you would have to add a helper for this yourself.

Basically you would need to call eth_signTypedData with the appropriate data. An example for this using Ethers can be found here: https://github.com/gnosis/safe-contracts/blob/main/src/utils/execution.ts#L87-L95.

The generate signature can be used with then to create a SafeSignature instance using the EthSignSignature class as a workaround.

0

This is already implemented into safe-core-sdk development branch at the time of this comment.

https://github.com/safe-global/safe-core-sdk/issues/108

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.