Minting
Minting with NativeScript
Below Javascript snippet shows a minting transaction using NativeScript, Example uses typhonjsopen in new window library.
const receivingAddress =
"addr_test1qz2qzz8d4unvpkes7nt7tjkwx0sff3cfkrvl528mgkdzt5kmt68vuzvz4nzgs00x0shrgywvy674v6r2zcs8fxvvq27qqycj9a";
const decoded = typhonjs.utils.decodeBech32(receivingAddress);
const pubKeyHash = decoded.value.slice(2, 56 + 2);
const nativeScript = {
pubKeyHash: pubKeyHash,
};
const nativeScriptFactory = new typhonjs.NativeScriptFactory(nativeScript);
const policyId = nativeScriptFactory.policyId().toString("hex");
const mintResponse = await window.cardano.typhon.transaction({
mints: [
{
policyId: policyId,
assets: [
{
assetName: "41737365744e616d65",
amount: "10000",
},
],
nativeScript: nativeScript,
},
],
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
More detailed example at this Github Repositoryopen in new window.
Minting with PlutusScript
Below Javascript snippet shows a minting transaction using PlutusScript, Example uses typhonjsopen in new window library.
const mintResponse = await window.cardano.typhon.transaction({
mints: [
{
policyId: "648823ffdad1610b4162f4dbc87bd47f6f9cf45d772ddef661eff198",
assets: [
{
assetName: "41737365744e616d65",
amount: "10000",
},
],
plutusScript: {
type: "PlutusScriptV1",
cborHex: "4e4d01000033222200412001200101",
},
redeemer: {
plutusDataCbor: "d8799f0c0cff",
exUnits: {
mem: 74400,
steps: 22121439,
},
},
},
],
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
More detailed example at this Github Repositoryopen in new window.