1

I am trying to run the following script:

const messageBuild = require('./build/contracts/MyContract.json')

const MyContract = require('~/Truffle_programs/script_transfer_Eth_thr_Truffle/contracts/MyContract.sol'); const MyContractTester = require('~/Truffle_programs/script_transfer_Eth_thr_Truffle/contracts/MyContractTester.sol'); module.exports = (callback)=>{ var acc1 = accounts[1] var acc2 = accounts[2] const myC = MyContract.deployed() const myCT = MyContractTester.deployed() web3.eth.sendTransaction({to:myC.address, from:acc2, value: web3.utils.toWei('11')}) balance2 = web3.eth.getBalance(acc2) web3.utils.fromWei(balance2, "ether") mybal = web3.eth.getBalance(myC.address) web3.utils.fromWei(mybal, "ether") myC.sendTo(myCT.address, web3.utils.toWei('3',"ether"), {from:accounts[0]}) myCbal = web3.eth.getBalance(myC.address) web3.utils.fromWei(myCbal, "ether") myCTbal = web3.eth.getBalance(myCT.address) web3.utils.fromWei(myCTbal, "ether") }

but I am getting the error:

truffle(development)> truffle exec ./myscript.js
Using network 'development'.

internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module '~/Truffle_programs/script_transfer_Eth_thr_Truffle/contracts/MyContract.sol'

I tried the "ls" command and found that the path is correct:

@lc2530hz:~$ ls ~/Truffle_programs/script_transfer_Eth_thr_Truffle/contracts/
Migrations.sol  MyContract.sol  MyContractTester.sol

Somebody please guide me.

Zulfi.

zak100
  • 1,406
  • 1
  • 13
  • 37

0 Answers0