Deploy - tx

Deploy a new 𝔉rc20 token

Example of Fixes Inscription data string:

op=deploy,tick=fixes,max=1000000000.0,limit=1000.0,burnable=1

Transaction parameters:

Key
Required
FType
Description

tick

t.String

Ticker: identity of the 𝔉rc20 token

max

t.UFix64

Max supply: Set max supply of the 𝔉rc20 token

limit

t.UFix64

Mint limit: limit per inscription

burnable

t.Bool

Is this 𝔉rc20 a burnable inscription.

Recommended to set it as true.

Transaction code example:

import txDeployFRC20 from "@fixes/contracts/transactions/deploy-frc20.cdc?raw";

interface TokenMetaDto {
  tick: string;
  max: number;
  limit: number;
  burnable: boolean;
}

async function deploy(token: TokenMetaDto) {
  return await flow.sendTransaction(txDeployFRC20, (arg, t) => [
      arg(token.tick, t.String),
      arg(token.max.toFixed(8), t.UFix64),
      arg(token.limit.toFixed(8), t.UFix64),
      arg(token.burnable, t.Bool),
  ]);
}

Transaction source code

https://github.com/fixes-world/fixes/blob/main/cadence/transactions/deploy-frc20.cdc
import "FungibleToken"
import "FlowToken"

import "Fixes"
import "FRC20Indexer"
import "FixesInscriptionFactory"

transaction(
    tick: String,
    max: UFix64,
    limit: UFix64,
    burnable: Bool,
) {
    let ins: auth(Fixes.Extractable) &Fixes.Inscription

    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 -------------------------------------------------- */

        // build data string
        let dataStr = FixesInscriptionFactory.buildDeployFRC20(tick: tick, max: max, limit: limit, burnable: burnable)

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

        // 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!")

        // Withdraw tokens from the signer's stored vault
        let flowToReserve <- vaultRef.withdraw(amount: estimatedReqValue)

        // Create the Inscription first
        let newInsId = FixesInscriptionFactory.createAndStoreFrc20Inscription(
            dataStr,
            <- (flowToReserve as! @FlowToken.Vault),
            store
        )

        // borrow a reference to the new Inscription
        self.ins = store.borrowInscriptionWritableRef(newInsId)
            ?? panic("Could not borrow a reference to the new Inscription!")
    }

    execute {
        let indexer = FRC20Indexer.getIndexer()
        indexer.deploy(ins: self.ins)
    }
}

Last updated