zak100 Posted June 29, 2020 Share Posted June 29, 2020 Hi, I am trying to run the following code. I am getting error while executing the line: truffle(ganache)> const putAmount = putBalance.c[0] The error is : Quote evalmachine.<anonymous>:0 const putAmount = putBalance.c[0] ^ TypeError: Cannot read property '0' of undefined at evalmachine.<anonymous>:0:31 at sigintHandlersWrap (vm.js:98:15) I have uploaded the image of the whole program. I don't have much knowledge of Javascript. Somebody please guide me how to define the property 'c[0]'. Zulfi. Link to comment Share on other sites More sharing options...
fiveworlds Posted June 29, 2020 Share Posted June 29, 2020 The error is caused by an outdated Truffle and inconsistent Solidity version not returning the expected JSON result to putBalance. The tests themselves are not written in JavaScript. You are better off learning the latest versions of Truffle and Solidity . $ sudo apt-get update $ sudo apt-get install nodejs $ sudo apt-get install ethereum $ sudo apt-get install geth $ sudo npm install -g truffle $ mkdir MetaCoin $ cd MetaCoin $ truffle unbox metacoin //Open a seperate terminal and run $ cd MetaCoin $ testrpc //Back in the original terminal $ truffle test 1 Link to comment Share on other sites More sharing options...
zak100 Posted June 30, 2020 Author Share Posted June 30, 2020 (edited) Hi myfriend- Thanks a lot for your response. I got the code from the following link: https://github.com/Bdragon93/reentrancy-acttack Please check the above image, they have not defined 'c[0]'. My Truffle version: Quote Truffle version is: truffle(ganache)> truffle version Truffle v5.1.27 (core: 5.1.27) Solidity v0.5.16 (solc-js) Node v8.10.0 Web3.js v1.2.1 truffle(ganache)> Kindly tell me which version are you talking about? Kindly guide me which tutorial are you using, what is in your 'test' file? Zulfi. Hi fiveworlds- You are right. It was a version problem. Correct: truffle(ganache)> const putAmount = putBalance.toNumber() undefined Zulfi. Edited June 30, 2020 by zak100 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now