current position:Home>There is no response after entering the following JS document of truss exec in the truss console, but manual input in the truss can be submitted successfully

There is no response after entering the following JS document of truss exec in the truss console, but manual input in the truss can be submitted successfully

2022-02-03 20:56:15 Q & A of Denglian community

What's the problem truffle edition 5.1.4web3 edition 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)})});}



Take the answer 1:

I know your problem .

stay exec Execution time , Contract objects are not automatically created , therefore Contract.deployed() It won't work .

Add the following code to the header of the file OK 了 .

var MyContract = artifacts.require("MyContract");





Other answers 1:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032056128106.html

Random recommended