I added the following code for implementing a wait logic after deploying the contract and before calling the functions from the contract. This is same as mentioned in some other posts in Stackexchange.
// await sleep trick
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// We need to wait until any miner has included the transaction
// in a block to get the address of the contract
async function waitBlock() {
while (true) {
let receipt = web3.eth.getTransactionReceipt(transferfunds.transactionHash);
if (receipt && receipt.contractAddress) {
console.log("Your contract has been deployed at http://testnet.etherscan.io/address/" + receipt.contractAddress);
console.log("Note that it might take 30 - 90 sceonds for the block to propagate befor it's visible in etherscan.io");
break;
}
console.log("Waiting a mined block to include your contract... currently in block " + web3.eth.blockNumber);
await sleep(4000);
}
return;
}
While loading the script to Geth for testing, it returned the following error.

The error displayed points to the => from the sleep(). How can we get rid of this error ?
waitBlockfinishes. I've edited my code to reflect that. – user19510 Dec 20 '17 at 21:36