264445 (9) [Avatar] Offline
#1
Hello Roberto,
I noticed that contract in listing 3.1 doesn't compile unless I put in the 'public' modifier in the functions:
function SimpleCoin(uint256 _initialSupply) public { ...


The same for the transfer function. I'm not sure if the modifier should be public or not though.
hth
adil
RobertoI (26) [Avatar] Offline
#2
Hi Adil,

thanks for reporting this.
I have just tested it again, by literally copying listing 3.1 from the MEAP PDF and pasting it into a new code tab of Remix (https://ethereum.github.io/browser-solidity/#).

I am getting compilation warnings, which are expected, because in chapter 3 I have not covered yet function access modifiers (such as public, private, etc) and I did not want to confuse the readers by including syntax I have not fully explained yet. Warnings will not prevent you from instantiating the contract, though.

I am interested to understand why this is not compiling on your Remix instance, though.

Can you try the following steps:
1) Please confirm you are getting compilation warnings or definitely errors (which are preventing you from instantiating the contract)
2) Please put the lambda expression at the top of the listing in case you didn't:
pragma solidity ^0.4.0;
3) In case you copied the code from the PDF document, can you please try to copy it from the code I have uploaded to the book website (https://www.manning.com/books/building-ethereum-dapps and look for the "Source code" link)
4) Please let me know what OS and browser version you are running

Please let me know and many thanks again!
Roberto
264445 (9) [Avatar] Offline
#3
Hello Roberto,
ok I tried again in the ethereum wallet application. I've taken a screenshot of what I get. This time I cut and paste the code from listing 3.1.
I've attached the screenshot I hope you can see it. I noticed that the version I'm using is 0.4.18 whereas the one in the listing is 0.4.0 and greater. I'm not sure if there have
been changes? But, it should be the same if we require the same versions. I'm running on Linux.
hth
adil
RobertoI (26) [Avatar] Offline
#4
Hi Adil,

you are right, listing 3.1 is executed in the wallet and since the latest release, in order to deploy the contract, you must specify functions as public.

Thanks for spotting this and I will amend listing 3.1 accordingly on the manuscript.

Roberto
264445 (9) [Avatar] Offline
#5
Hello Roberto,
no problem I am very happy to help. One thing that puzzle's me is the pragma at the beginning we set to 0.4.0 so shouldn't code that compiled in that version compile in newer versions because we are asking to be compliant with version 0.4.0 and upwards? I guess I misunderstand something.
hope all is well,
adil
RobertoI (26) [Avatar] Offline
#6
Hi Adil, that 0.4.0 contract code compiles correctly in Remix and it compiles correctly also in my Windows Ethereum wallet, version: 0.9.1, so I believe it is not a compilation issue. I might be wrong, but I suspect they might have changed something in the wallet implementation that now requires all functions to be declared explicitly as public in order to access them. So, I believe it might be an accessibility issue, rather than a compilation one. I will download the latest Windows version (0.9.3) and check if I experience the same issue. In the meantime, can you please let me know what version of the Linux wallet are you running? Many thanks for your help with this!
264445 (9) [Avatar] Offline
#7
Hello Roberto,
Sorry for the delay. The version I am using of Ethereum Wallet is 0.9.3. I download the 64bit tar file and used that. Is that ok?
adil
RobertoI (26) [Avatar] Offline
#8
Many thanks for confirming this, which explains why you see the issue and I don't. I will update my wallet and retest.
berevoescu (7) [Avatar] Offline
#9
I had the same issue - and it might be related to having on our side a newer version of Solidity.
It is no only the public modifier, but it looks like naming constructor rules changed from using the name of the contract, to this sort of construct:

constructor() public {
...
}

Note: I have version 0.4.24 on my side.
RobertoI (26) [Avatar] Offline
#10
You are right, a few Solidity keywords have been introduced recently, such as constructor().

I am planning to rewrite all book examples with the latest syntax for the next MEAP release.
berevoescu (7) [Avatar] Offline
#11
I can hardly wait for the next MEAP release (I did get to the end of the current version in a couple of days and I am looking forward for the rest smilie
There are other little changes needed in the sample code from the book, due to the new additions and changes in Solidity, but it's pretty straightforward to find them on one's own.

Thanks,
--bjh