contracts.py 文件源码

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

项目:saffron 作者: Lamden 项目源码 文件源码
def deploy(self, cwd=False):
        assert not self.is_deployed, 'This contract already exists on the chain.'
        assert self.sol, 'No solidity code loaded into this object'
        response = database.insert_contract(self.name,
                                            self.abi,
                                            self.bytecode,
                                            self.gas_estimates,
                                            self.method_identifiers,
                                            cwd)
        okay = web3.personal.Personal(self.web3)
        options = 'Unlock: \n' + '\n'.join([' '.join([str(i),':',x]) for i, x in enumerate(okay.listAccounts)]) + '\n'
        self.defaultAccount = okay.listAccounts[int(input(options))]
        result = okay.unlockAccount(self.defaultAccount, getpass.getpass('\nPassword:'), 5000)
        if result:
            self.address = self.web3.eth.sendTransaction(transaction={'data' : '0x' + self.bytecode, 'from': self.defaultAccount, 'gaslimit': 30000})
            self.instance = self.web3.eth.contract(self.address)
        else:
            raise Exepction('unable to unlock account')
        #update the deployed and address to the db and an instance for pulling and interacting with the contract again
        return update_contract(json.dumps(self.address), self.method_identifiers, self.name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号