Skip to content

Instantly share code, notes, and snippets.

@13x54n
Created June 12, 2024 05:21
Show Gist options
  • Save 13x54n/d86c9926b9129bf0c0d9a9bc50a90f36 to your computer and use it in GitHub Desktop.
Save 13x54n/d86c9926b9129bf0c0d9a9bc50a90f36 to your computer and use it in GitHub Desktop.
ERC20 Token from OpenZeppelin.
#[starknet::contract]
mod MingToken {
use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
use starknet::ContractAddress;
component!(path: ERC20Component, storage: erc20, event: ERC20Event);
// ERC20 Mixin
#[abi(embed_v0)]
impl ERC20MixinImpl = ERC20Component::ERC20MixinImpl<ContractState>;
impl ERC20InternalImpl = ERC20Component::InternalImpl<ContractState>;
#[storage]
struct Storage {
#[substorage(v0)]
erc20: ERC20Component::Storage
}
#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
ERC20Event: ERC20Component::Event
}
#[constructor]
fn constructor(
ref self: ContractState,
recipient: ContractAddress
) {
let name = "Ming";
let symbol = "MNG";
self.erc20.initializer(name, symbol);
// @dev the decimals is 18
self.erc20._mint(recipient, 1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment