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)
评论列表
文章目录