コード例 #1
0
                                "uniqueAbiAndAddressHash": "0x54040994221542e1ce9fdfc9c7396d02de07a2b7df065865b8a404a5498c6fef"
                            }
                        ]
                    },
                    "requiresUpdating": "yes",
                    "quality": "50",
                    "indexInProgress": "false"
                }'''
sourceJSON = json.loads(source)

#transferABI = '''[{"constant":true,"inputs":[],"name":"proxyType","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"implementation","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_masterCopy","type":"address"},{"name":"initializer","type":"bytes"},{"name":"funder","type":"address"},{"name":"paymentToken","type":"address"},{"name":"payment","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"}]'''

transferABI = '''[{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]'''

transferABIJSON = json.loads(transferABI)
theDeterministicHash = harvester.shaAnAbi(transferABIJSON)
cleanedAndOrderedAbiText = harvester.cleanAndConvertAbiToText(transferABIJSON)
erc20Hashes = harvester.createUniqueAbiComparisons(
    json.loads(cleanedAndOrderedAbiText))
print("\nThe original ABI is as follows:")
print(transferABIJSON)
print("\nThe cleaned and ordered ABI is as follows:")
print(cleanedAndOrderedAbiText)
print("\nThe Sha3 of this ABI is as follows:")
print(theDeterministicHash)
print(
    "\nThe unique function hashes for this official ERC20 ABI are as follows:")
print(erc20Hashes)

harvester.abiCompatabilityUpdate(transferABIJSON, sourceJSON)