Truffle Introduction

Hey @Kraken

You have to run the command as sudo: sudo npm install -g etc...

Let me know

1 Like

By checking your console it seems like truffle successfully migrated only one file while they should be two:

Screenshot 2020-12-07 at 16.04.31

Follow these steps:

Truffle should migrate your project and you should see that reflected in Ganache.

If that does not work push your project on github and share the repo.

Happy coding,
Dani

This is the screenshot:

Hey @cswan1

Can you share your truffle config file?

thanks,
Dani

/**

  • Use this file to configure your truffle project. It’s seeded with some
  • common settings for different networks and features like migrations,
  • compilation and testing. Uncomment the ones you need or modify
  • them to suit your project as necessary.
  • More information about configuration can be found at:
  • trufflesuite.com/docs/advanced/configuration
  • To deploy via Infura you’ll need a wallet provider (like @truffle/hdwallet-provider)
  • to sign your transactions before they’re sent to a remote public node. Infura accounts
  • are available for free at: infura.io/register.
  • You’ll also need a mnemonic - the twelve word phrase the wallet uses to generate
  • public/private key pairs. If you’re publishing your code to GitHub make sure you load this
  • phrase from a file you’ve .gitignored so it doesn’t accidentally become public.

*/

// const HDWalletProvider = require(’@truffle/hdwallet-provider’);
// const infuraKey = β€œfj4jll3k…”;
//
// const fs = require(β€˜fs’);
// const mnemonic = fs.readFileSync(".secret").toString().trim();

module.exports = {
/**

  • Networks define how you connect to your ethereum client and let you set the
  • defaults web3 uses to send transactions. If you don’t specify one truffle
  • will spin up a development blockchain for you on port 9545 when you
  • run develop or test. You can ask a truffle command to use a specific
  • network from the command line, e.g
  • $ truffle test --network
    */

networks: {
// Useful for testing. The development name is special - truffle uses it by default
// if it’s defined here and no other network is specified at the command line.
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
// tab if you use this network and you must also set the host, port and network_id
// options below to some value.
//
// development: {
//host: β€œ127.0.0.1”, // Localhost (default: none)
// port: 8545, // Standard Ethereum port (default: none)
// network_id: β€œ*”, // Any network (default: none)
// },
// Another network with more advanced options…
// advanced: {
// port: 8777, // Custom port
// network_id: 1342, // Custom network
// gas: 8500000, // Gas sent with each transaction (default: ~6700000)
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
// from: , // Account to send txs from (default: accounts[0])
// websockets: true // Enable EventEmitter interface for web3 (default: false)
// },
// Useful for deploying to a public network.
// NB: It’s important to wrap the provider as a function.
// ropsten: {
// provider: () => new HDWalletProvider(mnemonic, https://ropsten.infura.io/v3/YOUR-PROJECT-ID),
// network_id: 3, // Ropsten’s id
// gas: 5500000, // Ropsten has a lower block limit than mainnet
// confirmations: 2, // # of confs to wait between deployments. (default: 0)
// timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
// skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
// },
// Useful for private networks
// private: {
// provider: () => new HDWalletProvider(mnemonic, https://network.io),
// network_id: 2111, // This network is yours, in the cloud.
// production: true // Treats this network as if it was a public net. (default: false)
// }
},

// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},

// Configure your compilers
compilers: {
solc: {
// version: β€œ0.5.1”, // Fetch exact version from solc-bin (default: truffle’s version)
// docker: true, // Use β€œ0.5.1” you’ve installed locally with docker (default: false)
// settings: { // See the solidity docs for advice about optimization and evmVersion
// optimizer: {
// enabled: false,
// runs: 200
// },
// evmVersion: β€œbyzantium”
// }
}
}
};

Hello,

I got this far in the session but can’t proceed. Per the instructions, I created the function setMessage in Atom and typed let instance = await Helloworld.deployed() in the console. However, the message in the console shows an error. I tried it several times too. How do I fix this? What caused it?

Thank you.

I’m tried redoing the lesson again. But now, like the first time, my console will only compile the migration file. It will not run the Helloworld file. Does anyone know why this is happening? Do I need to delete files in Atom before attempting to run again. This is very frustrating.

What do you mean β€˜cd into your project root using your terminal’? I am a novice and do not understand that instruction. Plus, I got everything to work but hit a wall following Filip’s directions for setting up function setMessage(). The console would not allow me to create the instance. I restarted and now the same problem where the command line only migrated the migration file. It cannot see the Helloworld file.

What do I need to do?

Hey @cswan1

You should be able to run truffle migrate --reset, once the contracts are migrated you can truffle console and interact with them.

The error you posted is telling you the instance has already been declared, which means that you have to assign the new contract instance by typing instance = await HelloWorld.deployed() (so omit the let command to avoid multiple declarations.

But now, like the first time, my console will only compile the migration file. It will not run the Helloworld file.

Run truffle migrate --reset.

@gabba @filip
I tried to install as per your instructions above and finally installed without the -g.
Now my Terminal is giving the following comments :slight_smile:

Last login: Wed Dec 9 19:08:48 on ttys000

aadyakalra@Aadyas-MacBook-Air ~ % npm install [email protected]

npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

added 27 packages, and audited 27 packages in 16s

4 low severity vulnerabilities

To address all issues, run:

npm audit fix --force

Run npm audit for details.

aadyakalra@Aadyas-MacBook-Air ~ %

should i run the npm audit fix --force. ??

Hi @filip @gabba

Please help.
I have been trying for the last 2 hours .

I tried with the npm install -g [email protected] - it didn’t work.
Later i tried with npm install [email protected] - it finally worked (but now i don’t remember the location where this installation took place)

so i finally later installed in the below location ( again)

And Now its showing the below mentioned error :

Sorry, name can only contain URL-friendly characters.

Last login: Wed Dec 9 20:52:22 on ttys000

aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents/Ethereum\ Smart\ Contract\ advanced/Package

aadyakalra@Aadyas-MacBook-Air Package % npm init

This utility will walk you through creating a package.json file.

It only covers the most common items, and tries to guess sensible defaults.

See npm help init for definitive documentation on these fields

and exactly what they do.

Use npm install <pkg> afterwards to install a package and

save it as a dependency in the package.json file.

Press ^C at any time to quit.

package name: (package) npm install [email protected]

Sorry, name can only contain URL-friendly characters.

package name: (package)

Thanks brutherin, that worked!

1 Like

Last login: Thu Dec 10 12:26:42 on ttys000
aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents
aadyakalra@Aadyas-MacBook-Air Documents % npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See npm help init for definitive documentation on these fields
and exactly what they do.

Use npm install <pkg> afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (documents)
version: (1.0.0)
description:
entry point: (jsintro.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to /Users/aadyakalra/Documents/package.json:

{
β€œname”: β€œdocuments”,
β€œversion”: β€œ1.0.0”,
β€œdescription”: β€œβ€,
β€œmain”: β€œjsintro.js”,
β€œscripts”: {
β€œtest”: β€œecho β€œError: no test specified” && exit 1”
},
β€œauthor”: β€œβ€,
β€œlicense”: β€œISC”
}

Is this OK? (yes)
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js

  • Fetching solc version list from solc-bin. Attempt #1
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN [email protected] No description
    npm WARN [email protected] No repository field.
  • [email protected]
    added 27 packages from 439 contributors and audited 27 packages in 10.5s
    found 1 low severity vulnerability
    run npm audit fix to fix them, or npm audit for details
    aadyakalra@Aadyas-MacBook-Air Documents % npm audit fix
    npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)

[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js

  • [email protected]
    added 120 packages from 59 contributors, removed 3 packages and updated 10 packages in 23.509s

37 packages are looking for funding
run npm fund for details

fixed 1 of 1 vulnerability in 27 scanned packages
aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % npm fund
[email protected]
β”œβ”€β”¬ https://opencollective.com/mochajs
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/sponsors/sindresorhus
β”‚ └── [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
β”œβ”€β”¬ https://github.com/sponsors/isaacs
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/sponsors/ljharb
β”‚ └── [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
β”œβ”€β”¬ https://github.com/sponsors/jonschlinkert
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/chalk/chalk?sponsor=1
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/chalk/ansi-styles?sponsor=1
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/sponsors/feross
β”‚ └── [email protected], [email protected]
β”œβ”€β”¬ https://www.patreon.com/feross
β”‚ └── [email protected], [email protected]
└─┬ https://feross.org/support
└── [email protected], [email protected]

aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js

  • [email protected]
    added 3 packages from 2 contributors, removed 129 packages, updated 10 packages and audited 27 packages in 13.356s
    found 1 low severity vulnerability
    run npm audit fix to fix them, or npm audit for details
    aadyakalra@Aadyas-MacBook-Air Documents % npm audit fix
    npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)

[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js

  • [email protected]
    added 120 packages from 59 contributors, removed 3 packages and updated 10 packages in 18.989s

37 packages are looking for funding
run npm fund for details

fixed 1 of 1 vulnerability in 27 scanned packages
aadyakalra@Aadyas-MacBook-Air Documents % npm fund
[email protected]
β”œβ”€β”¬ https://opencollective.com/mochajs
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/sponsors/sindresorhus
β”‚ └── [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
β”œβ”€β”¬ https://github.com/sponsors/isaacs
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/sponsors/ljharb
β”‚ └── [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
β”œβ”€β”¬ https://github.com/sponsors/jonschlinkert
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/chalk/chalk?sponsor=1
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/chalk/ansi-styles?sponsor=1
β”‚ └── [email protected]
β”œβ”€β”¬ https://github.com/sponsors/feross
β”‚ └── [email protected], [email protected]
β”œβ”€β”¬ https://www.patreon.com/feross
β”‚ └── [email protected], [email protected]
└─┬ https://feross.org/support
└── [email protected], [email protected]

aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn’t exist.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/aadyakalra/.npm/_logs/2020-12-10T07_34_32_123Z-debug.log
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js

  • [email protected]
    added 3 packages from 2 contributors, removed 120 packages, updated 10 packages and audited 27 packages in 10.187s
    found 1 low severity vulnerability
    run npm audit fix to fix them, or npm audit for details
    aadyakalra@Aadyas-MacBook-Air Documents % npm audit

                     === npm audit security report ===                        
    

Run npm install [email protected] to resolve 1 vulnerability

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Low β”‚ Prototype Pollution β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Package β”‚ minimist β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Dependency of β”‚ truffle β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Path β”‚ truffle > mocha > mkdirp > minimist β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ More info β”‚ https://npmjs.com/advisories/1179 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

found 1 low severity vulnerability in 27 scanned packages
run npm audit fix to fix 1 of them.
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)

[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js

  • [email protected]
    added 120 packages from 59 contributors, removed 3 packages, updated 10 packages and audited 144 packages in 17.794s

37 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

t% aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % truffle init

I have tried all methods @gabba @Erno @filip @thecil

but its just not working… i have searched on google as well…

nothing seems to be working,

Hey @Su.kal.Crypto

What you see there are warnings generated by npm, nothing to worry about.
Truffle should work as expected

Hey Dan,

as you would have seen in the above message it says:

β€œt% aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle”

Also, as shown by Filip in his first (Installation) video in Smart contract programming 201, he had said that if everything works fine then the system will generate a basic project for me with files and folders.

so, as you are saying, even if it doesn’t work in the way Filip showed, in my Computer, should i just proceed with the course’s next video , and eventually everything will work fine ??

i am using a Mac

thanks and regards

Suveett Kalra

Dear Danielle,
Also, because when i am running command ls
in the ethereum-course-advanced folder its showing β€œHelloworld” and when i am running command β€œls” again in Helloworld,

it’s going blank unlike in Filip’s video on running β€œls” it was showing the following
contracts. test
migrations. truffle- config.js

see below :slight_smile:

Last login: Thu Dec 10 15:10:58 on ttys000

aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents/ethereum-course-advanced

aadyakalra@Aadyas-MacBook-Air ethereum-course-advanced % ls

Helloworld

aadyakalra@Aadyas-MacBook-Air ethereum-course-advanced % cd /Users/aadyakalra/Documents/ethereum-course-advanced/Helloworld

aadyakalra@Aadyas-MacBook-Air Helloworld % ls

aadyakalra@Aadyas-MacBook-Air Helloworld %

so, you are suggesting that i just proceed to the next Video ??

thanks and regards

Suveett kalra

Last login: Thu Dec 10 15:10:58 on ttys000

aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents/ethereum-course-advanced

aadyakalra@Aadyas-MacBook-Air ethereum-course-advanced % ls

Helloworld

aadyakalra@Aadyas-MacBook-Air ethereum-course-advanced % cd /Users/aadyakalra/Documents/ethereum-course-advanced/Helloworld

aadyakalra@Aadyas-MacBook-Air Helloworld % ls

aadyakalra@Aadyas-MacBook-Air Helloworld %

@dan-i. kindly see above and revert. Thanks and awaiting. I am really looking forward to completing this course soon, and then the Smart contract Risk assessment/ management course.

regards

Suveett kalra

1 Like

Hey @Su.kal.Crypto

If you get β€˜command not found: truffle’ means that Truffle is not installed globally.
Open your terminal and run sudo npm install -g [email protected].

Once done navigate into an (empty) project folder and run truffle init.

Should work fine.

Let me know

Dear @dan-i

Now its showing the below message :slight_smile:
Last login: Thu Dec 10 19:51:22 on ttys000

aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents

aadyakalra@Aadyas-MacBook-Air Documents % sudo npm install -g [email protected].

Password:

npm ERR! code ETARGET

npm ERR! notarget No matching version found for [email protected]…

npm ERR! notarget In most cases you or one of your dependencies are requesting

npm ERR! notarget a package version that doesn’t exist.

npm ERR! A complete log of this run can be found in:

npm ERR! /Users/aadyakalra/.npm/_logs/2020-12-10T14_22_54_253Z-debug.log

aadyakalra@Aadyas-MacBook-Air Documents % sudo npm install -g [email protected]

npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module β€˜is-npm’

npm ERR! Require stack:

npm ERR! - /usr/local/lib/node_modules/npm/node_modules/update-notifier/index.js

npm ERR! - /usr/local/lib/node_modules/npm/bin/npm-cli.js

npm ERR! A complete log of this run can be found in:

npm ERR! /Users/aadyakalra/.npm/_logs/2020-12-10T14_23_27_411Z-debug.log

aadyakalra@Aadyas-MacBook-Air Documents %

aadyakalra@Aadyas-MacBook-Air Documents %

kindly revert whats to be done next?

thanks and regards

suveett Kalra