2

While proposing a transaction to the safe service, I am getting below error:

Error: Unprocessable Entity
    at sendRequest (C:\Home\Mesha\mesha-be\node_modules\@gnosis.pm\safe-service-client\src\utils\httpRequests.ts:52:9)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

I am creating and proposing the transaction in the backend with below code:

import SafeServiceClient from "@gnosis.pm/safe-service-client";
const safeService = new SafeServiceClient('https://safe-transaction.rinkeby.gnosis.io');
import Safe, { EthersAdapter } from "@gnosis.pm/safe-core-sdk";
import { ethers } from "ethers";
const HDWalletProvider = require("@truffle/hdwallet-provider");

// Creating web3 provider
const walletProvider = new HDWalletProvider({
  privateKeys: [privateKey], 
  providerOrUrl: ALCHEMY_KEY,
});

const provider = new ethers.providers.Web3Provider(walletProvider);

// Initializing safe-core sdk
const signer: any = provider.getSigner(0);

const ethAdapter = new EthersAdapter({
  ethers,
  signer,
});

const safeSdk: Safe = await Safe.create({ ethAdapter, safeAddress }); // safeAddress: '0x0A3dAaa3AEbd9A832b87FC94F1aBc15a9e4ed6F5', Rinkeby

const transaction = {
  to: '0xb0968a944aF335f0f73900821a52d0066593aC5a',
  data: '0x',
  value: '1000000000000000',
}
transaction.nonce = await safeService.getNextNonce(safeAddress);
const safeTransaction = await safeSdk.createTransaction(transaction);
await safeSdk.signTransaction(safeTransaction);
const safeTxHash = await safeSdk.getTransactionHash(safeTransaction);
await safeService.proposeTransaction({
  safeAddress,
  safeTransaction,
  safeTxHash,
  senderAddress,
}); // Here I am getting the error

All the input seems fine to me as I console them before calling the proposeTransaction :

safeAddress: '0x0A3dAaa3AEbd9A832b87FC94F1aBc15a9e4ed6F5'
safeTransaction: EthSafeTransaction {
  signatures: Map {
    '0xb0968a944af335f0f73900821a52d0066593ac5a' => EthSignSignature {
      signer: '0xb0968a944aF335f0f73900821a52d0066593aC5a',
      data: '0xc6eb0fed77c6c6bf3891aa06f6620b0cc53a4646633dfd3148d16868fa45c58d53cdb1359ceabdaddab2cf37e8ca1997ab19669776b75
    }
  },
  data: {
    to: '0xb0968a944af335f0f73900821a52d0066593ac5a',
    value: '1000000000000000',
    data: '0x',
    operation: 0,
    baseGas: 0,
    gasPrice: 0,
    gasToken: '0x0000000000000000000000000000000000000000',
    refundReceiver: '0x0000000000000000000000000000000000000000',
    nonce: 0,
    safeTxGas: 0
  }
}
safeTxHash: '0x0954a44ef78e4a0cdeabbafb196dd2ab7ee531739c3ecd58636804571fd868ab'
senderAddress: '0xb0968a944aF335f0f73900821a52d0066593aC5a'

Error is less helpful as it is not giving much information. I was not facing such errors while using the safe SDKs in the frontend.

Version:

@gnosis.pm/safe-core-sdk: v1.3.0
@gnosis.pm/safe-service-client: v1.1.1
node: v12.17.0
@truffle/hdwallet-provider: v2.0.0
ethers: v5.5.3

1 Answer 1

4

Ok the issue is resolved. The reason was that the to field in the transaction is not checksumed:

const transaction = {
  to: '0xb0968a944aF335f0f73900821a52d0066593aC5a',
  data: '0x',
  value: '1000000000000000',
}

I checksumed the address and it worked:

transaction.to = ethers.utils.getAddress(transaction.to)

I think the SDK should handle this as I was not getting this issue while using the SDKs in the frontend and even nothing is mentioned about this in the guide

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.