Implementing a Token Contract using Solidity

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • openzeppelin-contracts

    OpenZeppelin Contracts is a library for secure smart contract development.

  • `pragma solidity ^0.8.17; import "https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/math/SafeMath.sol"; contract Token is SafeERC20 { using SafeMath for uint256; // The name of the token string public name; // The symbol of the token string public symbol; // The number of decimal places for the token uint8 public decimals; // The total supply of the token uint256 public totalSupply; // Mapping from addresses to their token balance mapping (address => uint256) public balanceOf; // Event for when tokens are transferred event Transfer(address indexed from, address indexed to, uint256 value); // Initialize the token with a name, symbol, and number of decimal places constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _totalSupply) public { require(_totalSupply <= 2**256 - 1); // check totalSupply within range require(_decimals <= 18); // check decimal places within range name = _name; symbol = _symbol; decimals = _decimals; totalSupply = _totalSupply; balanceOf[msg.sender] = _totalSupply; } // Transfer tokens from one address to another function transfer(address payable _to, uint256 _value) public { require(_to != address(0)); // check recipient address is not the null address require(_value > 0); // check value is greater than 0 require(balanceOf[msg.sender] >= _value); // check sender has sufficient balance balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); // decrease sender balance balanceOf[_to] = balanceOf[_to].add(_value); // increase recipient balance emit Transfer(msg.sender, _to, _value); } function mint(address _to, uint256 _amount) public onlyOwner { require(_amount > 0); totalSupply = totalSupply.add(_amount); balanceOf[_to] = balanceOf[_to].add(_amount); emit Transfer(address(0), _to, _amount); } modifier onlyOwner { require(msg.sender == owner); _; } address public owner; } `

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts