Truffle Introduction

@filip first of all thank you for including us in space! Big shout out!
And like everyone here, I have truble when trying to initialize truffle:

PS D:> cd Helloworld/
PS D:\Helloworld> truffle init
truffle : File C:\Users\MAŠA I SOFIJA\AppData\Roaming\npm\truffle.ps1 cannot be loaded because running scripts is disab
led on this system. For more information, see about_Execution_Policies at https:/
At line:1 char:1

  • truffle init
  •   + CategoryInfo          : SecurityError: (:) [], PSSecurityException
      + FullyQualifiedErrorId : UnauthorizedAccess

PS D:\Helloworld>

What do you recommend me to do?

I’m running into an issue where my console.log command isn’t printing anything onto the screen. Within powershell I can run getMessage() and see that the message has been updated by the deploy.js file. This is my code

const HelloWorld = artifacts.require("HelloWorld");

module.exports = function (deployer) {
    instance.setMessage("Hello Again!").then(function(){
        console.log("Current message: " + message);

Open a new powershell window as administrator and run this command

Set-ExecutionPolicy -ExecutionPolicy Bypass

Now run the init again


@filip @dan-i

I have a question when I apply the following function. the account balance of the player address is not increase by the msg.value? I can see the log shows the value I define in msg.value.

// withdraw fund from contract for player
function withdrawFromPlayer() public payable {
    require(playerBalance[msg.sender] >= msg.value);
    require(msg.value > 0);
    uint playerbalance;
    uint toTransfer = msg.value;
    playerBalance[msg.sender] -= toTransfer;
    playerbalance = playerBalance[msg.sender];
    emit WithdrawFromPlayer(msg.sender, toTransfer, playerbalance);

for example, I deposite 3 Ether to playerBalance[msg.sender], then I withdraw 1 Ether from playerBalance[msg.sender], the balance of playerBalance[msg.sender] is 2. but I don’t see +1 ether from player’s account.

@Bobcat It works now, bless you :smiling_face_with_three_hearts:


Hello there, @filip

I was wondering if anyone else has had issues with this and knows how they may have fixed it. I’m getting this error and have had a difficult time trying to figure out why.

I’ve already tried uninstalling and reinstalling Truffle and Ganache. The first time I truffle compile & truffle migrate it seems to work with no issues. But anytime I try to migrate after I get this error.

I’m not sure of it’s an issue with the module.exports or the networks in the truffle.config.js file? I left it the way it was commented out so I would have guess that it would have just worked out fine.

I was also trying to figure out where those file locations were and couldn’t find any files past webpack location (I’m guessing there’s a reason for that that I’m not knowledgeable of).

Thank you for the help!

ExtendableError: Unknown network "ganache". See your Truffle configuration file for available networks.
    at Object.validateNetworkConfig (/home/paulrmunley/.npm-global/lib/node_modules/truffle/build/webpack:/packages/environment/environment.js:110:1)
    at Object.detect (/home/paulrmunley/.npm-global/lib/node_modules/truffle/build/webpack:/packages/environment/environment.js:16:1)
    at /home/paulrmunley/.npm-global/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:206:1

I fixed this by adjusting the “truffle-config.js” file. Within that file you’ll see a “networks’ section with some commented out lines. Remove the comments and adjust the setting to what Ganache shows in the header (the RCP server, Network ID”). Mine looks like

    development: {
      host: "",    
      port: 7545,            
      network_id: 5777,  

I was able to fix the issue I was having with the getMessage() function not firing, I had to take it out of the setMessage function (basically move the curly brackets). In the video Setter Function @filip has it within the function and it works fine so I’m confused as to why I had to make these adjustments.

`module.exports = function (deployer) {
    instance.setMessage("Hello Again!").then(function(){});
      console.log("Current message: " + message);
1 Like

Thank you so much for this. I changed everything but the network_id: 5777, myself. I thought the star would make it use whatever network ID as it said but for some reason that wasn’t working. I appreciate the help on this! :+1:

1 Like

I actually noticed this on my end as well. When I followed the example it wasn’t showing the current message at all. I tried changing things around in the HelloWorld migration file and had no luck getting the same response. I did use the syntax that you had and it did end up working.

Hey @Paul_Kwok

The withdraw function does not need to be payable because you are not sending ether to it.
Remove also require (msg.value > 0) as you do not have to send ether to that function.


I am stuck at setMessage. I cannot find my error.

I did the usual; restart of CMD and I’ll be damned, it works, but why?


Difficult to say why worked after restarting the terminal, maybe some changes were not saved?

1 Like

At “Building our First Test Part 1” 5:55 I do not get the correct result. I get

I cannot see what is wrong, nor where to find the error.



That’s a bug in the node js version you are using.
Follow this faq to downgrade node: FAQ - How to downgrade Node.Js

1 Like


It might be a good idea to give these instructions when installing in the first place, saving a lot of cursing! Being a teacher I always warn my students if they are about to find solutions by them selves, when I know the task ahead is dependent of them finding fundamental tools to complete the assignment.

@filip the Ganache2.1.1 has issues for Mac installation I am receiving following error as soon as I launch it. Is it ok to just get the latest version?

Error: Hardfork muirGlacier not set as supported in supportedHardforks
at Common.setHardfork (/node_modules/ganache-core/node_modules/ethereumjs-common/src/index.ts:112:13)
at new Common (/node_modules/ganache-core/node_modules/ethereumjs-common/src/index.ts:79:12)
at new VM (/node_modules/ganache-core/node_modules/ethereumjs-vm/dist/index.js:62:21)
at BlockchainDouble.createVMFromStateTrie (/node_modules/ganache-core/lib/blockchain_double.js:130:14)
at /node_modules/ganache-core/lib/blockchain_double.js:85:36
at /node_modules/ganache-core/lib/blockchain_double.js:191:5
at /node_modules/ganache-core/lib/database/leveluparrayadapter.js:129:14
at /node_modules/ganache-core/lib/database/leveluparrayadapter.js:24:16
at /node_modules/ganache-core/node_modules/level-sublevel/shell.js:101:15
at /node_modules/ganache-core/node_modules/level-sublevel/nut.js:121:19
at /node_modules/ganache-core/node_modules/encoding-down/index.js:51:21
at /node_modules/ganache-core/node_modules/cachedown/index.js:58:21
at ReadFileContext.callback (/node_modules/ganache-core/lib/database/filedown.js:26:14)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)

I could be wrong, but I believe taking getMessage out of the setMessage function causes the program to not wait for the success of setMessage, thus breaking the promise chain. This file almost reminds me of the callback hell. That being said, I also had no luck having the truffle console log the message using the code Filip posted.

Hey @kHarsh

Can you please provide a screenshot of your terminal where we can verify the command you are trying to run?