Minting NFT/Token
For minting with Kuber, the transaction body should contain "mint" key containing script and amount to be minted as shown in the examples below for different types of minting policies.
Signature Policy
Here simple policy script specifying key-hash indicating who can mint the tokens using the following policy script. Output contains address where the token is to be minted in which the value specifies new value, policy id and required asset name. If the total number of minted token is 1, then it is considered as NFT. First we will use Kuber utilities to help us get the key-hash and policy id of the script.
Key Hash of the address
You can get your key-hash from your address using the Kuber Playground's Utility Section.
For eg. Address
addr_test1qzxy4jj7mmhsduucuwhgshylgj0qyejdyv4wkrecvzexneqjzg9nt7t234jvlen7e9qdwkdjmxdptz7eun3473kf5qfqty8avj
Key Hash
8c4aca5edeef06f398e3ae885c9f449e02664d232aeb0f3860b269e4
Use your address to get your key-hash.
Policy Id of the script
Now you can get your policy id from the script using the Kuber Playground's Utility Section by using the following input body, where you use your keyHash
from the previous step.
{
"keyHash": "8c4aca5edeef06f398e3ae885c9f449e02664d232aeb0f3860b269e4",
"type": "sig"
}
Output policy id
981a76013c22440ad5a7202d811f3a9eddd6e9bfa48523de5acfec53
Now, you can use the policy id and key hash to mint the token using the following transaction body. The mint specifies the script and amount to be minted. Here, the signature policy script is provided for the NFT minting, and two tokens named Token1 are minted. Then, the two tokens are sent to the demo address. The value
field in the output object specifies the amount of token to be transferred to the address.
{
"output": [
{
"address": "addr_test1qzxy4jj7mmhsduucuwhgshylgj0qyejdyv4wkrecvzexneqjzg9nt7t234jvlen7e9qdwkdjmxdptz7eun3473kf5qfqty8avj",
"value": "2 981a76013c22440ad5a7202d811f3a9eddd6e9bfa48523de5acfec53.Token1"
}
],
"mint": [
{
"script": {
"type": "sig",
"keyHash": "8c4aca5edeef06f398e3ae885c9f449e02664d232aeb0f3860b269e4"
},
"amount": {
"Token1": 2
}
}
]
}
Timelock Policy
It is the same as above except it contains script using time lock policy in mint field. Generate the policy id using the following body in the utility tab of Kuber Playground. The slot
specifies the number of slots before
or after
which the token can be minted.
{
"type": "before",
"slot": 9972761
}
Output Policy Id is
e3267339783b00bb80324c77fcecb1987a2bdf7cafc53559dbb884af
In the example below, the time lock policy script is provided for the NFT minting, and two tokens named TimeLockScript are minted. Then, the two tokens are sent to the demo address. The value
field in the output object specifies the amount of token to be transferred to the address. Since we are using timelock policy, we have to add transaction validity period in the transaction body. We'll have to specify validityEndSlot
in the transaction body for before
policy script which should be less than the slot number in the script. For after
policy script, we'll have to specify validityStartSlot
which should be greater than the slot number in the script.
{
"output": [
{
"address": "addr_test1qzxy4jj7mmhsduucuwhgshylgj0qyejdyv4wkrecvzexneqjzg9nt7t234jvlen7e9qdwkdjmxdptz7eun3473kf5qfqty8avj",
"value": "2 e3267339783b00bb80324c77fcecb1987a2bdf7cafc53559dbb884af.TimeLockScript"
}
],
"mint": [
{
"script": {
"type": "before",
"slot": 9972761
},
"amount": {
"TimeLockScript": 2
}
}
],
"validityEndSlot": 9972750
}
Note The validityEndSlot should be less than the slot number in the script but not less that the current slot number. You can get the current slot number from the cardano explorer by looking at the slot number of latest transaction.
Complex Policy (all/any)
In the following example, we demonstrate how complex policy can be written in Kuber using both time lock and policy hash. Like in the before examples you use the content inside the script field in the mint object to generate the policy id. And use the transaction body as below to mint the token with the policy id.
{
"output": [
{
"address": "addr_test1qp05qvgpzrgrhujkp5ft7x3ja7en8fj7p4mt4ggvwam2pp3gw8kcumwk8xy4lcvvdpk4plqahkq7jsw3ctw3u49622kqqhdnr0",
"value": "1 9497e9ed6acd8b85c17411d508ac45570170ade9fe04df4ec9390d74.Token1"
}
],
"mint": [
{
"script": {
"scripts": [
{
"keyHash": "8c4aca5edeef06f398e3ae885c9f449e02664d232aeb0f3860b269e4",
"type": "sig"
},
{
"slot": 99999999,
"type": "before"
}
],
"type": "all"
},
"amount": {
"Token1": 1,
"Token2": 2
}
}
],
"validityEndSlot": 19972750
}
Plutus script
Here the script used in plutus script in the format given below on mint field. Plutus script requires an additional field as redeemer which is to be passed on another "redeemer" field. The policy id is generated using the script field in the utilities section of Kuber Playground as in the above examples.
{
"output": [
{
"address": "addr_test1qzvudjg7wg35wqkp4k3rhewp7kjsrm3fzsfx8xpwdffmtcms5zgjmjf3s8e9d3nqz3vt6ka3ht5egt55q3ge23399x0s5eywfd",
"value": "1 2006f9e089829000e5c5b73bf690f01712c6f392c25a8ba70210989e.Token1"
}
],
"mint": [
{
"script": {
"type": "PlutusScriptV1",
"description": "",
"cborHex": "5907245907210100003232323232323232323322323232323233223232323222323253353232333573466e1c00920040130123333573466e1cd55cea801a400046644246600200600464646464646464646464646666ae68cdc39aab9d500a480008cccccccccc888888888848cccccccccc00402c02802402001c01801401000c008cd404c8c8c8cccd5cd19b8735573aa0049000119910919800801801180f1aba150023018357426ae8940088c98c80a4cd5ce01501481389aab9e5001137540026ae854028cd404c050d5d0a804999aa80b3ae501535742a010666aa02ceb94054d5d0a80399a8098101aba15006335013335502302175a6ae854014c8c8c8cccd5cd19b8735573aa00490001199109198008018011919191999ab9a3370e6aae754009200023322123300100300233502475a6ae854008c094d5d09aba2500223263202d33573805c05a05626aae7940044dd50009aba150023232323333573466e1cd55cea8012400046644246600200600466a048eb4d5d0a80118129aba135744a004464c6405a66ae700b80b40ac4d55cf280089baa001357426ae8940088c98c80a4cd5ce01501481389aab9e5001137540026ae854010cd404dd71aba15003335013335502375c40026ae854008c06cd5d09aba2500223263202533573804c04a04626ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226aae7940044dd50009aba150033232323333573466e1d400520062321222230040053018357426aae79400c8cccd5cd19b875002480108c848888c008014c068d5d09aab9e500423333573466e1d400d20022321222230010053014357426aae7940148cccd5cd19b875004480008c848888c00c014dd71aba135573ca00c464c6404066ae7008408007807407006c4d55cea80089baa001357426ae89400c8c98c8064cd5ce00d00c80b9bad00410171326320173357389210350543500017135573ca00226ea800448c88c008dd6000990009aa80b111999aab9f00125009233500830043574200460066ae880080548c8c8c8cccd5cd19b8735573aa00690001199911091998008020018011919191999ab9a3370e6aae7540092000233221233001003002301735742a00466a01c02c6ae84d5d1280111931900d19ab9c01b01a018135573ca00226ea8004d5d0a801999aa803bae500635742a00466a014eb8d5d09aba2500223263201633573802e02c02826ae8940044d55cf280089baa0011335500175ceb44488c88c008dd5800990009aa80a11191999aab9f0022500823350073355017300635573aa004600a6aae794008c010d5d100180a09aba100111220021221223300100400312232323333573466e1d4005200023212230020033005357426aae79400c8cccd5cd19b8750024800884880048c98c8048cd5ce00980900800789aab9d500113754002464646666ae68cdc39aab9d5002480008cc8848cc00400c008c014d5d0a8011bad357426ae8940088c98c803ccd5ce00800780689aab9e5001137540024646666ae68cdc39aab9d5001480008dd71aba135573ca004464c6401a66ae7003803402c4dd500089119191999ab9a3370ea00290021091100091999ab9a3370ea00490011190911180180218031aba135573ca00846666ae68cdc3a801a400042444004464c6402066ae700440400380340304d55cea80089baa0012323333573466e1d40052002200523333573466e1d40092000200523263200c33573801a01801401226aae74dd5000891001091000919191919191999ab9a3370ea002900610911111100191999ab9a3370ea004900510911111100211999ab9a3370ea00690041199109111111198008048041bae35742a00a6eb4d5d09aba2500523333573466e1d40112006233221222222233002009008375c6ae85401cdd71aba135744a00e46666ae68cdc3a802a400846644244444446600c01201060186ae854024dd71aba135744a01246666ae68cdc3a8032400446424444444600e010601a6ae84d55cf280591999ab9a3370ea00e900011909111111180280418071aba135573ca018464c6402466ae7004c04804003c03803403002c0284d55cea80209aab9e5003135573ca00426aae7940044dd50009191919191999ab9a3370ea002900111999110911998008028020019bad35742a0086eb4d5d0a8019bad357426ae89400c8cccd5cd19b875002480008c8488c00800cc020d5d09aab9e500623263200b33573801801601201026aae75400c4d5d1280089aab9e500113754002464646666ae68cdc3a800a400446424460020066eb8d5d09aab9e500323333573466e1d400920002321223002003375c6ae84d55cf280211931900419ab9c009008006005135573aa00226ea800444888c8c8cccd5cd19b8735573aa0049000119aa80518031aba150023005357426ae8940088c98c8020cd5ce00480400309aab9e5001137540029309000a490350543100112212330010030021123230010012233003300200200101"
},
"redeemer": {
"int": 2
},
"amount": {
"Token1": 1
}
}
]
}