Created
June 18, 2019 16:22
-
-
Save SAYONG/1757d0938e26e22c2781f53436830dee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from eth_tester import EthereumTester | |
from web3 import Web3 | |
from web3.providers.eth_tester import EthereumTesterProvider | |
from vyper import compiler | |
w3 = Web3(EthereumTesterProvider(EthereumTester())) | |
w3.eth.defaultAccount = sender = w3.eth.accounts[0] | |
with open('whitelist.vy') as f: | |
source_code = f.read() | |
out = compiler.compile_code( | |
source_code, | |
['abi', 'bytecode'], | |
) | |
abi = out['abi'] | |
bytecode = out['bytecode'] | |
contract = w3.eth.contract(abi=abi, bytecode=bytecode) | |
params = {'from': w3.eth.defaultAccount, 'gasPrice': 0} | |
tx_hash = contract.constructor(sender).transact(params) | |
tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) | |
print('Gas used: {}'.format(tx_receipt.gasUsed)) | |
contract_address = tx_receipt.contractAddress | |
whitelist = w3.eth.contract(address=contract_address,abi=abi) | |
print('Contract size: {}'.format(len(w3.eth.getCode(whitelist.address)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment