MeshJS / mesh

TypeScript open-source library to advance Web3 development on Cardano

Home Page:https://meshjs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add sample to lock the policy when minting assets

ggcaponetto opened this issue · comments

The current samples shows the minting of assets with no policy locking.

How would one achieve policy locking?

Digging deeper, I discovered that I can add the expiry to the forgeScript . In order to do this, the csl library should be exposed by the module, but it is not, I guess.

Any advice is appreciated!

ForgeScript provide a factory method called fromNativeScript you can use it to pass a JSON NativeScript object in case the already provided factories aren't enough to fulfill your requirements. we also export a type called NativeScript you can import it using import type { NativeScript } from '@martifylabs/mesh' you can use it to make sure the script you are passing is valid

Hi @ggcaponetto,
you can include NativeScript to define the forging script (for example if you want to have a policy locking script), you can do this:

import type { NativeScript } from '@martifylabs/mesh';

const nativeScript: NativeScript = {
  type: 'all',
  scripts:
  [
    {
      type: 'before',
      slot: '<insert slot here>'
    },
    {
      type: 'sig',
      keyHash: '<insert keyHash here>'
    }
  ]
};

const forgingScript = ForgeScript.fromNativeScript(nativeScript);

Hope this helps. We will update the documentation to include this.

Thanks a lot!