Fixes World
Github
  • 💡What is Fixes?
  • 📓Concepts
    • 🔡Fixes Inscription
    • 💹Fixes Coins
      • Guide 1: How to Launch a new Coin?
    • 🎟️Lottery Game
    • 👻𝔉rc20s
    • 📔Token List
      • 📘Query TokenList
      • 📙Query Reviewers
  • 👨‍💻Developer
    • On-chain Interactions
      • 🔯𝔉rc20
        • Deploy - tx
        • Mint(batch) - tx
        • Transfer - tx
        • Burn - tx
        • List for Sale - tx
        • Take list as buyer - tx
        • List for Purchase - tx
        • Take list as seller - tx
        • Cancel Listing - tx
      • 🔡Fixes Inscription
        • EstimateCost - read
    • Open API Service
      • 🔯𝔉rc20 Basics
        • Query 𝔉rc20 Tokens
        • Fetch 𝔉rc20 Token Info
        • Check 𝔉rc20 registered
        • Get 𝔉rc20 balances
        • Get 𝔉rc20 balance
      • 🛒𝔉rc20 Marketplace
        • Query all 𝔉rc20 Markets
        • Fetch 𝔉rc20 Market detailed info
        • Check 𝔉rc20 Market enabled
        • Query 𝔉rc20 Listings
        • Query Market Trading History
        • Query Address Trading History
      • 🔧Utilities
        • Estimate Fixes inscribing cost
        • Get current $FLOW price
      • 📃Legal Disclaimer
  • 🔗LINKS
    • Official Website
    • Linktree
Powered by GitBook
On this page
Edit on GitHub
  1. Developer
  2. On-chain Interactions
  3. 𝔉rc20

Mint(batch) - tx

Mint 𝔉rc20 token

Example of Fixes Inscription data string:

op=mint,tick=fixes,amt=1000.0

Transaction parameters:

Key
Required
FType
Description

tick

t.String

Ticker: identity of the 𝔉rc20 token

amt

t.UFix64

Amount to mint: States the amount of the 𝔉rc20 token to mint. Has to be less or equal to "limit"

repeats

t.UInt64

How many times to repeat the mint action. Better less than or equal to 100 times.

Transaction code example:

import txBatchMintFRC20 from "@fixes/contracts/transactions/batch-mint-frc20.cdc?raw";
import txMintFRC20 from "@fixes/contracts/transactions/mint-frc20.cdc?raw";

async function mint(
  tick: string,
  amt: number,
  repeats: number = 1
) {
  let txid: string;
  if (repeats > 1) {
    txid = await flow.sendTransaction(txBatchMintFRC20, (arg, t) => [
      arg(tick, t.String),
      arg(amt.toFixed(8), t.UFix64),
      arg(repeats, t.UInt64),
    ]);
  } else {
    txid = await flow.sendTransaction(txMintFRC20, (arg, t) => [
      arg(tick, t.String),
      arg(amt.toFixed(8), t.UFix64),
    ]);
  }
  return txid;
}

Transaction source code

Or mint simple inscription

Related docs

  • EstimateCost - read

PreviousDeploy - txNextTransfer - tx

Last updated 1 year ago

👨‍💻
🔯
https://github.com/fixes-world/fixes/blob/main/cadence/transactions/mint-frc20.cdc
How to send a transaction to Flow blockchain or query data from Flow blockchain?
https://github.com/fixes-world/fixes/blob/main/cadence/transactions/batch-mint-frc20.cdc
import "FungibleToken"
import "FlowToken"
import "FRC20Indexer"
import "Fixes"
import "FixesInscriptionFactory"

transaction(
    tick: String,
    amt: UFix64,
    repeats: UInt64
) {
    prepare(acct: auth(Storage, Capabilities) &Account) {
        /** ------------- Prepare the Inscription Store - Start ---------------- */
        let storePath = Fixes.getFixesStoreStoragePath()
        if acct.storage
            .borrow<auth(Fixes.Manage) &Fixes.InscriptionsStore>(from: storePath) == nil {
            acct.storage.save(<- Fixes.createInscriptionsStore(), to: storePath)
        }

        let store = acct.storage
            .borrow<auth(Fixes.Manage) &Fixes.InscriptionsStore>(from: storePath)
            ?? panic("Could not borrow a reference to the Inscriptions Store!")
        /** ------------- End -------------------------------------------------- */

        // Get a reference to the signer's stored vault
        let vaultRef = acct.storage
            .borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault)
        ?? panic("Could not borrow reference to the owner's Vault!")

        // Get a reference to the Fixes Indexer
        let indexer = FRC20Indexer.getIndexer()
        let tokenMeta = indexer.getTokenMeta(tick: tick)
        assert(tokenMeta != nil, message: "TokenMeta for tick ".concat(tick).concat(" does not exist!"))

        let insDataStr = FixesInscriptionFactory.buildMintFRC20(tick: tick, amt: amt)

        var i = 0 as UInt64
        while i < repeats {
            i = i + 1

            let tokenMeta = indexer.getTokenMeta(tick: tick)
            if tokenMeta!.max == tokenMeta!.supplied {
                break
            }

            // estimate the required storage
            let estimatedReqValue = FixesInscriptionFactory.estimateFrc20InsribeCost(insDataStr)

            // get reserved cost
            let flowToReserve <- (vaultRef.withdraw(amount: estimatedReqValue) as! @FlowToken.Vault)

            // Create the Inscription first
            let newInsId = FixesInscriptionFactory.createAndStoreFrc20Inscription(
                insDataStr,
                <- flowToReserve,
                store
            )

            // borrow a reference to the new Inscription
            let insRef = store.borrowInscriptionWritableRef(newInsId)
                ?? panic("Could not borrow a reference to the newly created Inscription!")

            /// Mint the FRC20 token
            indexer.mint(ins: insRef)
        }
    }
}