rmrk-tools icon indicating copy to clipboard operation
rmrk-tools copied to clipboard

Add onMint callback to MINT interaction

Open Yuripetusko opened this issue 3 years ago • 3 comments

Because TS/extrinsic implementation version of RMRK standard uses block number in NFT id, this prevents you from doing anything with an NFT in the same block as it is MINTed. This is because you need to know at which block the NFT was minted before you can construct additional remarks for it.

with that in mind, I propose to accept an optional onMint array with nft fields object passed with MINT interaction. This array would use double curly brace notation that will be interpolated into nft id that is being minted at a runtime.

RMRK::MINT::2.0.0::${encodeURIComponent(
  JSON.stringify({
    collection: '8949162-e0b9bdcc456a36497a',
    symbol: 'KANL',
    transferable: 1,
    sn: 00009999,
    metadata: 'ipfs://ipfs/foo',
    onMint: [
      `RMRK::RESADD::2.0.0::{{nft.id}}::${encodeURIComponent(
          JSON.stringify({
            id: nanoid(8),
            src: 'ipfs://ipfs/foo',
          })
        )}`
    ]
  })
)}

Yuripetusko avatar Feb 09 '22 23:02 Yuripetusko

Needs a spec change, and a whitelist for callback ops to LIST, SEND, RESADD. Otherwise fine, but needs to be aware of possible double curlies in the resource fields, if someone decides to break things 🤔

Swader avatar Feb 09 '22 23:02 Swader

Definitely a 👍 Need the exact use case you are using as an example.

yornaath avatar Mar 02 '22 11:03 yornaath

This would be a hugely useful addition to the spec!

boyswan avatar Mar 14 '22 23:03 boyswan