contracts.py 文件源码

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

项目:saffron 作者: Lamden 项目源码 文件源码
def __init__(self, name, sol_file_path):
        assert name != None, 'A name identifier must be provided to create a new contract instance.'
        _name, _address = database.contract_exists(name=name)
        assert _name is None and _address is None
        node_info = json.loads(open(os.environ['NODE_INFO_JSON']).read())
        self.web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:{port}".format(port=node_info.get('rpcport'))))
        self.name = name
        self.is_deployed = None
        with open(sol_file_path) as f:
            self.sol = load_sol_file(f)
        self.template_json = Environment().from_string(database.input_json).render(name=self.name, sol=json.dumps(self.sol))
        self.output_json = compile_standard(json.loads(self.template_json))
        self.compiled_name = list(self.output_json['contracts'][self.name].keys())[0]
        self.contracts = self.output_json['contracts'][self.name][self.compiled_name]
        self.abi = self.contracts['abi']
        self.metadata = self.contracts['metadata']
        self.bytecode = self.contracts['evm']['deployedBytecode']['object']
        self.gas_estimates = self.contracts['evm']['gasEstimates']
        self.method_identifiers = self.contracts['evm']['methodIdentifiers']

        # set in deploy
        self.address = None
        self.instance = None
        self.defaulAccount = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号