0

I have a gnosis-safe and an ERC-20 contract with permit(owner, spender, value, deadline, v, r, s) method that requires v,r,s of the owner as the argument.

I have calculated the required v,r,s value for an EOA as owner using its private keys directly and it worked without any problem.

Now I am not able to figure out how to achieve the same for a gnosis-safe as the owner.

There is one method named signTypedData in gnosis-safe-sdk but it takes SafeTransaction type as input which is not at all similar to the kind of typed-data I am aware of.

typed-Data that I used while signing via EOA looks something like this,

{
  "types": {
    "EIP712Domain": [
      {
        "name": "name",
        "type": "string"
      },
      {
        "name": "version",
        "type": "string"
      },
      {
        "name": "chainId",
        "type": "uint256"
      },
      {
        "name": "verifyingContract",
        "type": "address"
      }
    ],
    "Permit": [
      {
        "name": "owner",
        "type": "address"
      },
      {
        "name": "spender",
        "type": "address"
      },
      {
        "name": "value",
        "type": "uint256"
      },
      {
        "name": "nonce",
        "type": "uint256"
      },
      {
        "name": "deadline",
        "type": "uint256"
      }
    ]
  },
  "primaryType": "Permit",
  "domain": {
    "name": "JEBA",
    "version": "1",
    "chainId": "0x61",
    "verifyingContract": "0xf2A622494b8328d2Ed0E6FB1AeEA9B750624a488"
  },
  "message": {
    "owner": "0xC20C81665AF4104Bb6405F9Bdb19a6FF645C6B0a",
    "spender": "0x24Cd34c77DFcb50b5C473b9eEEAa5c57Af730D64",
    "value": "10000000",
    "nonce": "0x0000000000000000000000000000000000000000000000000000000000000002",
    "deadline": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
  }
}

From an EOA account, this typed-data can be signed using both ecsign method of ethereumjs-util and ethers.SigningKey.signDigest, which gives me v,r and s value which is then can be used to call permit method.

whereas, the SafeTransaction type is something like this,

export declare enum OperationType {
    Call = 0,
    DelegateCall = 1
}
export interface MetaTransactionData {
    readonly to: string;
    readonly value: string;
    readonly data: string;
    readonly operation?: OperationType;
}
export interface SafeTransactionData extends MetaTransactionData {
    readonly operation: OperationType;
    readonly safeTxGas: number;
    readonly baseGas: number;
    readonly gasPrice: number;
    readonly gasToken: string;
    readonly refundReceiver: string;
    readonly nonce: number;
}
export interface SafeTransaction {
    readonly data: SafeTransactionData;
    readonly signatures: Map<string, SafeSignature>;
    addSignature(signature: SafeSignature): void;
    encodedSignatures(): string;
}

I am not able to figure out how to use typed-data json in the SafeTransaction object, so that I can call safeSdk.signTypedData(safeTransaction) with the safe account to get the v,r,s values.

Manu Rastogi
  • 188
  • 1
  • 7
  • also posted here https://ethereum.stackexchange.com/questions/138743/erc-20-permit-call-with-eip-712-signing-from-a-gnosis-safe-using-gnosis-safe-sdk – Manu Rastogi Nov 04 '22 at 11:52

0 Answers0