gnosis-safe – Can Gnosis Safe-Core-SDK Function Fully Offchain with Safe-React-Gateway-SDK

gnosisgnosis-chaingnosis-safe

The SafeSdk & the gateway API is great, but can it support full offchain signing?

From the doc:

User1 signs: safeSdk.signTransaction() is offchain,
User2 signs with: safeSdk.approveTransactionHash()   <-- but this is an onchain call and requires gas.

Can user2~n just call safeSdk.signTransaction() as well and have this recorded on the safe-gateway so that its available in the queue (from getTransactionQueue)??

Thanks

Best Answer

Yes, all the signers can sign a transaction off-chain and send the signature to the Safe Transaction Service, so it appears on the queue in the web UI.

The @gnosis.pm/safe-core-sdk package allows to sign a transaction off-chain like this:

...

const safeTxHash = await safeCoreSdk.getTransactionHash(safeTransaction)
const signature = await safeCoreSdk.signTransactionHash(safeTxHash)

The @gnosis.pm/safe-service-client package allows to send that signature to the Transaction Service:

import SafeServiceClient from '@gnosis.pm/safe-service-client'

...

const safeService = new SafeServiceClient({ txServiceUrl, ethAdapter })
await safeService.confirmTransaction(safeTxHash, signature.data)

You will find a more complete answer following this guide: https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md#confirm-transaction

Related Topic