Our great sponsors
-
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.
`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; } `
Related posts
- Fork mainnet using hardhat to test and build on DeFi protocols and more
- Generating Decentralized identifier using ERC725 and ERC735
- “Every company will have an nft strategy” - Gary Vee Gary V explains why every company will implement in nft strategy in the next decade. Not every nft will be the next big then but they will still be very useful because the technology is so great. Do you agree with Gary?
- Question about implementing a UUPS proxy
- Kromatika DEX Automates Uniswap V3