Truffle for Blockchain developer
Installation , Setup , Creation , Compilation,Deployment of Project
Truffle framework is a decentralised application development environment, testing framework, and asset pipeline for Ethereum and other blockchain-based applications (dApps). It offers a set of tools and utilities to help developers build, test, and deploy smart contracts and dApps on the Ethereum network.
Truffle has a huge number of plugins -> download / install & start work immediately
Pros: Setup is easy and Streamlined Development, Debugging features in truffle is strong
Cons: Flexibility is Reduced, Learning Curve, and Lack of Modularity
1) Truffle install and setup
Step1: Create a new folder
Step 2:
npm install -g truffle // use npm to install Truffle:
truffle version // To confirm whether Truffle was installed correctly or not
Truffle v5.7.6 (core: 5.7.6)
Ganache v7.7.3
Solidity v0.5.16 (solc-js)
Node v16.16.0
Web3.js v1.8.2
Step3 :
In VSCode editor , Install Truffle for VS Code plugin
After installation truffle logo appears on the left of vs code
Click on truffle logo -> 'Networks' -> 'Create a new network' -> select 'Ganache service' -> start the service
Step4:
truffle init // To create a truffle project and it will
truffle init creates the following structure of files.
contracts/: Directory for your Solidity contracts
migrations/: Directory for the scriptable deployment files
test/: Directory for files that test your application and contracts
truffle-config.js: The Truffle configuration file
truffle create contract <contract name>
truffle compile // compiles the project
truffle test
Step5: Deploying to Ganache
Scripts to deploy smart contracts are located in the migrations/
directory and are numbered.
truffle develop
// This command will start the truffle console. It will also show some information such as the chain network, accounts, Mnemonic, etc
you will see the console as truffle (develop)>
Type migrate --reset
Use a block explorer like Etherscan to view the transaction details. For example, use the transaction hash or contract address to view the details.
#truffle #blockchain