Creating a pToken Transaction

The TokenParams attribute

Recall that TokenParams is an optional field in txParams when calling createTransaction. When TokenParams==null, a PRV transaction will be created. If you want to transfer a pToken, just pass in an object with the following format:
  • PaymentInfo: array of token receivers
  • InputCoins: the (token) coins that will be spent
  • TokenID: fixed identifier for the token being spent
  • CoinCache: an array of random (encrypted) token coins in the Incognito network, used to hide sender identity
Remember to still include a PRV input since the TX fee needs to be in PRV
Example:
1
{
2
"SenderSK": "ThHKrr8n8sJ1fRjRpU7WK4ihCcNDPgBpCSB+Yl1OGg0=",
3
"PaymentInfo": [],
4
"InputCoins": [{
5
"Version": "2",
6
"Info": "",
7
"Index": "1vnApCg",
8
"PublicKey": "12VpWUvJ7DCrU1BDCy6w8qLuMFeV8iMDpUDVDrzpgkLAoUhroDp",
9
"Commitment": "1pwvwufBRZME3YfaesJch97VBmT8zwyUgDvXHGUAeRCF2icR5o",
10
"KeyImage": "124Z7u1Y4fA4qktQPFToDNM2mAEsCpRUAcNzjsnXiAVG4bJknhB",
11
"SharedRandom": "",
12
"SharedConcealRandom": "",
13
"TxRandom": "13arbQFVuqY7CA57rzVGSECphoaqi1dCvS3r5TBuDv4rr4Uexyu2frqKphhaQpUFeL6zop2wShyhoEf4wMy3Wkx5NpY5i4WMEyo2",
14
"Randomness": "12ZCiAzdK5ppmpPBQujy7KHioKa7rMhEy6D4CFpJQGjiqp36CKF",
15
"Value": "38249999993610",
16
"CoinDetailsEncrypted": "15eNawVo61YYRLcKmmuKJrSVt2WijxWPR84RubghQuafoWfibL",
17
"SNDerivator": "",
18
"AssetTag": ""
19
}],
20
"Fee": 20,
21
"Metadata": null,
22
"Info": "",
23
"CoinCache": {
24
"Indexes": [4, 8],
25
"Commitments": [
26
"12iVg2mTehTpMxvkMChkzVUhUswmJKmVDxiJZVyt7VRY6hXtjJS",
27
"1pwvwufBRZME3YfaesJch97VBmT8zwyUgDvXHGUAeRCF2icR5o"
28
],
29
"PublicKeys": [
30
"1kvBKj1yxpy8aazcNEcGHtChxEppFscytoXEiybva3HEtZXjNp",
31
"12VpWUvJ7DCrU1BDCy6w8qLuMFeV8iMDpUDVDrzpgkLAoUhroDp"
32
],
33
"AssetTags": []
34
},
35
"TokenParams": {
36
"PaymentInfo": [{
37
"PaymentAddress": "12si2KgWLGuhXACeqHGquGpyQy7JZiA5qRTCWW7YTYrEzZBuZC2eGBfckc2NRXkQXiw7XwK2WVfKxC8AcwKGCsyRVr9SR8bN9vTcnk2PPbymztCWadgr9JMP1UY6oSk9XZb56EAKunejzNnmo9Ln",
38
"Amount": "100",
39
"Message": ""
40
}],
41
"InputCoins": [{
42
"Version": "2",
43
"Info": "",
44
"Index": "",
45
"PublicKey": "1oVKp6i7baNBkoVWi1xbqUQmjpMTd536FPt9UJ3NL81GSWAhmU",
46
"Commitment": "12k9Bm6HnmZz4Q6oyeH6KuFshEckdQJo7uyeVDWeSYEwaVya28H",
47
"KeyImage": "1YEP2H44Qw5ZCAk3WvmEnEqUZCrSjaNUKHG8SmMqCbBwNSXhn1",
48
"SharedRandom": "12uUHdYx6YMp3TrFoibGcz9hJrtKxr1Xs1sC5M7Bw6paJiWtnUU",
49
"SharedConcealRandom": "",
50
"TxRandom": "14maNtXPGFgCvHFweEWaiML6eY5Fb6bVu4fF71MRFyTWfsZ8qtZ46zxQRFUohqgFkVorHUCMXbgMJMVNg7ufxKuBBuucJcpcPAhE",
51
"Randomness": "1cbzwMu9CrKNRjRZKyJpJzzFHA4KHQUe9TwyAMfoAaRgLYg9LF",
52
"Value": "50000",
53
"CoinDetailsEncrypted": "1cZx5qAY9hxDNE7c4xzZD511TZC1YUj7JCwchZwQYxumjZ9n5P",
54
"SNDerivator": "",
55
"AssetTag": "12Yut8DnBXWQNVsnG9sE3tJPvCZufQ4AKBXBvyckdWEjyfXYLfj"
56
}],
57
"TokenID": "699a3006d1865ebdc437053b33df6a62c6c7c2f554f2fd0adf99a60f5117f945",
58
"CoinCache": {
59
"Indexes": [0, 1],
60
"Commitments": [
61
"12k9Bm6HnmZz4Q6oyeH6KuFshEckdQJo7uyeVDWeSYEwaVya28H",
62
"14SvXFXYhyZueCnBL5EFYpA4J8QiuZBYAj4JSdvXS7cCsaXnZq"
63
],
64
"PublicKeys": [
65
"1oVKp6i7baNBkoVWi1xbqUQmjpMTd536FPt9UJ3NL81GSWAhmU",
66
"12cDNcYxkJD4aVBSSqp5ukf4H6ZUuQjn9gmKSepNo7mGbUgHA9z"
67
],
68
"AssetTags": [
69
"12Yut8DnBXWQNVsnG9sE3tJPvCZufQ4AKBXBvyckdWEjyfXYLfj",
70
"12tPdPNVJKQfXgEye7ndwqxxifjRV7tYaQq93T8M8Bx3BpH4iHw"
71
]
72
}
73
}
74
}
Copied!
Resulting TX:
1
{
2
"Tx": {
3
"Version": 2,
4
"Type": "tp",
5
"LockTime": 1609823256,
6
"Fee": 10,
7
"Info": "",
8
"SigPubKey": "CAEBBAEFAQMBBgEGAQYBCAEI",
9
"Sig": "AiBIeH8RyJa...",
10
"Proof": "AgAAAuIBY2cS...",
11
"PubKeyLastByteSender": 170,
12
"Metadata": null
13
},
14
"TxTokenPrivacyData": {
15
"PropertyID": "0000000000000000000000000000000000000000000000000000000000000005",
16
"PropertyName": "",
17
"PropertySymbol": "",
18
"SigPubKey": "CAEBAQABAQEBAQEBAQAA",
19
"Sig": "AiCKGcpDJI6j...",
20
"Proof": "AgAAA0ICrdrbV...",
21
"Type": 1,
22
"Mintable": false
23
}
24
}
Copied!

Creating a custom token

The Incognito network allows creation of custom tokens, as long as their name & symbol do not conflict with existing ones. Simply set
1
{
2
//...
3
"TokenID" : "",
4
"TokenName" : "<your-desired-name>",
5
"TokenSymbol" : "<your-desired-symbol>",
6
"PaymentInfo" : "<receiver-and-amount-to-create>",
7
//...
8
}
Copied!
inside your TokenParams.
Example:
1
"TokenParams": {
2
"TokenID": "",
3
"TokenName": "Rose",
4
"TokenSymbol": "RSE",
5
"Amount": 10000,
6
"PaymentInfo": [{
7
"PaymentAddress": "12sxXUjkMJZHz6diDB6yYnSjyYcDYiT5QygUYFsUbGUqK8PH8uhxf4LePiAE8UYoDcNkHAdJJtT1J6T8hcvpZoWLHAp8g6h1BQEfp4h5LQgEPuhMpnVMquvr1xXZZueLhTNCXc8fkVXseeVAGCt8",
8
"Amount": "10000"
9
}],
10
"InputCoins": [],
11
"CoinCache": {}
12
}
Copied!
Resulting TX:
1
{
2
"Tx": {
3
"Version": 2,
4
"Type": "tp",
5
"LockTime": 1609823172,
6
"Fee": 50,
7
"Info": "",
8
"SigPubKey": "CAEBAwEFAAEDAQMBBQEEAQQ=",
9
"Sig": "AiCMCNb1mBPec...",
10
"Proof": "AgAAAuIB4QzMG8R...",
11
"PubKeyLastByteSender": 170,
12
"Metadata": null
13
},
14
"TxTokenPrivacyData": {
15
"PropertyID": "f6c2aca5a808f439690a81e3190a36e8e4f5bdb518ede086c9ee0c1ff52eb681",
16
"PropertyName": "Rose",
17
"PropertySymbol": "RSE",
18
"Proof": "AgAAAUIAAQAAA...",
19
"Type": 0,
20
"Mintable": false
21
}
22
}
Copied!
Last modified 10mo ago