QA InfoTech , Independent Software Testing Service Logo
jobs@qainfotech.com
Sales: Contact Sales +1 469-759-7848 sales@qainfotech.com
QA Infotech your Software testing partner
Menu
  • About
    • Team
    • Overview
    • Values and Culture
    • QA InfoTech Foundation
    • Careers
  • Services
    • QUALITY ENGINEERING
      • Functional Testing
      • Automation Testing
      • Mobile Testing
      • Performance Testing
      • Accessibility Testing
      • Usability Testing
      • Security Testing
      Quality ASSURANCE
      • Globalization, Translation & Localization Testing
      • Courseware & Content Testing
      • Crowdsourced Testing
      • Cloud Testing
      Software Development
      • eLearning
      • Data Sciences
      • Accessibility Development
      • Mobility Solutions
      • Web Development
      • Front End Frameworks
      • Salesforce Development
      • Cloud Solutions
      • Enterprise Content Management
      • Odoo
      • ServiceNow
      • AS400
      Digital Assurance
      • Digital Assurance
      • Data Sciences & Analytics
      • Quality Consulting & Test Center of Excellence (TCOE)
      • SAP Testing
      • Selenium Test Automation
      • Blockchain Testing
  • Verticals
    • e-learning
      List Start
    • e-Learning
    • Publishing
    • BFSI
    • Health Care
    • Media
    • Travel
    • Retail
    • Government
    • OpenERP
    • List Stop
  • Knowledge Center
    • Case Studies
    • White Paper
    • Webinars
    • Blogs
  • WebinarsNew
  • News
    • News
    • Press Release
  • Contact
  • Get A Quote
  • Home
  • »
TRUFFLE – A Framework for Solidity Smart Contracts
20 Aug, 2019

TRUFFLE – A Framework for Solidity Smart Contracts

  • Oshin Gupta
  • Blockchain
  • Tags: Framework for Smart Contracts, Solidity Smart Contracts, Truffle Framework
  • no comments

It’s very tempting to work on emerging technologies and going insane to explore more on that. This article includes details about one such framework used for blockchain development. Considering you have a basic idea about the smart contracts development, we move forward to learn about the truffle framework for the deployment and testing of smart contracts. 

Let’s face it, it’s very difficult to manage the lifecycle and processing of a smart contract. To do so, we have to first write the contract and compile it using solc (the solidity compiler). After successful compilation, we get the contract artifacts such as ABI, bytecode, etc which is then used to deploy the contract on the connected network. Once the contract is deployed, we then use the deployed contract’s address to perform the testing. 

This procedure requires extra time and attention from the smart contract developer. To enhance the effortless processing of the smart contract, the Truffle suite is developed. Truffle framework is designed for the smart contract developer to deploy and test their contracts using some basic commands. 

Truffle provides the following feature set to the developers:

  • Built-in smart contract compilation, linking, deployment and binary management.
  • Automated contract testing for rapid development.
  • Scriptable, extensible deployment & migrations framework.
  • Network management for deploying to any number of public & private networks.
  • Package management with EthPM & NPM, using the ERC190 standard.
  • Interactive console for direct contract communication.
  • Configurable build pipeline with support for tight integration.
  • External script runner that executes scripts within a Truffle environment.

After knowing the feature set, smart contract heroes must be excited to learn more about the technical implementation and usage of the Truffle framework. Let’s get started with a practical example.

Installation: Install truffle in your system using npm:

$ npm install -g truffle

Skip this step if the truffle is already installed. 

Network Setup: To deploy the contracts, we will be requiring a blockchain network. One can create their private network using geth or connect to any testnet (Network configurations need to be defined in the truffle configuration file). In this article, we are going to use ganache-cli, which is the ethereum testrpc having 10 accounts with 100 ether balance. In a separate terminal, install and run the ganache-cli using npm:

$ npm install -g ganache-cli
$ ganache-cli

Project Creation: Create a project directory and navigate inside that directory:

$ mkdir truffle_app
$ cd truffle_app

Project Structuring: Initialize the project with truffle by running either of the following commands:

$ truffle init
$ truffle unbox <box_name>

Truffle init is used to initialize the truffle project with no smart contract included. Truffle unbox command is used to download any project from the truffle box. After successful execution, the project structure is created with the following directories or files inside the project directory:

  1. contracts/: This directory includes all the solidity smart contracts.
  2. migrations/: This directory includes the scriptable migration files.
  3. test/: This directory includes the test files written in javascript and/or solidity.
  4. truffle-config.js: This file includes the truffle configurations for the compiler, network, plugins, test (mocha), etc.

Network Configuration: As we are using ganache-cli, we need to configure networks for development in the truffle-config file by setting host to “127.0.0.1”, port to 8545 (default port for ganache-cli) and network_id to “*” (any network).

Contract Compilation: Once the project structure is created, define all your solidity smart contracts in the contracts/ directory. Truffle uses the default solc compiler to compile the contracts or it can use the external compiler if defined in the truffle configuration file. 

$ truffle compile

This command will create the build/ directory inside the project directory including the contracts/ directory for storing the contract artifacts in the .json file. Each contract has its own .json file irrespective of the contracts file. (Suppose there is one contract file in the contracts/ directory which includes two contracts, then after compilation, the build/contracts/ directory have two .json files for each one).

For more details, refer to contract compilation truffle documentation.

Contract Migration: Migration files can be written in javascript which includes the contract artifacts using the artifacts.require() as shown below. 

let SampleContract = artifacts.require(‘SampleContract’);

Migration files have module.exports function defined as below:

Module.exports = function(deployer, network, accounts) {
// Deploy your contracts as shown below
deployer.deploy(SampleContract, arg1, arg2, { from: accounts[1] });
}

File name starts wth a number which is used to keep track of the sequence and is followed by the basic description. Once the migration files are defined, one can deploy or link the contracts using the following command:

$ truffle migrate

This will generate the addresses of the contracts deployed. 

For more details, refer to running migration truffle documentation.

Contract Testing: Contracts can be tested by writing the test cases in the following: Javascript and typescript, for exercising your contracts from the outside world, just like your application.

Solidity, for exercising your contracts in advanced, bare-to-the-metal scenarios.

To run the automated test cases defined in the test/ directory: 

$ truffle test

To know how to write test cases using truffle, follow the truffle testing documentation.

As now you have the basic idea about the Truffle framework, start working around with it and enjoy the ease of smart contract deployment and testing with just a few commands. 

To obtain a deeper knowledge and a better understanding of Smart Contract Audit and how it sustains the back-end functioning of delocalized systems just talk to our experts.

Site Categories

  • Accessibility Testing (29)
  • Automation Testing (27)
  • Banking Application Testing (2)
  • Blockchain (2)
  • Blogs (378)
  • Business (44)
  • Case Studies (37)
  • Cloud Testing (5)
  • Company (16)
  • Compatibility Testing (1)
  • DevLabs Expert Group (25)
  • DevOps (2)
  • Dot Net (27)
  • E-Learning testing (3)
  • Events (6)
  • Fun at Devlabs (1)
  • Functional Testing (4)
  • Healthcare App Testing (10)
  • Innovation (5)
  • Java (3)
  • Job Openings (31)
  • Mobile Testing (20)
  • News (144)
  • News & Updates (7)
  • Open Source (9)
  • Our-Team (9)
  • Performance Testing (24)
  • Press Releases (37)
  • QA Thought Leadership (3)
  • Salesforce App Development (2)
  • Security Testing (16)
  • Software Testing (37)
  • Testimonials (24)
  • Translation & Globalization Testing (10)
  • Uncategorized (3)
  • Usability Testing (1)
  • Webinars (26)
  • White Papers (35)
  • Popular
  • Recent
  • Tags
  • Zend Framework April 16, 2013
  • Effective Regression Testing Strategy for Localized Applications Effective Regression Testing Strategy for Localized Applications March 23, 2015
  • Moving from a commercial to an open source performance testing tool August 12, 2015
  • 3 Tier Architecture in .Net Framework March 21, 2013
  • Zend at QAIT Devlabs March 26, 2013
  • Key Focus Areas while Testing a Healthcare App Key Focus Areas while Testing a Healthcare App September 18, 2020
  • Need for the Right Performance Testing Strategy for your Mobile App Need for the Right Performance Testing Strategy for your Mobile App September 12, 2020
  • Key Points to Remember Before Starting Salesforce Customization Key Points to Remember Before Starting Salesforce Customization September 8, 2020
  • Top 5 Automation Testing Tools for Mobile Applications Top 5 Automation Testing Tools for Mobile Applications September 2, 2020
  • Improve Salesforce Application Performance Leveraging Platform Cache using Lightning Web Component Improve Salesforce Application Performance Leveraging Platform Cache using Lightning Web Component August 28, 2020
  • Jobs - 13
  • Hiring - 13
  • mobile app testing - 8
  • performance testing - 7
  • accessibility-testing - 6
  • #AccessibilityTesting - 6
  • #PerformanceTesting - 6
  • automation testing - 5
  • accessibility - 4
  • #PerformanceTestingServices - 4
  • Performance Testing Services - 4
  • mobile - 3
  • testing - 3
  • functional testing - 3
  • agile cycle - 3
  • DevOps - 3
  • performance - 3
  • software testing services - 3
  • data analytics - 3
  • #SoftwareTesting - 3
  • #TestAutomation - 3
  • #AppSecurity - 3
  • #SecureBankingApps - 3
  • #TestingBankingApplications - 3
  • #SoftwareTestingStrategy - 3

Site Archives

  • September 2020 (4)
  • August 2020 (9)
  • July 2020 (15)
  • June 2020 (9)
  • May 2020 (13)
  • April 2020 (13)
  • March 2020 (23)
  • February 2020 (7)
  • January 2020 (18)
  • December 2019 (9)
  • November 2019 (10)
  • October 2019 (8)
  • September 2019 (9)
  • August 2019 (6)
  • July 2019 (4)
  • June 2019 (7)
  • May 2019 (18)
  • April 2019 (15)
  • March 2019 (5)
  • February 2019 (1)
  • January 2019 (5)
  • December 2018 (3)
  • October 2018 (4)
  • August 2018 (4)
  • July 2018 (15)
  • June 2018 (1)
  • May 2018 (3)
  • April 2018 (7)
  • March 2018 (5)
  • February 2018 (15)
  • January 2018 (3)
  • December 2017 (8)
  • November 2017 (13)
  • October 2017 (19)
  • September 2017 (13)
  • August 2017 (11)
  • July 2017 (7)
  • June 2017 (6)
  • May 2017 (5)
  • April 2017 (2)
  • March 2017 (6)
  • January 2017 (3)
  • December 2016 (7)
  • October 2016 (3)
  • September 2016 (3)
  • August 2016 (6)
  • July 2016 (4)
  • June 2016 (3)
  • May 2016 (6)
  • April 2016 (3)
  • March 2016 (7)
  • February 2016 (3)
  • January 2016 (3)
  • December 2015 (20)
  • November 2015 (2)
  • October 2015 (28)
  • September 2015 (4)
  • August 2015 (2)
  • July 2015 (14)
  • June 2015 (2)
  • May 2015 (2)
  • April 2015 (5)
  • March 2015 (18)
  • February 2015 (11)
  • January 2015 (4)
  • December 2014 (3)
  • November 2014 (4)
  • October 2014 (6)
  • September 2014 (7)
  • August 2014 (6)
  • July 2014 (7)
  • June 2014 (6)
  • May 2014 (4)
  • April 2014 (7)
  • March 2014 (7)
  • February 2014 (8)
  • January 2014 (7)
  • December 2013 (3)
  • November 2013 (6)
  • October 2013 (6)
  • September 2013 (10)
  • August 2013 (3)
  • July 2013 (4)
  • June 2013 (6)
  • May 2013 (3)
  • April 2013 (12)
  • March 2013 (6)
  • February 2013 (2)
  • January 2013 (1)
  • December 2012 (2)
  • November 2012 (3)
  • October 2012 (3)
  • September 2012 (5)
  • August 2012 (2)
  • July 2012 (6)
  • June 2012 (1)
  • May 2012 (2)
  • April 2012 (3)
  • March 2012 (8)
  • February 2012 (4)
  • January 2012 (3)
  • December 2011 (1)
  • November 2011 (4)
  • October 2011 (3)
  • September 2011 (2)
  • August 2011 (3)
  • June 2011 (4)
  • May 2011 (1)
  • April 2011 (4)
  • February 2011 (1)
  • January 2011 (1)
  • October 2010 (2)
  • August 2010 (4)
  • July 2010 (2)
  • June 2010 (3)
  • May 2010 (3)
  • April 2010 (1)
  • March 2010 (5)
  • February 2010 (1)
  • January 2010 (2)
  • December 2009 (3)
  • November 2009 (1)
  • October 2009 (2)
  • July 2009 (1)
  • June 2009 (2)
  • May 2009 (2)
  • March 2009 (2)
  • February 2009 (4)
  • December 2008 (2)
  • November 2008 (1)
  • October 2008 (1)
  • September 2008 (1)
  • August 2008 (2)
  • May 2008 (1)
  • February 2008 (1)
  • September 2007 (1)
  • August 2007 (1)
  • May 2007 (2)
  • June 2006 (1)

Tag Cloud

#AccessibilityTesting #AppSecurity #AutomationTesting #MobileAppTesting #MobileTesting #PerformanceTesting #PerformanceTestingServices #SecureBankingApps #SoftwareTestAutomation #SoftwareTesting #SoftwareTestingStrategy #TestAutomation #TestingBankingApplications .NEt accessibility accessibility-testing agile cycle automation automation testing BigData cloud computing cloud testing data analytics DevOps education functional testing functional testing services globalization Hiring Jobs localization testing mobile mobile app testing Mobile Testing Offshore QA Testing performance performance testing Performance Testing Services Security testing services Selenium Test Automation software testing software testing services technology testing xAPI

Post Calendar

January 2021
MTWTFSS
« Sep  
 123
45678910
11121314151617
18192021222324
25262728293031

About QA InfoTech

Q A QA InfoTech is a C M M i CMMi Level III and I S O ISO 9001: 2015, I S O ISO 20000-1:2011, I S O ISO 27001:2013 certified company. We are one of the reputed outsourced Q A QA testing vendors with years of expertise helping clients across the globe. We have been ranked amongst the 100 Best Companies to work for in 2010 and 2011 & 50 Best Companies to work for in 2012 , Top 50 Best IT & IT-BMP organizations to work for in India in 2014, Best Companies to work for in IT & ITeS 2016 and a certified Great Place to Work in 2017-18. These are studies conducted by the Great Place to Work® Institute. View More

Get in Touch

Please use Tab key to navigate between different form fields.

This site is automatically   protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Services

  • Functional Testing
  • Automation Testing
  • Mobile Testing
  • Performance Testing
  • Accessibility Testing
  • Security Testing
  • Localization Testing
  • Cloud Testing
  • Quality Consulting

Useful Links

  • Blogs
  • Downloads
  • Case Studies
  • Webinars
  • Team
  • Pilot Testing
  • Careers
  • QA TV
  • Contact

Office Locations

Michigan, USA
Toronto, Canada
Noida, INDIA ( HQ )
Bengaluru, INDIA
Michigan, USA

  • 32985 Hamilton Court East, Suite 121, Farmington Hills, Michigan, 48334
  • +1-469-759-7848
  • info@qainfotech.com

Toronto, Canada

  • 6 Forest Laneway, North York, Ontario, M2N5X9
  • info@qainfotech.com

Noida, INDIA ( HQ )

  • A-8, Sector 68 Noida, Uttar Pradesh, 201309
  • +91-120-6101-805 / 806
  • info@qainfotech.com

Bengaluru, INDIA

  • RMZ Ecoworld, Outer Ring Road, Bellandur, Bengaluru, Karnataka, 560103
  • +91-95600-00079
  • info@qainfotech.com

Copyright ©2020 qainfotech.com. All rights reserved | Privacy Policy | Disclaimer

Scroll
QA InfoTech logo
  • About
    ▼
    • Team
    • Values and Culture
    • Overview
    • QA InfoTech Foundation
    • Careers
  • Services
    ▼
    • Software Development
      ▼
      • eLearning
      • Data Sciences
      • Accessibility Development
      • Mobility Solutions
      • Web Development
      • Front End Frameworks
      • Salesforce Development
      • Cloud Solutions
      • Enterprise Content Management
      • Odoo
      • ServiceNow
      • AS400
    • Functional Testing Services
    • Automation Testing Services & Tools
    • Mobile Testing Services
    • Performance Testing Services
    • Accessibility Testing Services
    • Usability Testing
    • Security Testing
    • Translation & Globalization Testing
    • Courseware & Content Testing
    • Crowdsourced Testing
    • Cloud Testing
    • Digital Assurance
    • Data Sciences and Analytics
    • SAP Testing
    • Selenium Test Automation
    • Blockchain Applications Testing
  • Verticals
    ▼
    • e-Learning
    • Health Care
    • Retail
    • Publishing
    • Media
    • Government
    • BFSI
    • Travel
    • OpenERP
  • Knowledge Center
    ▼
    • Case Studies
    • White Paper
    • Webinars
    • Blogs
  • WebinarsNew
  • News
    ▼
    • News
    • Press Release
  • Contact
  • Get a Quote
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Accept CookiesPrivacy policy