尝试在测试环境中复制智能合约以进行练习。当我去部署合同时,我收到“语法错误:无效或意外的令牌”。我不得不解决其他一些问题,但似乎无法解决这个问题。有人可以帮忙吗?
2_deploy_contract.js
var Etheremura = artifacts.require("Etheremura");
module.exports = function(deployer) {
deployer.deploy(Etheremura, 0000000000000000000000000D86C54925E12a52a5929c167f20B989F499b3CB7), 000000000000000000000000000000000000000000000000000000000000005f);
};
C:\Users\Rexdog979\eth>truffle migrate
Compiling your contracts...
===========================
√ Fetching solc version list from solc-bin. Attempt #1
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'development'
> Network id: 5777
> Block gas limit: 6721975 (0x6691b7)
2_deploy_contracts.js
=====================
C:\Users\Rexdog979\eth\migrations\2_deploy_contracts.js:4
deployer.deploy(Etheremura, 0000000000000000000000000D86C54925E12a52a5929c167f20B989F499b3CB7), 000000000000000000000000000000000000000000000000000000000000005f);
^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token
at new Script (node:vm:99:7)
at Object.createScript (node:vm:260:10)
at Object.file (C:\Users\Rexdog979\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\require\require.js:93:1)
at Migration._load (C:\Users\Rexdog979\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:49:1)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration.run (C:\Users\Rexdog979\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:212:1)
at Object.runMigrations (C:\Users\Rexdog979\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)
at Object.runFrom (C:\Users\Rexdog979\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
at Object.run (C:\Users\Rexdog979\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:87:1)
at runMigrations (C:\Users\Rexdog979\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:258:1)
at Object.run (C:\Users\Rexdog979\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:223:1)
at Command.run (C:\Users\Rexdog979\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\command.js:147:1)
Truffle v5.3.6 (core: 5.3.6)
Node v16.1.0
答案 0 :(得分:1)
在 )
函数的第二个参数之后有一个多余的右大括号 deployer.deploy()
。
您似乎还试图将地址和无符号整数作为 ABI 编码值传递。但是,Truffle deploy()
函数接受 JS 标量 - 而不是 ABI 编码值。
所以你可以这样做:
deployer.deploy(
Etheremura,
'0xD86C54925E12a52a5929c167f20B989F499b3CB7', // assuming it's an address
95 // assuming it's an integer, 5f hex == 95 decimal
);
答案 1 :(得分:0)
查看部署函数 deployer.deploy(Etheremura, 0000000000000000000000000D86C54925E12a52a5929c167f20B989F499b3CB7), 000000000000000000000000000000000000000000000000000000000000005f);
,您的地址后面有一个不必要的右括号。
同时提供您的地址(如 "0xD86C54925E12a52a5929c167f20B989F499b3CB7"
)和整数形式的值。还要确保您提供的地址是有效的以太坊地址。