crittermanager Smart Contract

in #steem-engine5 years ago

{
"id": "ssc-mainnet1",
"json": {
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "crittermanager",
"params": "",
"code": "LyogZXNsaW50LWRpc2FibGUgbm8tYXdhaXQtaW4tbG9vcCAqLwovKiBlc2xpbnQtZGlzYWJsZSBtYXgtbGVuICovCi8qIGdsb2JhbCBhY3Rpb25zLCBhcGkgKi8KCi8vIHRlc3QgY29udHJhY3QgdG8gZGVtb25zdHJhdGUgU3BsaW50ZXJsYW5kcyBzdHlsZQovLyBwYWNrIGlzc3VhbmNlIG9mIGNvbGxlY3RhYmxlIGNyaXR0ZXJzCmNvbnN0IENPTlRSQUNUX05BTUUgPSAnY3JpdHRlcm1hbmFnZXInOwoKLy8gbm9ybWFsbHkgd2Ugd291bGQgdXNlIGFwaS5vd25lciB0byByZWZlciB0byB0aGUgY29udHJhY3QKLy8gb3duZXIgKHRoZSBhY2NvdW50IHRoYXQgZGVwbG95ZWQgdGhlIGNvbnRyYWN0KSwgYnV0IGZvciBub3cKLy8gY29udHJhY3QgZGVwbG95bWVudCBpcyByZXN0cmljdGVkLCBzbyB3ZSBuZWVkIGFub3RoZXIgd2F5Ci8vIHRvIHJlY29nbml6ZSB0aGUgQ3JpdHRlciBhcHAgb3duZXIKY29uc3QgQ1JJVFRFUl9DUkVBVE9SID0gJ2NyeXB0b21hbmNlcic7CgovLyB0aGlzIHBsYWNlaG9sZGVyIHJlcHJlc2VudHMgRU5HIHRva2VucyBvbiB0aGUgbWFpbm5ldCBhbmQgU1NDIG9uIHRoZSB0ZXN0bmV0Ci8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBuby10ZW1wbGF0ZS1jdXJseS1pbi1zdHJpbmcKY29uc3QgVVRJTElUWV9UT0tFTl9TWU1CT0wgPSAnRU5HJzsKCi8vIHdlIHdpbGwgaXNzdWUgY3JpdHRlcnMgaW4gInBhY2tzIiBvZiA1IGF0IGEgdGltZQpjb25zdCBDUklUVEVS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U3ltYm9sLCBwYWNrcy50b1N0cmluZygpLCAndHJhbnNmZXInKSwgJ3VuYWJsZSB0byB0cmFuc2ZlciBwYWNrIHRva2VucycpKSB7CiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQoKICAgICAgICAvLyB3ZSB3aWxsIGlzc3VlIGNyaXR0ZXJzIGluIHBhY2tzIG9mIDUgYXQgb25jZQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGFja3M7IGkgKz0gMSkgewogICAgICAgICAgY29uc3QgaW5zdGFuY2VzID0gW107CiAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IENSSVRURVJTX1BFUl9QQUNLOyBqICs9IDEpIHsKICAgICAgICAgICAgaW5zdGFuY2VzLnB1c2goZ2VuZXJhdGVSYW5kb21Dcml0dGVyKGVkaXRpb25NYXBwaW5nW3BhY2tTeW1ib2xdLCBhcGkuc2VuZGVyKSk7CiAgICAgICAgICB9CgogICAgICAgICAgYXdhaXQgYXBpLmV4ZWN1dGVTbWFydENvbnRyYWN0KCduZnQnLCAnaXNzdWVNdWx0aXBsZScsIHsKICAgICAgICAgICAgaW5zdGFuY2VzLAogICAgICAgICAgICBpc1NpZ25lZFdpdGhBY3RpdmVLZXksCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIH0KICAgIH0KICB9CiAgcmV0dXJuIGZhbHNlOwp9Owo="
}
}
}

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.034
BTC 90827.60
ETH 3116.50
USDT 1.00
SBD 2.97