Truffle 使用记录

学习使用truffle 共同进步

一. 配置链信息

在truffle-config中

      provider: function() {
          return new HDWalletProvider("钱包私钥", "RPCURL") },
      network_id: 97,
      chain_id:97,
      gasPrice: 10000000000000, 
      gas:50000000,
      websockets: true,
      timeoutBlock:1000,
     },

详细配置说明

二.遇到问题

执行以下命令 truffle compile truffle migrate --network bsctest

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

Starting migrations...
======================
> Network name:    'bsctest'
> Network id:      97
> Block gas limit: 50000000 (0x2faf080)

1_deploy_contracts.js
=====================

   Deploying 'MetaCoin'
   --------------------
 *** Deployment Failed ***

"MetaCoin" -- transaction overpriced.

Exiting: Review successful transactions manually by checking the transaction hashes above on Etherscan.

Error:  *** Deployment Failed ***

"MetaCoin" -- transaction overpriced.

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:331:1
    at processTicksAndRejections (node:internal/process/task_queues:95: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:54:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:202:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:142:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:107:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:91:1)
    at module.exports (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/runMigrations.js:10:1)
    at Object.module.exports [as run] (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:41:1)
    at runCommand (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command-utils.js:184:1)
Truffle v5.5.23 (core: 5.5.23)
Node v18.15.0

解决方案:更换了节点 就好了 问题二

======================
> Network name:    'bsctest'
> Network id:      97
> Block gas limit: 50000000 (0x2faf080)

1_deploy_contracts.js
=====================

   Deploying 'MetaCoin'
   --------------------
 *** Deployment Failed ***

"MetaCoin" -- tx fee (250000.00 ether) exceeds the configured cap (1.00 ether).

Exiting: Review successful transactions manually by checking the transaction hashes above on Etherscan.

Error:  *** Deployment Failed ***

"MetaCoin" -- tx fee (250000.00 ether) exceeds the configured cap (1.00 ether).

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:331:1
    at processTicksAndRejections (node:internal/process/task_queues:95: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:54:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:202:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:142:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:107:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:91:1)
    at module.exports (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/runMigrations.js:10:1)
    at Object.module.exports [as run] (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:41:1)
    at runCommand (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command-utils.js:184:1)
Truffle v5.5.23 (core: 5.5.23)
Node v18.15.0

解决方案: 方案一: truffle migrate --network bsctest --rpc.txfeecap 0 --rpc.gascap 0 (失败)参考资料

方案二:更改配置

      provider: function() {
          return new HDWalletProvider("XXXXX",
          "https://data-seed-prebsc-2-s2.bnbchain.org:8545") },
      network_id: 97,
      chain_id: 97,
      gasPrice: 20e10, 
      gas: 25e6,
      websockets: false,
      timeoutBlock: 1000,
     },

中的gas 直接去掉

点赞 0
收藏 0
分享

0 条评论

请先 登录 后评论
一只菜鸟
一只菜鸟
0x0ec5...b8a5
江湖只有他的大名,没有他的介绍。