You are viewing a single comment's thread from:

RE: Test title

in #topic15 years ago

{
"id": "ssc-testnet1",
"json": {
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "crittermanager",
"params": "",
"code": "LyogZXNsaW50LWRpc2FibGUgbm8tYXdhaXQtaW4tbG9vcCAqLwovKiBlc2xpbnQtZGlzYWJsZSBtYXgtbGVuICovCi8qIGdsb2JhbCBhY3Rpb25zLCBhcGkgKi8KCi8vIHRlc3QgY29udHJhY3QgdG8gZGVtb25zdHJhdGUgU3BsaW50ZXJsYW5kcyBzdHlsZQovLyBwYWNrIGlzc3VhbmNlIG9mIGNvbGxlY3RhYmxlIGNyaXR0ZXJzCmNvbnN0IENPTlRSQUNUX05BTUUgPSAnY3JpdHRlcm1hbmFnZXInOwoKLy8gbm9ybWFsbHkgd2Ugd291bGQgdXNlIGFwaS5vd25lciB0byByZWZlciB0byB0aGUgY29udHJhY3QKLy8gb3duZXIgKHRoZSBhY2NvdW50IHRoYXQgZGVwbG95ZWQgdGhlIGNvbnRyYWN0KSwgYnV0IGZvciBub3cKLy8gY29udHJhY3QgZGVwbG95bWVudCBpcyByZXN0cmljdGVkLCBzbyB3ZSBuZWVkIGFub3RoZXIgd2F5Ci8vIHRvIHJlY29nbml6ZSB0aGUgQ3JpdHRlciBhcHAgb3duZXIKY29uc3QgQ1JJVFRFUl9DUkVBVE9SID0gJ2NyeXB0b21hbmNlcic7CgovLyB0aGlzIHBsYWNlaG9sZGVyIHJlcHJlc2VudHMgRU5HIHRva2VucyBvbiB0aGUgbWFpbm5ldCBhbmQgU1NDIG9uIHRoZSB0ZXN0bmV0Ci8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBuby10ZW1wbGF0ZS1jdXJseS1pbi1zdHJpbmcKY29uc3QgVVRJTElUWV9UT0tFTl9TWU1CT0wgPSAiU1NDIjsKCi8vIHdlIHdpbGwgaXNzdWUgY3JpdHRlcnMgaW4gInBhY2tzIiBvZiA1IGF0IGEgdGltZQpjb25zdCBDU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