Minting Tokens
1
Public Mint (plain uint256)
// Hardhat / ethers.js
const token = await hre.ethers.getContractAt("MyPrivateToken", tokenAddress);
const amount = hre.ethers.parseUnits("1000", 18); // 1000 tokens
const tx = await token.mint(recipientAddress, amount, { gasLimit: 5000000 });
await tx.wait();
console.log("Minted 1000 tokens to", recipientAddress);2
Encrypted Mint (itUint256)
const { prepareIT256 } = require("@coti-io/coti-sdk-typescript");
// Build the encrypted amount
const MINT_SELECTOR = ethers.id("mint(address,((uint256,uint256),bytes))").slice(0, 10);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, ethers.provider);
const it = prepareIT256(
BigInt(hre.ethers.parseUnits("500", 18)), // 500 tokens
{ wallet, userKey: process.env.PRIVATE_AES_KEY_TESTNET },
tokenAddress,
MINT_SELECTOR
);
const tx = await token.connect(minterSigner)["mint(address,((uint256,uint256),bytes))"](
recipientAddress,
[[it.ciphertext.ciphertextHigh, it.ciphertext.ciphertextLow], it.signature],
{ gasLimit: 5000000 }
);
await tx.wait();Last updated
Was this helpful?