Last active
December 15, 2023 12:37
-
-
Save hughpearse/d03f00b5fd7683ed5015c8bed91e5b25 to your computer and use it in GitHub Desktop.
Openzeppelin solidity smart contract for HughCoin tokens pegged to ETH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
// Author: Hugh Pearse | |
pragma solidity ^0.8.20; | |
import {ERC20} from "@openzeppelin/[email protected]/token/ERC20/ERC20.sol"; | |
/// @custom:security-contact [email protected] | |
contract HughCoin is ERC20 { | |
address public owner; | |
constructor() | |
ERC20("HughCoin", "HUGH") | |
{ | |
owner = msg.sender; | |
} | |
function deposit() public payable { | |
require(msg.value > 0, "Deposit value must be greater than 0"); | |
_mint(msg.sender, msg.value); | |
} | |
function withdraw(uint256 amount) public { | |
require(balanceOf(msg.sender) >= amount, "Not enough tokens to withdraw"); | |
_burn(msg.sender, amount); | |
payable(msg.sender).transfer(amount); | |
} | |
receive() external payable { | |
deposit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sepolia Test Network
Arbitrum Goerli Test Network
Arbitrum Sepolia Test Network
Token - https://sepolia.arbiscan.io/token/0xC5b1bF53F36a099106A8a6FeE12540d91f10EA56
Contract - https://sepolia.arbiscan.io/address/0xC5b1bF53F36a099106A8a6FeE12540d91f10EA56
Arbitrum One Main Network