Skip to content

add mint to command#10

Merged
gitteri merged 2 commits intomainfrom
cli-mint-to
Jul 29, 2025
Merged

add mint to command#10
gitteri merged 2 commits intomainfrom
cli-mint-to

Conversation

@gitteri
Copy link
Copy Markdown
Collaborator

@gitteri gitteri commented Jul 29, 2025

Mint Command Implementation

SDK Layer (packages/sdk/src/management/mint.ts)

  • createMintToTransaction() - Creates a transaction to mint tokens to a recipient's ATA
  • decimalAmountToRaw() - Converts decimal amounts to raw token amounts based on decimals
  • getMintInfo() - Retrieves mint information including decimals from the blockchain
  • Automatically creates the Associated Token Account (ATA) if it doesn't exist
  • Uses Token-2022 program throughout

CLI Layer (packages/cli/src/commands/mint.ts)

  • Command format: mosaic mint -m -r -a
  • Arguments:
    • mint-address: The token mint address
    • recipient: The wallet address that will own the ATA
    • amount: Decimal amount (e.g., 1.5) that gets converted to raw units
  • Uses the configured Solana keypair as the mint authority (assumes you have mint authority)
  • Provides comprehensive output showing both decimal and raw amounts

Key Features:

  1. Automatic ATA handling - Creates recipient's ATA if it doesn't exist
  2. Decimal conversion - Automatically converts decimal amounts to raw amounts based on mint's decimals
  3. Token-2022 support - Uses TOKEN_2022_PROGRAM_ADDRESS throughout
  4. Consistent CLI patterns - Follows same error handling, spinner, and output patterns as create commands
  5. Keypair integration - Uses Solana CLI config for mint authority

Usage Examples:

Mint 10.5 tokens to a recipient

mosaic mint -m EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -r 9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM -a 10.5

Mint with custom RPC

mosaic mint --rpc-url https://api.mainnet-beta.solana.com -m EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -r 9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM -a100

Mint with custom keypair

mosaic mint --keypair ~/.config/solana/mint-authority.json -m <mint> -r <recipient> -a 50.25

The command automatically:

  • Fetches mint info to get the correct decimals
  • Converts the decimal amount to raw units (e.g., 1.5 with 6 decimals becomes 1,500,000)
  • Creates the recipient's ATA if needed
  • Mints the tokens
  • Shows detailed success information including both decimal and raw amounts

Important

Adds a CLI command to mint tokens, with SDK support for transaction creation and decimal conversion.

  • CLI:
    • Adds mintCommand in mint.ts to mint tokens to a recipient's ATA.
    • Command: mosaic mint -m <mint-address> -r <recipient> -a <amount>.
    • Handles automatic ATA creation and uses Solana keypair for mint authority.
  • SDK:
    • Adds createMintToTransaction() and getMintInfo() in mint.ts for transaction creation and mint info retrieval.
    • Implements decimalAmountToRaw() in transactionUtil.ts for decimal to raw amount conversion.
  • Integration:
    • Integrates mintCommand into CLI in index.ts.
    • Exports new functions in sdk/src/index.ts.

This description was created by Ellipsis for e4d4e1a. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Copy Markdown
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Changes requested ❌

Reviewed everything up to 6ec47c9 in 1 minute and 39 seconds. Click for details.
  • Reviewed 296 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/cli/src/commands/mint.ts:73
  • Draft comment:
    Confirm that using the same keypair for mint authority and fee payer is intentional; consider offering an option for a separate fee payer if needed.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% This comment violates several rules: 1) It asks for confirmation of intention ("Confirm that...") 2) It's speculative about future needs ("consider offering an option...") 3) The code comment already acknowledges this is intentional 4) There's no evidence this is problematic or needs changing. Perhaps having separate keypairs is a common security practice in Solana, and this comment is raising a valid architectural concern? Even if separate keypairs might be beneficial, the comment is still asking for confirmation rather than pointing out a clear issue, and it's speculative about future needs. Delete the comment as it violates rules about asking for confirmation and making speculative suggestions without clear evidence of an issue.
2. packages/sdk/src/transactionUtil.ts:62
  • Draft comment:
    Using Math.floor on floating-point multiplication may lead to precision issues for large values; consider using a precise arithmetic library if high precision is required.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% Given that decimals are limited to 0-9, the maximum multiplier would be 10^9. JavaScript numbers can safely handle integers up to 2^53-1 (about 9 quadrillion), which is more than enough precision for 9 decimal places. The use case appears to be for token amounts, where extreme precision beyond 9 decimals is unlikely to be needed. The comment raises a theoretically valid concern about floating point precision. There could be edge cases with very large numbers that I haven't considered. The decimal limit of 0-9 effectively prevents any realistic precision issues, and token amounts rarely need more precision than this provides. The comment should be deleted as it raises a theoretical concern that isn't practically relevant given the constraints of the code.

Workflow ID: wflow_tkCTQD4rFjVLC6sU

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Copy Markdown
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed e4d4e1a in 33 seconds. Click for details.
  • Reviewed 12 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/sdk/src/management/mint.ts:41
  • Draft comment:
    Good removal of the debug log. Consider using a configurable debug logger if this information is needed in development.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_BQPTEmJ0ouGUtXsW

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@gitteri gitteri merged commit 035d05e into main Jul 29, 2025
2 checks passed
@gitteri gitteri deleted the cli-mint-to branch July 29, 2025 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant