module test::token_factory {
use sui::coin::{Self, Coin, TreasuryCap};
use sui::tx_context::{Self, TxContext};
use sui::object::{UID};
/// Represents a managed token type
public struct TokenInfo has key, store {
id: UID,
symbol: vector<u8>,
name: vector<u8>,
decimals: u8
}
/// Generic token type created by the factory
public struct Token has drop {}
/// Initialize a new token and register it with a TreasuryCap
public fun create_token(
decimals: u8,
ctx: &mut TxContext
): TokenInfo {
let (treasury_cap, metadata) = coin::create_currency<Token>(
Token {},
decimals,
b"LST",
b"LST",
b"",
option::none(),
ctx
);
transfer::public_transfer(treasury_cap, ctx.sender());
transfer::public_freeze_object(metadata);
TokenInfo {
id: object::new(ctx),
symbol: b"LST",
name: b"LST",
decimals
}
}
/// Mint new tokens for the specified token type
public fun mint(
treasury_cap: &mut TreasuryCap<Token>,
amount: u64,
recipient: address,
ctx: &mut TxContext
) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}
/// Burn tokens of the specified token type
public fun burn(
treasury_cap: &mut TreasuryCap<Token>,
coin: Coin<Token>,
) {
coin::burn(treasury_cap, coin);
}
}
Hello everyone, when I call the create_token function here as below, I get the following error. What do you think is the reason?
// Call create_token to create a new token
txb.moveCall({
target: "0x421702371870f9d6dc0cfce61f55fa4faa932e09b90c3afe1ad5983a022a6e2c::token_factory::create_token",
arguments: [
txb.pure.u8(9), // Decimals
],
});
error: Dry run failed, could not automatically determine a budget: MoveAbort(MoveLocation { module: ModuleId { address: 0000000000000000000000000000000000000000000000000000000000000002, name: Identifier("coin") }, function: 16, instruction: 7, function_name: Some("create_currency") }, 0) in command 0