Truffle: "Migrations" -- transaction could not be decoded: could not recover secp256k1 key: calculated Rx is larger than curve P

I have happened a problem when I migrate a singale contract,the log is below:

> truffle migrate --network rinkeby --reset


Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



Starting migrations...
======================
> Network name:    'rinkeby'
> Network id:      4
> Block gas limit: 10000000 (0x989680)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------

Error:  *** Deployment Failed ***

"Migrations" -- transaction could not be decoded: could not recover secp256k1 key: calculated Rx is larger than curve P.

    at D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\deployer\src\deployment.js:365:1
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Migration._deploy (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:74:1)
    at Migration._load (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:61:1)
    at Migration.run (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:212:1)
    at Object.runMigrations (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)
    at Object.runFrom (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
    at Object.runAll (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\migrate\index.js:114:1)
    at Object.run (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\migrate\index.js:79:1)
    at runMigrations (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:263:1)
    at Object.run (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:228:1)
    at Command.run (D:\projects\hero-contract\node_modules\truffle\build\webpack:\packages\core\lib\command.js:136:1)
Truffle v5.2.5 (core: 5.2.5)
Node v12.16.1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hero-contract@1.0.0 migrate: `truffle migrate --network rinkeby --reset`
npm ERR! Exit status 1
npm ERR!

And the trufffle-config.js is below:

const { projectId, mnemonic,ropsten_projectId} = require('./secrets.json');
const HDWalletProvider = require('@truffle/hdwallet-provider');

module.exports = {

  networks: {
    development: {
      host: '127.0.0.1',     // Localhost (default: none)
      port: 7545,            // Standard Ethereum port (default: none)
      network_id: '*',       // Any network (default: none)
    },
    // Useful for deploying to a public network.
    // NB: It's important to wrap the provider as a function.
    rinkeby: {
      provider: () => new HDWalletProvider(mnemonic, `https://rinkeby.infura.io/v3/${projectId}`),
      network_id: 4,       // Rinkeby's id
      gas: 5500000,        // Rinkeby has a lower block limit than mainnet
      confirmations: 2,    // # of confs to wait between deployments. (default: 0)
      timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
      skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
    },
    ropsten: {
      provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/${ropsten_projectId}`),
      network_id: 3,       // Rinkeby's id
      gas: 5500000,        // Rinkeby has a lower block limit than mainnet
      confirmations: 2,    // # of confs to wait between deployments. (default: 0)
      timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
      skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
    },
  },

  compilers: {
    solc: {
      version: '0.7.0',    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      // settings: {          // See the solidity docs for advice about optimization and evmVersion
      //  optimizer: {
      //    enabled: true,
      //    runs: 200,
      //  }
      // evmVersion: "byzantium"
    }
  },
};

Please help me , thank you very much

3 Likes

+1 also stuck on this same problem

2 Likes

I am not sure, but did you use 32 bytes of private key (do not paste key at here)?

1 Like

Yes ,and mnemonic words is also has this issue

1 Like

Have you solved it :slightly_smiling_face:

1 Like

truffle version:
$ truffle version

Truffle v5.2.4 (core: 5.2.4)

Solidity - 0.6.12 (solc-js)

Node v15.12.0

Web3.js v1.2.9

truffle-config snippets:

const HDWalletProvider = require('@truffle/hdwallet-provider');
const { infuraProjectId, mnemonic } = require('./secrets.json');
...

// rinkeby
rinkeby: {
  provider: () => new HDWalletProvider(
    mnemonic, `https://rinkeby.infura.io/v3/${infuraProjectId}`
  ),
  network_id: 4,
  // gasPrice: 10e9,
  gas: 5500000,  
  skipDryRun: false
}, 

I can get eth balance of the wallet account just fine, so I expect signing etc to work?

$ npx truffle console --network rinkeby
truffle(rinkeby)> accounts
[
  '0x6B5732937e1c3B041B95D523C1817E45746d39C0',
  '0x5cCA4FB5Aed40Faa61Fe9d322416546b78377Cb0',
  '0x27a522d246ea23ccBE481e6547e9d33cA6507E44',
  '0xB93392C38387943047715052067E544f5a8D8b65',
  '0xce4805Dc3baFa79B2Bdb099107945326Cfada4c8',
  '0x075284ef930296197C490a658E07EEDDd0BB3d72',
  '0x1Ca4B743A5EA01Dbfc25621002ABBA9672ecA2a5',
  '0xf37ecA5762a4Db7B58A8ac06a4c68016D017DDC8',
  '0x6467D677FC300E9512269221d98eA17568887F27',
  '0x745A0BC31B12F34214bBB89666D242Aa9a343801'
]
truffle(rinkeby)> await web3.eth.getBalance(accounts[0])
'2995716000000000000'
truffle(rinkeby)> .exit

running migrate ends with the mentioned error:

$ npx truffle migrate --network rinkeby

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



Migrations dry-run (simulation)
===============================
> Network name:    'rinkeby-fork'
> Network id:      4
> Block gas limit: 10000000 (0x989680)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------
   > block number:        8275701
   > block timestamp:     1616368781
   > account:             0x6B5732937e1c3B041B95D523C1817E45746d39C0
   > balance:             2.995372098
   > gas used:            171951 (0x29faf)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.000343902 ETH

   -------------------------------------
   > Total cost:         0.000343902 ETH


2_deploy.js
===========

   Deploying 'Box'
   ---------------
   > block number:        8275703
   > block timestamp:     1616368797
   > account:             0x6B5732937e1c3B041B95D523C1817E45746d39C0
   > balance:             2.994522228
   > gas used:            397600 (0x61120)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.0007952 ETH

   -------------------------------------
   > Total cost:           0.0007952 ETH


Summary
=======
> Total deployments:   2
> Final cost:          0.001139102 ETH





Starting migrations...
======================
> Network name:    'rinkeby'
> Network id:      4
> Block gas limit: 10000000 (0x989680)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------


Error:  *** Deployment Failed ***

"Migrations" -- transaction could not be decoded: could not recover secp256k1 key: calculated Rx is larger than curve P.

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:74:1)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:61:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:212:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:87:1)
    at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:263:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:226:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:136:1)
Truffle v5.2.4 (core: 5.2.4)
Node v15.12.0
4 Likes

Hi @bencong_he,

Welcome to the community :wave:

I get the same issue deploying the Box contract to Rinkeby using Truffle and Alchemy.

$ npx truffle migrate --network rinkeby --reset

Compiling your contracts...
===========================
> Compiling ./contracts/Box.sol
> Compiling ./contracts/Migrations.sol
> Artifacts written to /home/abcoathup/projects/forum/bencong_he/build/contracts
> Compiled successfully using:
   - solc: 0.7.0+commit.9e61f92b.Emscripten.clang



Starting migrations...
======================
> Network name:    'rinkeby'
> Network id:      4
> Block gas limit: 10000000 (0x989680)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------

Error:  *** Deployment Failed ***

"Migrations" -- transaction could not be decoded: could not recover secp256k1 key: calculated Rx is larger than curve P.

    at /home/abcoathup/projects/forum/bencong_he/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.2.5 (core: 5.2.5)
Node v10.23.2

Truffle version:

$ npx truffle version
Truffle v5.2.5 (core: 5.2.5)
Solidity - 0.7.0 (solc-js)
Node v10.23.2
Web3.js v1.2.9

I could deploy using Hardhat so it looks like it may be an issue with Truffle / Truffle HD Wallet Provider

$ npx hardhat run --network rinkeby scripts/deploy.js
Deploying Box...
Box deployed to: 0x58690Ce8f7144Dc66EaEdA65D54944966C0ac795

I downgraded Truffle HD Wallet Provider versions and was able to deploy

    "@truffle/hdwallet-provider": "^1.2.3"

I created an Issue on Truffle:

5 Likes

Thank you very much,but I downgraded Truffle HD Wallet Provider to 1.2.3,it also had this issue,I don’t know why.

1 Like

I’ve been having the same problem the last two days and have been following this thread. I was able to get it working by downgrading to version 1.2.1 as opposed to 1.2.3

2 Likes

Thanks for making the truffle issue @abcoathup, it appears we just have to wait for truffle to fix, or use hardhat.

2 Likes

Hi @PatrickAlphaC,

Or use an earlier version of @truffle/hdwallet-provider until this is resolved.

2 Likes

I wasted too many hours between last night and this morning trying to debug this issue.

You all are life savers…

2 Likes

Hi @Stevers,

Welcome to the community :wave:

Glad this thread helped.

Many thanks! You saved my day :slight_smile:

1 Like