Skip to content

Instantly share code, notes, and snippets.

@janfilips
Created July 11, 2018 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janfilips/fd878e02d880a78ed723f221794d4c83 to your computer and use it in GitHub Desktop.
Save janfilips/fd878e02d880a78ed723f221794d4c83 to your computer and use it in GitHub Desktop.
from web3 import Web3
import json
from web3.providers.rpc import HTTPProvider
CONTRACT_ABI = '''
[{"constant": false,"inputs": [{"name": "hash","type": "bytes32"}],"name": "apply","outputs": [],"payable": false,"stateMutability": "nonpayable","type": "function"},{"constant": true,"inputs": [{"name": "email","type": "string"}],"name": "getApplicationID","outputs": [{"name": "","type": "uint256"}],"payable": false,"stateMutability": "view","type": "function"}]
'''
CONTRACT_ADDRESS = '0xcbbfbafedb0eb83016d2a96a4e80d30b20fa3e30'
CONTRACT_ADDRESS = Web3.toChecksumAddress(CONTRACT_ADDRESS)
w3 = Web3(HTTPProvider('https://ropsten.infura.io'))
#x = w3.eth.getTransaction('0x8ba068edf2c9134efd5d00019ae5d9e771ebd6e4cf326891ee0a1851f62f0054')
#print('transaction details', x)
KECCAK_EMAIL = '747fa38ae85d5f6be1bfe18a5040f3d4fb9fc4b74a4972d440e7bdcb8f1b6c28'
KECCAK_EMAIL = Web3.toHex(text=KECCAK_EMAIL)
KECCAK_EMAIL = Web3.toBytes(text=KECCAK_EMAIL)
print('pica ------------ ',KECCAK_EMAIL)
CONTRACT_ABI = json.loads(CONTRACT_ABI)
contract_instance = w3.eth.contract(address=CONTRACT_ADDRESS, abi=CONTRACT_ABI,)
#print ('block number', w3.eth.blockNumber)
#print ('Creator',contract_instance.call().creator)
#print ('Contracts',contract_instance.call().newContracts)
#print ('OracleName',contract_instance.call().oracleName)
#print ('-'*100)
print ('1. Submit a hash (Keccak-256) of your email address using the apply() function.')
apply_res = contract_instance.functions.apply(KECCAK_EMAIL).call()
print ('apply response:', apply_res)
print ('2. Retrieve your application ID using the getApplicationID() function.')
#application_id = contract_instance.functions.getApplicationID('test@test.com').call()
#print ('appliation_id', application_id)
application_id = contract_instance.functions.getApplicationID(KECCAK_EMAIL).call()
print ('appliation_id', application_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment