cardano-serialization-lib icon indicating copy to clipboard operation
cardano-serialization-lib copied to clipboard

Using PLUTUS SCRIPT for minting?

Open manupadillaph opened this issue 3 years ago • 2 comments

I coulnt find a way to use PLUTUS SCRIPTS for Minting.

https://cardano.stackexchange.com/questions/5980/mint-tokens-using-plutus-scripts-with-the-serialization-lib/8664#8664

I found in the examples a way to do it with Navite Scripts using add_mint_asset_and_output method:

add_mint_asset_and_output(policy_script: NativeScript, asset_name: AssetName, amount: Int, output_builder: TransactionOutputAmountBuilder, output_coin: BigNum): void; /**

  • Add a mint entry together with an output to this builder
  • Using a PolicyID, AssetName, Int for amount, and Address objects
  • The asset will be securely added to existing or new Mint in this builder
  • A new output will be added with the specified Address and the minted asset
  • The output will be set to contain the minimum required amount of Coin
  • @param {NativeScript} policy_script
  • @param {AssetName} asset_name
  • @param {Int} amount
  • @param {TransactionOutputAmountBuilder} output_builder

Are you considering to add this functionality?

manupadillaph avatar Jul 16 '22 05:07 manupadillaph

Any help, idea, news?

manupadillaph avatar Aug 03 '22 18:08 manupadillaph

I've looked around trying to do the same thing, as far as I can tell there are no existing functionality for plutus scripts, only 'cardano native scripts' which are different.

micahkendall avatar Aug 05 '22 03:08 micahkendall

Plutus minting now available in the new CSL version 11.2.0

lisicky avatar Dec 08 '22 22:12 lisicky

@manupadillaph @micahkendall, Mesh latest update and working with CSL (thanks @lisicky for deploying 11.2), allows you to do minting assets with Plutus script, and you can do it like this (see docs):

import { Transaction } from '@meshsdk/core';
import { AssetMetadata, Mint, Action, PlutusScript } from '@meshsdk/core';

const script: PlutusScript = {
  code: plutusMintingScriptCbor,
  version: 'V2',
};

const redeemer: Partial<Action> = {
  tag: 'MINT',
};

const tx = new Transaction({ initiator: wallet });

// define asset#1 metadata
const assetMetadata1: AssetMetadata = {
  "name": "Mesh Token",
  "image": "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
  "mediaType": "image/jpg",
  "description": "This NFT is minted by Mesh (https://meshjs.dev/)."
};
const asset1: Mint = {
  assetName: 'MeshToken',
  assetQuantity: '1',
  metadata: assetMetadata1,
  label: '721',
  recipient: 'addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr',
};
tx.mintAsset(
  script,
  asset1,
  redeemer,
);

const unsignedTx = await tx.build();
const signedTx = await wallet.signTx(unsignedTx);
const txHash = await wallet.submitTx(signedTx);

jinglescode avatar Dec 25 '22 02:12 jinglescode