Smart Contracts

Smart contract is a program that runs on blockchain. When using smart contract you can mint or burn tokens, own tokens or just create your “backend” application for a Dapp (decentralised application).

What a Smart Contract can do on Blockchain

A smart contract is used to manage tokens, to create your own currency tokens like Ether from Ethereum following the ERC-20 specification (you can even create an NFT token, following ERC-721 specification to sell on OpenSea, for example). You can even write a program to request a loan on DeFi (decentralised finance) or you can just create functionality for your front end.

What is required to write a smart contract

You can apply your own specifications to each network. When you’re writing a smart contract you need to know which network you want to deploy it to, if you want to use Ethereum or Avalanche, for example. You can use Solidity language, but for Solana Network you need to use Rust lang. We recommend that you read the specific network documentation to create your own smart contract.

 What tools are required

To create a smart contract for an Ethereum network there are some tools to help you:

·       Remix ide tool (https://remix.ethereum.org/#optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.7+commit.e28d00a7.js) IDE to write code on browser

·       Ganache - to emulate an Ethereum network in your local machine

·       Truffle - cli tool to handle migration and deploy your code (you can also just use remix).


Solidity Syntax.

Solidity has a syntax similar to Javascript. You can test using mocha, for example, and use it with NPM as well. Here is the solidity syntax:

```js
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MyContract {
    function helloWorld() public pure returns (string memory) {
        return "Hello, World!";
    }
}
```

Side note

Once your smart contract is deployed on blockchain it is visible on ledger and anyone can see the code  you wrote. If you have a contract address you can check it here (https://etherscan.io).

TLDR

Smart contract is an amazing way to create automations on blockchain and provide an interface for web applications, depending of your use case, smart contract can be a backend application or it can interact with tokens where basically it can send and receive valuable tokens.

 References:

·       Solidity documentation - https://docs.soliditylang.org/en/v0.8.10/

·       Remix IDE documentation - https://remix-ide.readthedocs.io/en/latest/

·       Ethereum documentation - https://ethereum.org/en/developers/docs/

Written by Lucas Rodrigues

Guest User