Open truffle-config.js file and uncomment the development code if commented
networks: { // Useful for testing. Thedevelopmentname 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 thehost,portandnetwork_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) // }, .... }
Once done change the port number to 7545 which is default port for ganache.
networks: { // Useful for testing. Thedevelopmentname 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 thehost,portandnetwork_id // options below to some value. // development: { host: "127.0.0.1", // Localhost (default: none) port: 7545, // Standard Ethereum port (default: none) network_id: "*", // Any network (default: none) }, ..}
Now run ganache first then on terminal compile you smart contracts using truffle compile then migrate using truffle migrate --network development
and you will notice that the contract is deployed.
Open truffle-config.js file and uncomment the development code if commented
networks: { // Useful for testing. The
developmentname 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,
portand
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) // }, .... }
Once done change the port number to 7545 which is default port for ganache.
networks: { // Useful for testing. The
developmentname 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,
portand
network_id// options below to some value. // development: { host: "127.0.0.1", // Localhost (default: none) port: 7545, // Standard Ethereum port (default: none) network_id: "*", // Any network (default: none) }, ..}
Now run ganache first then on terminal compile you smart contracts using
truffle compile
then migrate usingtruffle migrate --network development
and you will notice that the contract is deployed.