Guide to Writing and Deploying your First Smart Contract – Polygon Guild Ilorin Talk

I was invited to speak at the Polygon Guild Ilorin event. My talk was about writing and deploying your first smart contract.

Taking you on the journey from Abuja to Ilorin so you can share my pain lol. I missed my flight due to traffic on the morning of Friday 7th, July. For the love of community, I chose to travel by road (10hrs+), it wasn’t a comfortable journey but, to God be the glory, Ilorin was glad to have me.

I was welcomed by the guild lead, Hakeem, who took me for dinner and drove me to the hotel to rest. I had a hot water bath and went through my slide to make sure all is ok and good to go (End of the first night).

The next morning, I was very tired but had to get up to prepare for the event, wore a Native dress, and head out to a cafe to have my breakfast (Plantain and fried fish). After eating, took a bolt ride to the event venue. [that was my travel pain and enjoyment]

Next, my talk time… Enjoy my talk.

slide title page

I introduced the attendees to Smart contract as a self-executing digital contract that is encoded with predefined rules and conditions.

The purpose of a smart contract
  1. Automate and enforce the execution of agreements without an intermediary.
  2. Enabling trust, transparency, & efficiency in various types of transactions & interactions
The Importance of a smart contract
  1. Automation
  2. Transparency
  3. Security
  4. Potential for Innovation

When explaining innovation, I used developer DAO (D_D) as an example. Below is an excerpt:

A DAO is a decentralized autonomous organization, a type of bottom-up entity structure with no central authority. Members of a DAO own tokens of the DAO, and members can vote on initiatives for the entity. e.g: D_D
Choosing a Blockchain to Build On

I move on to talk about how to select a blockchain to build on based on the platform (Private Blockchain e.g Hyperledger Fabric.; Public blockchain e.g Ethereum.; Hybrid Blockchain e.g EOS, Avalanche) and criteria (scalability, security, dev tools and resources, and cost consideration).

Setting up an Environment for Writing a Smart Contract

Setting up a development environment for writing and deploying smart contracts involves several steps and requires specific tools and frameworks. Below are some:

  1. A code editor
  2. Node & NPM
  3. Solidity Compiler (`npm i -g solc`)
  4. Testing Framework (Truffle, Hardhat, Remix)
  5. Development Blockchain (for local development and testing. E.g Ganache)
  6. IDE (Remix) allows you to compile, debug & deploy your smart contracts.
  7. Set up project structure
  8. Initialize the project
  9. Install dependencies
  10. Write your contract
  11. Test & Deploy
What now is Solidity?

Solidity is a high-level programming language specifically designed for writing smart contracts on the Ethereum platform. It is statically typed and supports inheritance, libraries, and complex user-defined types.

A Solidity smart contract begins with the contract keyword followed by the contract’s name. The Contract body is enclosed in curly braces {}.

More on Solidity

Solidity allows the declaration of state variables and local variables. State variables store data persistently on the blockchain, while local variables are temporary and exist only within a function’s scope. 

Functions in Solidity can be defined as external, public, private, or internal, specifying their visibility and accessibility. External functions are meant to be called from outside the contract, while public functions can be accessed both internally and externally. Private and internal functions are restricted to internal contract use. 

Events are a way to emit information from a smart contract. They allow external applications to listen for and react to specific occurrences on the blockchain. 

Smart Contract Use Cases
  • Defi
  • Real Estate
  • Intelectual Property
  • Identity Management etc.

I shared a few resources that can help them in the journey to become a smart contract developer and move to a demo. I was able to practicalize writing a sample contract using Remix and also using their code editor and deploying with hardhat.

If you prefer the slide, here is a link to it (Slide).

Thank you for reading, comment and support is welcome.