コード例 #1
0
import json
import requests
from harvest import Harvest

harvester = Harvest()

#BAT 
abiUrl = "http://api.etherscan.io/api?module=contract&action=getabi&address=0x0d8775f648430679a709e98d2b0cb6250d2887ef&format=raw"
abiData = requests.get(abiUrl).content


officialAbiJSON = json.loads(abiData)
theDeterministicHash = harvester.shaAnAbi(officialAbiJSON)
cleanedAndOrderedAbiText = harvester.cleanAndConvertAbiToText(officialAbiJSON)
erc20Hashes = harvester.createUniqueAbiComparisons(json.loads(cleanedAndOrderedAbiText))
# print("\nThe original ABI is as follows:")
# print(officialAbiJSON)
# 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)



txReceipt = harvester.web3.eth.getTransactionReceipt("0xcceb1fd34dcc4b18defa4ff29d51a225b20af8ed179db37da72ec5d5a4e8d385")
tx = harvester.web3.eth.getTransaction("0xcceb1fd34dcc4b18defa4ff29d51a225b20af8ed179db37da72ec5d5a4e8d385")
#print("Transaction is as follows:")
#print(tx)
print(officialAbiJSON)
コード例 #2
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)