FT & Loyalty Module

Fungible tokens are used to enable seamless interchangeability and uniform value representation

One of the most important assets on blockchain is fungible tokens or FT. Here, we made deploying and distributing FT easy.

Deploy FT Contract

const ftDeploy = async () => {
  const decimals = 18;
  const totalSupply = "100000000000000000000000";
  const res = await client.client.ft.ftDeploy(
    (user as any)?.account_id,
    totalSupply,
    {
      spec: "ft-1.0.0",
      name: "FT Tutorial Contract",
      symbol: "GOTEAM",
      decimals: decimals,
      icon: null,
      reference: null,
      reference_hash: null,
    }
  );
  console.log("res", res);
};

Transfer FT

After you have deployed the FT contract, you might want to reward your loyal members, you can go with this code.

const ftTransfer = async () => {
  const receiverId = "cymac.testnet"
  const amount = "1000000000000000000"

  const res = await client.client.ft.ftTransfer(
    (user as any)?.account_id,
    receiverId,
    amount,
    null
  )

  console.log(res)
}

Get balance

const getBalance = async () => {
  const friendAccountId = "cymac.testnet"

  const res = await client.client.ft.ftBalanceOf(
    (user as any)?.account_id,
    friendAccountId      
  )
  console.log(res)
}

Get metadata

const getFtMetadata = async () => {
  const res = await client.client.ft.ftMetadata(
    (user as any)?.account_id,
  )
  console.log(res)
}

Get Total Supply

const getTotalSupply = async () => {
  const res = await client.client.ft.ftTotalSupply(
    (user as any)?.account_id,
  )
  console.log(res)
}

Last updated