【已解决】Truffle迁移合约过程中1_initial_migration.js迁移不了的问题

遇到问题,truffle-config.js文件如下。

module.exports = {
    
    
  networks: {
    
    
    development: {
    
    
      host: "localhost",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*"       // Any network (default: none)
     }
   }
};

但是为啥就是不行啊啊啊好崩溃!!!不知道有没有人也遇到了同样的问题,求解答!!!

$ truffle migrate

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

Starting migrations...
======================
> Network name:    'development'
> Network id:      1607256432808
> Block gas limit: 6721975 (0x6691b7)


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

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

Error:  *** Deployment Failed ***

"Migrations" -- 
Could not connect to your Ethereum client with the following parameters:
    - host       > localhost
    - port       > 8545
    - network_id > 1607256432808
Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle-config.js)
.

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:68:1)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:55:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:171: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:269:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:231:1
Truffle v5.1.55 (core: 5.1.55)
Node v14.15.1

解决办法:
其实从显示的问题来看,应该是我的testrpc客户端出了问题,使得一直在1_initial_migration.js这里就过不去。具体的做法,我就是用Ganache-cli作为客户端,就没有出现问题了。。。(老泪纵横。。网上也没有相应的解决办法,只好根据自己对结果猜测哪里出问题瞎尝试,虽然也不是从根本上解决,不过可以进行下一步了哈哈!)

ganache客户端显示:

$ ganache-cli
Ganache CLI v6.12.1 (ganache-core: 2.13.1)

Available Accounts
==================
(0) 0xc97d8B1E0F53e02Beb4B9E2894695CCFA8aAf6d3 (100 ETH)
(1) 0xf5dB344BEF774a68A8796C4B8095DAe053b83DA5 (100 ETH)
(2) 0x37aA82Eb4CfCbde2f4cd71754eBB024dE7C36417 (100 ETH)
(3) 0xb1161B4dF07f13B7bf50766Da227D8230Febd313 (100 ETH)
(4) 0x8EE8A5dd35175e8174C1e367F77b30e90d532bd5 (100 ETH)
(5) 0xDC85BDdAFb651614666bCb0682C2E42a1829f6C0 (100 ETH)
(6) 0xea2bAD916D2f7FE27De0FD188fd763689771D418 (100 ETH)
(7) 0xa3035316602be2220c2F54E3b56c1764771d3A52 (100 ETH)
(8) 0x7c17CD98E0bb03Dfc0702B9125DC02C3269b7e98 (100 ETH)
(9) 0x53681c00eF85D582e7357fc563e32B5FD0E36682 (100 ETH)

Private Keys
==================
(0) 0xd12f26f76d920923635f8208caf637165bdcd4dded1fb4c7c3935fde5faf9241
(1) 0x50ada28f52ec0c817be82c02e70931ed777ba6261c23f6c7ecb99bcc5695f83d
(2) 0xfd9c148759494288dbe2c74afce0a8808302fa66401275af47ca7ff9be67a8ab
(3) 0xccd4518ab231f13cbe97c03b01eba1abef440425e05e022114c3743a90a29a83
(4) 0x41167955c24a78a37089909b89661c38ae69dc89fd52bd7ab740dcb0f9a6da00
(5) 0x2bfa0ff56f7114feaeed8e2d4a2994f3a893a66cd00b916cf9a658d8e7ec63c0
(6) 0x0031c0bb9837f639bf992451b1b31db5cd4d89bc2d5529a3e6cd41f9579eed00
(7) 0x38b2e3dc76ef3cd3a9e70f3900e133f0edb81c53494a62206cf4b16a7a9efd53
(8) 0x419e756e2717f19e3d122f363b3007c7415c01e226934b0ec8182d2bc8d04e96
(9) 0x9e483a2ff1b54278bde35aca3d8d82d97147f549c0c8cad9bebf83964dad107e

HD Wallet
==================
Mnemonic:      share chat ostrich neutral seed fish thought filter novel print replace elephant
Base HD Path:  m/44'/60'/0'/0/{
    
    account_index}

Gas Price
==================
20000000000

Gas Limit
==================
6721975

Call Gas Limit
==================
9007199254740991

Listening on 127.0.0.1:8545
eth_blockNumber
net_version
eth_accounts
eth_getBlockByNumber
eth_accounts
net_version
eth_getBlockByNumber
eth_getBlockByNumber
net_version
eth_getBlockByNumber
eth_estimateGas
net_version
eth_blockNumber
eth_getBlockByNumber
eth_sendTransaction
eth_blockNumber

  Transaction: 0x3c46270177d1872b55583d6783c811a1b13c2703cb2628b3e041e1ae53d49c9a
  Contract created: 0x271e00fe33f264303561eea15af7c9ae1bca1e82
  Gas usage: 186963
  Block Number: 1
  Block Time: Sun Dec 20 2020 20:43:45 GMT+0800 (China Standard Time)

eth_getTransactionReceipt
eth_blockNumber
eth_blockNumber
eth_getCode
eth_blockNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_blockNumber
eth_getTransactionByHash
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
...

命令执行成功:

$ truffle migrate

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



Starting migrations...
======================
> Network name:    'development'
> Network id:      1608468140781
> Block gas limit: 6721975 (0x6691b7)


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

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0x3c46270177d1872b55583d6783c811a1b13c2703cb2628b3e041e1ae53d49c9a
   > Blocks: 1            Seconds: 66
   > contract address:    0x271E00fe33F264303561eEa15AF7c9Ae1Bca1e82
   > block number:        1
   > block timestamp:     1608468225
   > account:             0xc97d8B1E0F53e02Beb4B9E2894695CCFA8aAf6d3
   > balance:             99.99626074
   > gas used:            186963 (0x2da53)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00373926 ETH


   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.00373926 ETH


2_storage_migration.js
======================

   Deploying 'Storage'
   -------------------
   > transaction hash:    0xc97ad598bfa91c15dc0af5ca61916512853ddf51d5fcd6b4794969898dfc1fdc
   > Blocks: 1            Seconds: 10
   > contract address:    0xCE986bde8Ff4EBF259DedA70881AF3BcA6B8f83a
   > block number:        3
   > block timestamp:     1608468317
   > account:             0xc97d8B1E0F53e02Beb4B9E2894695CCFA8aAf6d3
   > balance:             99.99329622
   > gas used:            105891 (0x19da3)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00211782 ETH


   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.00211782 ETH


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

猜你喜欢

转载自blog.csdn.net/weixin_44029550/article/details/110756265