Created
April 21, 2025 19:05
-
-
Save goodylili/0373f19fcffb79cee56cca839653b1a6 to your computer and use it in GitHub Desktop.
basic coin on the Sui Network
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
module impatient::goodylili; | |
use sui::coin::{Self, TreasuryCap}; | |
use sui::url; | |
public struct GOODYLILI has drop {} | |
fun init(witness: GOODYLILI, ctx: &mut TxContext) { | |
// Create the icon URL | |
let icon_url = url::new_unsafe_from_bytes(b"https://framerusercontent.com/images/0KKocValgAmB9XHzcFI6tALxGGQ.jpg"); | |
let decimals: u8 = 8; | |
// Fixed multiplier for 8 decimals (10^8) | |
let multiplier = 100000000; // 10^8 | |
// Create the currency - make treasury mutable | |
let (mut treasury, metadata) = coin::create_currency( | |
witness, | |
decimals, | |
b"GOODYLILI", | |
b"GOODYLILI ON SUI", | |
b"Goodylili Taught Sui. Here's proof", | |
option::some(icon_url), | |
ctx, | |
); | |
// Mint 300 tokens (300 * 10^8 base units) | |
let initial_coins = coin::mint(&mut treasury, 300 * multiplier, ctx); | |
transfer::public_transfer(initial_coins, tx_context::sender(ctx)); | |
transfer::public_freeze_object(metadata); | |
transfer::public_transfer(treasury, tx_context::sender(ctx)); | |
} | |
public entry fun mint( | |
treasury_cap: &mut TreasuryCap<GOODYLILI>, | |
amount: u64, | |
recipient: address, | |
ctx: &mut TxContext, | |
) { | |
let coin = coin::mint(treasury_cap, amount, ctx); | |
transfer::public_transfer(coin, recipient); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment