def generate_contracts(token):
context = {
'TOKEN_CLASS_NAME': token.class_name,
'TOKEN_PUBLIC_NAME': token.public_name,
'CROWDSALE_CLASS_NAME': token.crowdsale_class_name,
'TOKEN_SYMBOL_NAME': token.symbol,
'TOKEN_DECIMALS': token.decimals
}
in_fname = os.path.join(settings.SOLIDITY_TEMPLATES_DIR, 'Token.sol.in')
out_fname = os.path.join(settings.SOLIDITY_CONTRACTS_DIR, token.class_name + '.sol')
with open(in_fname, 'r') as in_f, open(out_fname, 'w') as out_f:
template = Template(in_f.read())
out_f.write(template.render(**context))
in_fname = os.path.join(
settings.SOLIDITY_TEMPLATES_DIR, token.token_type + 'Crowdsale.sol.in'
)
out_fname = os.path.join(settings.SOLIDITY_CONTRACTS_DIR,
token.class_name + token.token_type + 'Crowdsale.sol')
with open(in_fname, 'r') as in_f, open(out_fname, 'w') as out_f:
template = Template(in_f.read())
out_f.write(template.render(**context))
评论列表
文章目录