Skip to content

Instantly share code, notes, and snippets.

@jhaym3s
Last active February 4, 2023 14:33
Show Gist options
  • Save jhaym3s/20c8eb73c4b89e0e6033be08baeca8ea to your computer and use it in GitHub Desktop.
Save jhaym3s/20c8eb73c4b89e0e6033be08baeca8ea to your computer and use it in GitHub Desktop.
stable coin
pragma solidity ^0.8.13;
contract StableCoin {
// Properties
string public name;
string public symbol;
uint256 public totalSupply;
// Mapping of addresses to their token balances
mapping(address => uint256) public balances;
// Events
event Transfer(address indexed from, address indexed to, uint256 value);
// Functions
function StableCoin(string memory _name, string memory _symbol, uint256 _totalSupply) public {
name = _name;
symbol = _symbol;
totalSupply = _totalSupply;
balances[msg.sender] = totalSupply;
}
function transfer(address _to, uint256 _value) public {
require(balances[msg.sender] >= _value, "Not enough balance");
balances[msg.sender] -= _value;
balances[_to] += _value;
emit Transfer(msg.sender, _to, _value);
}
function supplyManagement() public {
// Code to manage the supply of the token
}
}
@jhaym3s
Copy link
Author

jhaym3s commented Feb 4, 2023

try 0.8.0 in this doesn't work
You can try on remix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment