Emurgo / cardano-serialization-lib

This is a library, written in Rust, for serialization & deserialization of data structures used in Cardano's Haskell implementation of Alonzo along with useful utility functions.
Other
234 stars 125 forks source link

Using PLUTUS SCRIPT for minting? #481

Closed manupadillaph closed 1 year ago

manupadillaph commented 2 years ago

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

Are you considering to add this functionality?

manupadillaph commented 2 years ago

Any help, idea, news?

micahkendall commented 2 years ago

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.

lisicky commented 1 year ago

Plutus minting now available in the new CSL version 11.2.0

jinglescode commented 1 year ago

@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);