Hi @Tomaage,
From the screen shot it looks like you still have a different contract deployed to the one actually displayed in the text editor, and youâre calling functions on that other contract instead.
If you look at the panel with the function-call buttons for your deployed contract, your red deposit button has an input field for a uint
_toAdd
argument. This must be from the previous contract we coded which had the addBalance() function, and where we input unsigned integer values instead of ether values. If you still have that contract deployed, then this will be why itâs not letting you call the deposit function with an ether value in the Value field. As youâve realised, it requires a uint
argument in the input field instead. When youâve deployed the contract you want to interact with, the red deposit button should appear without any input field next to it, because the deposit() function in this contract doesnât have any parameters defined within the parentheses immediately after the function name in the function header.
You can also see that your displayed contract has a withdraw() function, but the transfer() function-call button is the only other one displayed in the panel for the contract which is actually deployed.
Itâs a good idea to have Auto-compile turned on: mark this option under Compiler Configuration in the Solidity Compiler panel. This will make sure that any errors are highlighed by the compiler while youâre coding. If you donât have Auto-compile turned on then you must remember to click the blue Compile button, and check that your contract has successfully compiled, before trying to deploy it. If you still have compiler errors then you wonât be able to deploy your contract until you resolve them.
From looking at your code, I can see that the contract you want to deploy wonât compile, even though youâve used the same code from the video. This is because youâve chosen to use the more up-to-date Solidity v0.8 (which is only to be encouraged) instead of v0.7 (the course uses v0.7.5). If you try to compile your contract, you will notice that you get a red compiler error for this line of code âŠ
Prior to Solidity v0.8, msg.sender
is already a payable address by default, and so doesnât need to be explicitly converted whenever the syntax requires it to reference a payable address (such as, here, with the transfer
method). Thatâs why the code in the video (based on Solidity v0.7 syntax) usesâ msg.sender.transfer(amount);
However, from Solidity v0.8, msg.sender
is non-payable by default, which means having to explicity convert it to a payable address when necessary. So, in order to get your contract to compile you need to make the following modification to this line of code âŠ
payable(msg.sender).transfer(amount);
You will find that the only difference in syntax between these two versions of Solidity, which affects the code covered in this course, concerns msg.sender
. Paying close attention to any compiler errors that you get will help you to easily identify when you need to explicity convert it usingâpayable()
Also, make sure you always remove your previously deployed contract(s) by clicking on the bin icon to the right of where it says Deployed Contracts; or if you only have one contract deployed, clicking on the cross just below the bin icon will also remove the contract. Then, just before you deploy your new contract, make sure it is the one displayed in the Contract field just below the Value field.
Let me know if you experience any further difficulties, or if you have any questions about any of the issues Iâve raised.