gnosis/safe/safe_creation_tx.py
def _estimate_gas(self,
                      master_copy: str,
                      initializer: bytes,
                      funder: str,
                      payment_token: str) -> int:
        """
        Gas estimation done using web3 and calling the node
        Payment cannot be estimated, as no ether is in the address. So we add some gas later.
        :param master_copy: Master Copy of Gnosis Safe already deployed
        :param initializer: Data initializer to send to GnosisSafe setup method
        :param funder: Address that should get the payment (if payment set)
        :param payment_token: Address if a token is used. If not set, 0x0 will be ether
        :return: Total gas estimation
        """

        # Estimate the contract deployment. We cannot estimate the refunding, as the safe address has not any fund
        gas: int = self._build_proxy_contract_creation_constructor(
            master_copy,
            initializer,
            funder,
            payment_token,
            0).estimateGas()

        # We estimate the refund as a new tx
        if payment_token == NULL_ADDRESS:
            # Same cost to send 1 ether than 1000
            gas += self.w3.eth.estimateGas({'to': funder, 'value': 1})
        else:
            # Top should be around 52000 when storage is needed (funder no previous owner of token),
            # we use value 1 as we are simulating an internal call, and in that calls you don't pay for the data.
            # If it was a new tx sending 5000 tokens would be more expensive than sending 1 because of data costs
            try:
                gas += get_erc20_contract(self.w3,
                                          payment_token).functions.transfer(funder, 1).estimateGas({'from':
                                                                                                    payment_token})
            except ValueError as exc:
                raise InvalidERC20Token from exc

        return gas
def _estimate_gas(self,
                      master_copy: str,
                      initializer: bytes,
                      funder: str,
                      payment_token: str) -> int:
        """
        Gas estimation done using web3 and calling the node
        Payment cannot be estimated, as no ether is in the address. So we add some gas later.
        :param master_copy: Master Copy of Gnosis Safe already deployed
        :param initializer: Data initializer to send to GnosisSafe setup method
        :param funder: Address that should get the payment (if payment set)
        :param payment_token: Address if a token is used. If not set, 0x0 will be ether
        :return: Total gas estimation
        """

        # Estimate the contract deployment. We cannot estimate the refunding, as the safe address has not any fund
        gas: int = self._build_proxy_contract_creation_constructor(
            master_copy,
            initializer,
            funder,
            payment_token,
            0).estimateGas()

        # We estimate the refund as a new tx
        if payment_token == NULL_ADDRESS:
            # Same cost to send 1 ether than 1000
            gas += self.w3.eth.estimateGas({'to': funder, 'value': 1})
        else:
            # Top should be around 52000 when storage is needed (funder no previous owner of token),
            # we use value 1 as we are simulating an internal call, and in that calls you don't pay for the data.
            # If it was a new tx sending 5000 tokens would be more expensive than sending 1 because of data costs
            try:
                gas += get_erc20_contract(self.w3,
                                          payment_token).functions.transfer(funder, 1).estimateGas({'from':
                                                                                                    payment_token})
            except ValueError as exc:
                raise InvalidERC20Token from exc

        return gas
def _estimate_gas ( self , master_copy : str , initializer : bytes , funder : str , payment_token : str ) -> int : # Estimate the contract deployment. We cannot estimate the refunding, as the safe address has not any fund gas : int = self . _build_proxy_contract_creation_constructor ( master_copy , initializer , funder , payment_token , 0 ) . estimateGas ( ) # We estimate the refund as a new tx if payment_token == NULL_ADDRESS : # Same cost to send 1 ether than 1000 gas += self . w3 . eth . estimateGas ( { 'to' : funder , 'value' : 1 } ) else : # Top should be around 52000 when storage is needed (funder no previous owner of token), # we use value 1 as we are simulating an internal call, and in that calls you don't pay for the data. # If it was a new tx sending 5000 tokens would be more expensive than sending 1 because of data costs try : gas += get_erc20_contract ( self . w3 , payment_token ) . functions . transfer ( funder , 1 ) . estimateGas ( { 'from' : payment_token } ) except ValueError as exc : raise InvalidERC20Token from exc return gas
Gas estimation done using web3 and calling the node
        Payment cannot be estimated, as no ether is in the address. So we add some gas later.
        :param master_copy: Master Copy of Gnosis Safe already deployed
        :param initializer: Data initializer to send to GnosisSafe setup method
        :param funder: Address that should get the payment (if payment set)
        :param payment_token: Address if a token is used. If not set, 0x0 will be ether
        :return: Total gas estimation
Gas estimation done using web3 and calling the node Payment cannot be estimated as no ether is in the address . So we add some gas later . : param master_copy : Master Copy of Gnosis Safe already deployed : param initializer : Data initializer to send to GnosisSafe setup method : param funder : Address that should get the payment ( if payment set ) : param payment_token : Address if a token is used . If not set 0x0 will be ether : return : Total gas estimation