Skip to content

Instantly share code, notes, and snippets.

@SAYONG
Created June 18, 2019 16:22
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 SAYONG/1757d0938e26e22c2781f53436830dee to your computer and use it in GitHub Desktop.
Save SAYONG/1757d0938e26e22c2781f53436830dee to your computer and use it in GitHub Desktop.
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