예제 #1
0
파일: async_tron.py 프로젝트: andelf/tronpy
    def deploy_contract(self, owner: TAddress, contract: AsyncContract) -> "AsyncTransactionBuilder":
        """Deploy a new contract on chain."""
        contract._client = self.client
        contract.owner_address = owner
        contract.origin_address = owner
        contract.contract_address = None

        return contract.deploy()
예제 #2
0
    async def get_contract(self, addr: TAddress) -> AsyncContract:
        """Get a contract object."""
        addr = keys.to_base58check_address(addr)
        info = await self.provider.make_request("wallet/getcontract", {
            "value": addr,
            "visible": True
        })

        try:
            self._handle_api_error(info)
        except ApiError:
            # your java's null pointer exception sucks
            raise AddressNotFound("contract address not found")

        cntr = AsyncContract(
            addr=addr,
            bytecode=info.get("bytecode", ''),
            name=info.get("name", ""),
            abi=info.get("abi", {}).get("entrys", []),
            origin_energy_limit=info.get("origin_energy_limit", 0),
            user_resource_percent=info.get("consume_user_resource_percent",
                                           100),
            client=self,
        )
        return cntr