Skip to main content
Daniel Portugal's user avatar
Daniel Portugal's user avatar
Daniel Portugal's user avatar
Daniel Portugal
  • Member for 5 years, 10 months
  • Last seen more than a month ago
  • Brazil
awarded
awarded
awarded
awarded
comment
Calling function from existing truffle contract in node.js
Between those curly brackets, you can do something with result: .then(function(result) { console.log(JSON.stringify(result)); }, function(error)... But you don't need that, since you're already listening to the receipt. What's inside result is the receipt. You can get more info here: web3js.readthedocs.io/en/v1.2.5/callbacks-promises-events.ht‌​ml
revised
Loading…
revised
Loading…
revised
Loading…
Loading…
awarded
comment
Problem with running truffle code with node.js
Just after the .once('transactionHash', function(hash) { console.log("TxHash: " + hash); }) Should be something like .once('transactionHash', function(hash) { console.log("TxHash: " + hash); }).on('receipt', function(receipt) { console.log("receipt: " + JSON.stringify(receipt)); }).then(function(instance) { return instance.getInsurerInfo.call() }) and so on
awarded
comment
Problem with running truffle code with node.js
Oh, no it doesn't. If it has any functionality like the browser's console, I'm unaware of it.
comment
Problem with running truffle code with node.js
As a side note: you can get the receipt for your deploy by adding this to your promise chain: .on('receipt', function(receipt) { console.log("receipt: " + JSON.stringify(receipt)); })
comment
Problem with running truffle code with node.js
You're welcome. You're right about the dotenv, it's required and I was importing it in another file. Ok, actually I don't think it's hanging. The contract has been deployed successfully and this output you posted proves so because what the code is doing there is calling the function getInsurerInfo from the deployed contract. That function should return exactly what you posted. So, yeah, success! :) It's deployed properly.
revised
Problem with running truffle code with node.js
deleted 9 characters in body
Loading…
revised
Problem with running truffle code with node.js
added 169 characters in body
Loading…
revised
Loading…
revised
Problem with running truffle code with node.js
added 650 characters in body
Loading…