Skip to content

Instantly share code, notes, and snippets.

@PowerStream3604
Last active October 16, 2021 07:03
Show Gist options
  • Save PowerStream3604/e4d64f315cbe4a6f5e85e88ed6024404 to your computer and use it in GitHub Desktop.
Save PowerStream3604/e4d64f315cbe4a6f5e85e88ed6024404 to your computer and use it in GitHub Desktop.

Complete tutorial of Unit Testing Ploygon Smart Contract with Truffle Framework

Overview of the tutorial

  • I am writing this tutorial to help other developers to implement a thorough test for Smart Contracts on Polygon.
  • We'll learn how to implement a smart-contract from scratch and unit test them using Truffle
  • This tutorials goal is to help developers to get a deep understanding of how unit testing works with Smart Contract on Polygon Network as a developer.

What we'll do in the tutorial.

  • Write our own Smart Contract for testing with solidity.
  • Compile & Deploy them with Truffle.
  • Unit test each functionalities of the Smart Contract with Truffle-Assertion.

We'll explore each of the Smart Contract functionalities and unit test each of them using the Truffle Framework.

Steps to unit testing a Smart Contract

  • Deploy the Smart Contract
  • Make Contract calls or transactions to alter the state of the Contract.
  • Check if the altered contract state is what we expected using the Truffle-Assertion library.
  • If the Contract works correctly, we'll set the result of the test to be true.
  • If the Contract doesn't work correctly, we'll set the result of the test to be false.

Who is this tutorial for?

  • This tutorial is for developers who have some knowledge about Truffle Framework and Solidity.
  • It's good for readers to have prior knowlege about Truffle Framework and Ethereum network.

This tutorial contains

  • [o] Smart Contract
  • [o] Front-End (javascript)

Protocol/Network

  • [o] Polygon(Matic)

Difficulty Level of the Tutorial

  • [o] Advanced

Previous Work

  1. EIP 3602 Fractional-NFT with on-chain Royalty Distribution system
  2. Ethereum Foundation Tutorial : Sending tokens & Predicting gas price with Ethers.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment