{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "account",
"contractAction": "register",
"contractPayload": {}
}
}
You are viewing a single comment's thread from:
{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "account",
"contractAction": "register",
"contractPayload": {}
}
}
{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "token",
"code": "YWN0aW9ucy5jcmVhdGVTU0MgPSBmdW5jdGlvbiAocGF5bG9hZCkgewogIGRiLmNyZWF0ZVRhYmxlKCdhY2NvdW50cycpOwp9CgovLyByZWdpc3RlciBhbiBhY2NvdW50IGhlbHBzIG90aGVyIGNvbnRyYWN0cyB0byBrbm93IAovLyBpZiBhbiBhY2NvdW50IGV4aXN0cyBvbiB0aGUgU3RlZW0gYmxvY2tjaGFpbgphY3Rpb25zLnJlZ2lzdGVyID0gZnVuY3Rpb24gKHBheWxvYWQpIHsKICBsZXQgYWNjb3VudHMgPSBkYi5nZXRUYWJsZSgnYWNjb3VudHMnKTsKCiAgbGV0IGFjY291bnQgPSBhY2NvdW50cy5maW5kT25lKHsgJ2lkJzogc2VuZGVyIH0pOwoKICBpZiAoYWNjb3VudCA9PT0gbnVsbCkgewogICAgY29uc3QgbmV3QWNjb3VudCA9IHsKICAgICAgJ2lkJzogc2VuZGVyCiAgICB9OwoKICAgIGFjY291bnRzLmluc2VydChuZXdBY2NvdW50KTsKICB9Cn0KICBgOwoKICAgIGxldCBjb2RlVG9rZW4gPSBgCmFjdGlvbnMuY3JlYXRlU1NDID0gZnVuY3Rpb24gKHBheWxvYWQpIHsKICBkYi5jcmVhdGVUYWJsZSgndG9rZW5zJyk7CiAgZGIuY3JlYXRlVGFibGUoJ2JhbGFuY2VzJyk7Cn0KCmFjdGlvbnMuY3JlYXRlID0gZnVuY3Rpb24gKHBheWxvYWQpIHsKICBjb25zdCB7IHN5bWJvbCwgcHJlY2lzaW9uLCBtYXhTdXBwbHkgfSA9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BpZiAoYXNzZXJ0KHRva2VuICE9PSBudWxsLCAnc3ltYm9sIGRvZXMgbm90IGV4aXN0JykKICAgICAgICAgICYmIGFzc2VydChjb3VudERlY2ltYWxzKHF1YW50aXR5KSA8PSB0b2tlbi5wcmVjaXNpb24sICdzeW1ib2wgcHJlY2lzaW9uIG1pc21hdGNoJykKICAgICAgICAgICYmIGFzc2VydChxdWFudGl0eSA"
}
}
}
{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "token",
"contractAction": "create",
"contractPayload": {
"symbol": "PKTC",
"precision": 0,
"maxSupply": 1000000
}
}
}
{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "token",
"contractAction": "issue",
"contractPayload": {
"symbol": "PKTC",
"to": "harpagon",
"quantity": 1000
}
}
}
{
"id": "ssc-b8923f70-c1f7-497f-961k",
"json": {
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "account",
"code": "YWN0aW9ucy5jcmVhdGVTU0MgPSBmdW5jdGlvbiAocGF5bG9hZCkgewogIGRiLmNyZWF0ZVRhYmxlKCdhY2NvdW50cycpOwp9CgovLyByZWdpc3RlciBhbiBhY2NvdW50IGhlbHBzIG90aGVyIGNvbnRyYWN0cyB0byBrbm93IAovLyBpZiBhbiBhY2NvdW50IGV4aXN0cyBvbiB0aGUgU3RlZW0gYmxvY2tjaGFpbgphY3Rpb25zLnJlZ2lzdGVyID0gZnVuY3Rpb24gKHBheWxvYWQpIHsKICBsZXQgYWNjb3VudHMgPSBkYi5nZXRUYWJsZSgnYWNjb3VudHMnKTsKCiAgbGV0IGFjY291bnQgPSBhY2NvdW50cy5maW5kT25lKHsgJ2lkJzogc2VuZGVyIH0pOwoKICBpZiAoYWNjb3VudCA9PT0gbnVsbCkgewogICAgY29uc3QgbmV3QWNjb3VudCA9IHsKICAgICAgJ2lkJzogc2VuZGVyCiAgICB9OwoKICAgIGFjY291bnRzLmluc2VydChuZXdBY2NvdW50KTsKICB9IAp9"
}
}
}
{
"id": "ssc-b8923f70-c1f7-497f-961k",
"json": {
"contractName": "account",
"contractAction": "register",
"contractPayload": {}
}
}
{
"id": "ssc-b8923f70-c1f7-497f-961k",
"json": {
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "token",
"code": "CmFjdGlvbnMuY3JlYXRlU1NDID0gZnVuY3Rpb24gKHBheWxvYWQpIHsKICBkYi5jcmVhdGVUYWJsZSgndG9rZW5zJyk7CiAgZGIuY3JlYXRlVGFibGUoJ2JhbGFuY2VzJyk7Cn0KCmFjdGlvbnMuY3JlYXRlID0gZnVuY3Rpb24gKHBheWxvYWQpIHsKICBjb25zdCB7IHN5bWJvbCwgcHJlY2lzaW9uLCBtYXhTdXBwbHkgfSA9IHBheWxvYWQ7CgogIGlmIChzeW1ib2wgJiYgdHlwZW9mIHN5bWJvbCA9PT0gJ3N0cmluZycKICAgICYmIChwcmVjaXNpb24gJiYgdHlwZW9mIHByZWNpc2lvbiA9PT0gJ251bWJlcicgfHwgcHJlY2lzaW9uID09PSAwKQogICAgJiYgbWF4U3VwcGx5ICYmIHR5cGVvZiBtYXhTdXBwbHkgPT09ICdudW1iZXInKSB7CgogICAgY29uc3QgUmVnZXhQdXJlTGV0dGVycyA9IC9eW2EtekEtWl0rJC87CgogICAgLy8gdGhlIHN5bWJvbCBtdXN0IGJlIG1hZGUgb2YgbGV0dGVycyBvbmx5CiAgICAvLyB0aGUgcHJlY2lzaW9uIG11c3QgYmUgYmV0d2VlbiAwIGFuZCA4IGFuZCBtdXN0IGJlIGFuIGludGVnZXIKICAgIC8vIHRoZSBtYXggc3VwcGx5IG11c3QgYmUgcG9zaXRpdmUKICAgIGlmIChhc3NlcnQoUmVnZXhQdXJlTGV0dGVycy50ZXN0KHN5bWJvbCksICdpbnZhbGlkIHN5bWJvbCcpCiAgICAgICYmIGFzc2VydCgocHJlY2lzaW9uID49IDAgJiYgcHJlY2lzaW9uIDw9IDgpICYmIChOdW1iZXIuaXNJbnRlZ2VyKH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hbmNlcy51cGRhdGUoYmFsYW5jZSk7CiAgfQp9CgpsZXQgY2FsY3VsYXRlQmFsYW5jZSA9IGZ1bmN0aW9uIChiYWxhbmNlLCBxdWFudGl0eSwgcHJlY2lzaW9uLCBhZGQpIHsKICBpZiAocHJlY2lzaW9uID09PSAwKSB7CiAgICByZXR1cm4gYWRkID8gYmFsYW5jZSArIHF1YW50aXR5IDogYmFsYW5jZSAtIHF1YW50aXR5CiAgfQoKICBsZXQgcmF0ZSA9IE1hdGgucG93KDEwLCBwcmVjaXNpb24pOwogIGxldCB0bXBRdHkgPSBxdWFudGl0eSAqIHJhdGU7CiAgbGV0IHRtcEJhbGFuY2UgPSBiYWxhbmNlICogcmF0ZTsKCiAgcmV0dXJuIGFkZCA/ICh0bXBCYWxhbmNlICsgdG1wUXR5KSAvIHJhdGUgOiAodG1wQmFsYW5jZSAtIHRtcFF0eSkgLyByYXRlOwp9CgpsZXQgY291bnREZWNpbWFscyA9IGZ1bmN0aW9uICh2YWx1ZSkgewogIGlmIChNYXRoLmZsb29yKHZhbHVlKSA9PT0gdmFsdWUpIHJldHVybiAwOwogIHJldHVybiB2YWx1ZS50b1N0cmluZygpLnNwbGl0KCcuJylbMV0ubGVuZ3RoIHx8IDA7Cn0="
}
}
}
{
"id": "ssc-b8923f70-c1f7-497f-961k",
"json": {
"contractName": "token",
"contractAction": "create",
"contractPayload": {
"symbol": "PKTC",
"precision": 0,
"maxSupply": 1000000
}
}
}