4. Deploy Using Ganache v7
Create a local blockchain environment through Ganache v7

1. Deploy via Ganache

  1. 1.
    Click on the terminal to open the Ganache mirror:
Start a local chain by entering ganache without any arguments.:
1
ganache
Copied!
2. Next to port mapping, click on the port, select Ganache, port 8545, click add:
And copy ganache-cli's link:
Thus you have successfully started a ganache local blockchain. You can then connect to the chain via metamask, or deploy the contract via truffle, hardhat. Here is the usage in truffle.
3. Open truffle-config.js in the editor, delete the original content and use the following content:
1
module.exports = {
2
networks: {
3
development: {
4
host: "*******", // ****For the local link generated by the previous port mapping and remove the "https://"
5
port: 80, //80 is the http port
6
network_id: "*"
7
}
8
}
9
};
Copied!
Replace ********** with the ganache-cli port mapping local link generated by yourself before, and remove the previous https://
Such as sandboxbe8dd860b46bganache-cli-8545.gateway.chainide.com
4. Save the CTRL+S and close the configuration file.
5. Switch to the truffle mirror and enter the Metacoin directory
1
cd MetaCoin
Copied!
6. Deployment
1
truffle migrate
Copied!

2. Contract Interaction

You can use the console to interact with the contract
1
truffle console
Copied!

3. Related links