utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:ethane 作者: onyb 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号