1.20.3 • Published 3 years ago

@mutants/cardano v1.20.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Mutants Cardano BETA

This library is an alternative to the cardano-serialization-lib and does not require your app to load WebAssembly code.

Sample transaction

In this transaction, the seller is sending a Mutant Croc NFT to our Marketplace validator, including a datum.

import {
  UTXOS,
  AssetUtils,
  RequiredInputs,
  RequiredOutputs,
  TransactionBuilder,
} from "@mutants/cardano";

// This is the asset the seller is going to send to our validator.
const mutantCrocAsset = {
    unit: "d517f38dd2c5acc3347c8e933e2c0185fafe3ba838f8830000a3c95f44724361726f6e6f566163696e75733030303030",
    quantity: "1" 
};

const estimateFee = 500000;
const sellerAddress = "addr1..." // Here you define the NFT seller payment address

// Here we calculate the min ADA required to be attached to the NFT
const minAdaUtxo = UTXOS.calculateMinMultiassetCost(
    AssetUtils.fromAssetsToPolicyMap([mutantCrocAsset])
);

// Here we define the seller required inputs. In order to send the NFT to the validator, we need to consume the NFT utxo,
// so we add the token, the min ADA that needs to be attached to it and an estimate fee (fee will be recalculated later)
const requiredInputs: RequiredInputs = {
    [sellerAddress]: {
        totalCoin: requiredUtxoADA + estimateFee,
        tokens: inputToken,
    },
};

// Here we define the required outputs. Since we want to send our NFT to our validator, we use the validator address here
// and determine that an output should be created with the Mutant NFT asset plus the minimum ADA required to be attached to that NFT.
// We also add the datum here, that will be used in our Plutus validator.
// In this case the datum has only 2 fields but ofc this would change depending in your validator script.
const datum = {
    constructor: 0,
    fields: [
      {
        bytes: seller,
      },
      {
        int: price,
      }
    ]
};

const requiredOutputs: RequiredOutputs = {
    [validator.address]: {
        totalCoin: minAdaUtxo,
        tokens: [mutantCrocAsset],
        datum,
    },
};
1.19.0

3 years ago

1.19.2

3 years ago

1.19.1

3 years ago

1.20.1

3 years ago

1.20.2

3 years ago

1.20.0

3 years ago

1.20.3

3 years ago

1.18.1

3 years ago

1.16.3

3 years ago

1.18.0

3 years ago

1.18.5

3 years ago

1.18.4

3 years ago

1.18.3

3 years ago

1.18.2

3 years ago

1.17.2

3 years ago

1.17.1

3 years ago

1.17.0

3 years ago

1.17.6

3 years ago

1.17.5

3 years ago

1.17.4

3 years ago

1.17.3

3 years ago

1.16.2

3 years ago

1.16.1

3 years ago

1.16.0

3 years ago

1.15.1

3 years ago

1.15.0

3 years ago

1.14.1

3 years ago

1.14.0

3 years ago

1.13.0

3 years ago

1.12.0

3 years ago

1.11.1

3 years ago

1.11.0

3 years ago

1.10.0

3 years ago

1.9.0

3 years ago

1.8.11

3 years ago

1.8.10

3 years ago

1.8.9

3 years ago

1.8.8

3 years ago

1.8.7

3 years ago

1.8.6

3 years ago

1.8.5

3 years ago

1.8.4

3 years ago

1.8.3

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.5

3 years ago

1.7.4

3 years ago

1.7.3

3 years ago

1.7.2

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.5.10

3 years ago

1.5.8

3 years ago

1.5.7

3 years ago

1.5.6

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago