coinbase / coinbase-sdk-nodejs

Other
64 stars 23 forks source link

Transaction failed with "Error while transferring: InternalError: Request failed with status code 500" #149

Closed shleodai closed 2 months ago

shleodai commented 2 months ago

Problem Description:

I was trying to transfer 0.01 USDC with the following code:

let w = await user.importWallet(seedData);
const anotherWallet = "0x2d1F25efd460Be9D1651A2cB9FC8FB101126cD39";
    try {
        await w.createTransfer({
            amount: 0.01,
            assetId: Coinbase.assets.Usdc,
            destination: anotherWallet,
        });
    } catch (error) {
        console.error(`Error while transferring: `, error);
    }

And there was that error. Here, My wallet is hydrated. Another wallet is generated by user.createWallet().

Note: My wallet is 0x1d61B40534De76FB238aF5a81f310324ceeD1E87, with CDP wallet id ca5ca8f6-3967-47e9-ab36-74db87a7c252. It has 10 USDC in Base Sepholia, so it's not a problem with insufficient balance. I am trying to create outgoing transfer to anotherWallet. Please fix my issue. Thank you!

I would give out all HTTP requests and responses related to this issue: (Authorization secret is omitted)

{
  method: 'POST',
  host: '172.17.192.1',
  port: '7890',
  path: 'https://api.cdp.coinbase.com/platform/v1/wallets/ca5ca8f6-3967-47e9-ab36-74db87a7c252/addresses/0x1d61B40534De76FB238aF5a81f310324ceeD1E87/transfers',
  headers: [Object: null prototype] {
    Accept: 'application/json, text/plain, */*',
    'Content-Type': 'application/json',
    Authorization: 'Bearer [OMITTED]'
    'User-Agent': 'axios/1.7.3',
    'Content-Length': '120',
    'Accept-Encoding': 'gzip, compress, deflate, br',
    host: 'api.cdp.coinbase.com'
  }
}

{
  statusCode: 200,
  headers: {
    connection: 'close',
    'transfer-encoding': 'chunked',
    'cf-cache-status': 'DYNAMIC',
    'cf-ray': '8b2686d2b9fecdf6-SIN',
    'content-type': 'application/json',
    date: 'Tue, 13 Aug 2024 06:07:45 GMT',
    server: 'cloudflare',
    'set-cookie': [
      'cb_dm=06d6b1a8-326c-45bd-8e76-a564fa81e94d; Path=/; Domain=coinbase.com; Expires=Sun, 13 Aug 2034 06:07:45 GMT; HttpOnly; Secure',
      '__cf_bm=gBMgRIHxeFm753SA9DAVaW7JKAZtix7jhgr.rFh9u7U-1723529265-1.0.1.1-2.0YI3felFkQHjbGNtII1l_rC4iZfDfZ7.vWBfXkfpFr3BVuyvXvIT2pKGPhZpJ3g7kcincyViIdROTmgHV2qw; path=/; expires=Tue, 13-Aug-24 06:37:45 GMT; domain=.coinbase.com; HttpOnly; Secure; SameSite=None'
    ],
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'trace-id': '4093630949092751494',
    'x-content-type-options': 'nosniff',
    'x-envoy-upstream-service-time': '84'
  },
  message: 'OK',
  body: '\x1F�\b\x00\x00\x00\x00\x00\x00\x03���n�0\x10�߅g\x15��Cѷڎ_�`(*\x10jK�)�-��{!�)�"\b�^�7���\x03���u�R�q����\x1F�Q��z�}\t<l\x15m:��J\x0F�P�K��C\x1BLc�y����\x18�ˮ�2���mq���.���i�/)��;k\x05Yp���h�f+!j�N�N!m�nw\b�4�+y8�S5\x1B6f,�����\x06xL�|��y:\r��j>`w��Ø�a\x1AW�vrP_���nK�\x0B�|ռ��]{؊\x15Q�=�i�S����>�j��ܘ:���<칌�0>��̗4֔o�\x17�_������G�u���X��s�y��R\x14\x1EU�\x0B1XzU$U��BU5�\x12l)�,.ҽ�\x05�\x02���\x15�,�;\x0F{ӂc��\x14\x00\t*\x1D<�\x16\x0EJ�/3\b.��\b�P��\\�\t(\x00AK\x02t\\L��[��\x12�\x16���pӽ\r���%K��̫�QB{��e\\2q����>�����L(�\x1F���Y\x05\x04K\r� �dHa\x0E��Ԗ̃\r>�I��\b\x0B��\x1B\x00\x00��얱n�0\fD�~F�\n' +
    `\x10u��\x1Cَ�L]:��\x0B�\t��K�\x0E54I�d����_C��HͅD�RIvt\x10��yg�\x15*��D�\x10L��d��B Ɉ�\x06�Z�p�"%MC5\x18��0\x1C��ۡ�'��\x1AN�B+��\x13J���?\x18�nIj֔:#r�̲C?�N�\x07� Tt�t<9��ݕ=�p�N�&�\x1D�Lڤb�}������hͶ̼�3���\x19*\x03��1�IJ��\x0B���%�\x10���ݯ|���ʇ\x7F�\x0F���x���֡��\x05A+��Q�\x02\x16���6lm�n_o�\x00\x00\x00��\x03\x00����\x15\n` +
    '\x00\x00'

}

{
  method: 'POST',
  host: '172.17.192.1',
  port: '7890',
  path: 'https://api.cdp.coinbase.com/platform/v1/wallets/ca5ca8f6-3967-47e9-ab36-74db87a7c252/addresses/0x1d61B40534De76FB238aF5a81f310324ceeD1E87/transfers/0a3fe69a-19bd-4f16-8c18-9d917610d888/broadcast',
  headers: [Object: null prototype] {
    Accept: 'application/json, text/plain, */*',
    'Content-Type': 'application/json',
    Authorization: 'Bearer [SECRET OMMITTED]',
    'User-Agent': 'axios/1.7.3',
    'Content-Length': '381',
    'Accept-Encoding': 'gzip, compress, deflate, br',
    host: 'api.cdp.coinbase.com'
  }
}
{
  statusCode: 500,
  headers: {
    connection: 'close',
    'content-length': '73',
    'cf-cache-status': 'DYNAMIC',
    'cf-ray': '8b2686d62e815ff8-SIN',
    'content-type': 'application/json',
    date: 'Tue, 13 Aug 2024 06:07:45 GMT',
    server: 'cloudflare',
    'set-cookie': [
      'cb_dm=a8f803a7-1f19-4461-a888-7c69d0ccf0aa; Path=/; Domain=coinbase.com; Expires=Sun, 13 Aug 2034 06:07:45 GMT; HttpOnly; Secure',
      '__cf_bm=oUfkG4e2aHzpedwFdrpJi_.ekqE78dTcyAiTHeVBpRM-1723529265-1.0.1.1-BstFCIFdOicEdn1vlrgKT3bEELSSSavUh_f4QLFnYHCvpCuQt0W5lDdkL3CI4obTCn.rUKVtqWlrdpFzsRGMaA; path=/; expires=Tue, 13-Aug-24 06:37:45 GMT; domain=.coinbase.com; HttpOnly; Secure; SameSite=None'
    ],
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'trace-id': '6755056725097625808',
    'x-content-type-options': 'nosniff',
    'x-envoy-upstream-service-time': '60'
  },
  message: 'Internal Server Error',
  body: '{"code":"internal","message":"failed to broadcast transfer transaction"}\n'
}
melissamforbs commented 2 months ago

🤔

alex-stone commented 2 months ago

👋 The address in question https://sepolia.basescan.org/address/0x1d61B40534De76FB238aF5a81f310324ceeD1E87 has 0 ETH to pay for gas.

We'll update the error code to better reflect this.

Also, if you upgrade to our latest SDK release you can specify gasless: true for USDC transfers, and CB will sponsor the gas for your transaction. This particular address would be able to make that same transfer with 0 ETH by adding that parameter!

shleodai commented 2 months ago

Thanks! Problem fixed long ago. Sorry that I didn't update it here.