truffle控制台输入truffle exec 如下js文档后,没有反应,但是手动在truffle输入却可以提交成功

请问这是什么问题 truffle版本5.1.4 web3版本1.0.0

module.exports = function(callback) {
 current_time = Math.round(new Date() / 1000);
 amt_1 = web3.utils.toWei(1, 'ether');
 Contract.deployed().then(function(i) {i.myFunc('name_1', 'cate', 'Hash_2', 'Hash_1', current_time, current_time + 200, 2*amt_1, 0).then(function(f) {console.log(f)})});
 Contract.deployed().then(function(i){i.myFunc2.call().then(function(f){console.log(f)})});
}
请先 登录 后评论

最佳答案 2020-04-22 18:35

我知道你的问题了。

在 exec 执行时, 不会自动创建合约对象,因此 Contract.deployed() 没法运行的。

在文件头加入以下代码就 OK 了。

var MyContract = artifacts.require("MyContract");
请先 登录 后评论

其它 1 个回答

Tiny熊 - 布道者
  擅长:智能合约,以太坊
请先 登录 后评论