- Install
Truffle
npm install -g truffle
- Install Ganache
To install ganache globally as cli tool:
npm install ganache --global
or install Ganache UI https://trufflesuite.com/ganache/
- Creating a Truffle project
truffle init new_project
- Pick a contract name (for example
Test
)
truffle create contract Test
- To run test in Truffle
truffle test
- Compile the contracts
truffle compile
- To deploy our contract in a testing environment, we use ganache cli tool (or use Ganache UI)
ganache
It will start a RPC server. After running ganache it will provide you and endpoint to connect with (for example http://127.0.0.1:8545)
- To connect to this endpoint, modify the truffle-config.js
networks: {
ganacheLocal: {
host: "127.0.0.1",
port: 8545,
network_id: "*"
}
- Deploy contract
truffle deploy --network ganacheLocal
also you can use Ethereum Remix plugin for VS Code https://marketplace.visualstudio.com/items?itemName=RemixProject.ethereum-remix