I'm trying to withdraw from this contract after funding it. After funding it, i checked the balance on goerli etherscan and there was goerliETH in it that i sent but i noticed that once i called withdraw the balance becomes 0 without sending it to my wallet address as intended.

The withdraw transcation was recorded but without any value, but under internal transactions i found out that the balance was transferred to the goerli black hole address.

I can't seem to find a way around this, any help will be greatly appreciated. This is the script below:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract TimeControlled {
    address public owner;
    address[] private ownerArr;
    uint256 dateForWithdrawal;
    address public contractAddress;

    mapping(address => bool) private addressToBool;

    constructor(bool isAllowed) public {
        owner == msg.sender;
        contractAddress == address(this);
        addressToBool[msg.sender] = isAllowed;
        addressToBool[address(this)] = isAllowed;

    // fund the contract and return a true value
    function fund() public payable returns (bool) {
    return true;

    // Check if the contract is being called by the owners
    // Require the owner to be the creators address or the contracts address
    modifier owners() {
        require(addressToBool[msg.sender], "You are not allowed!");

    // withdraw at a certain time
    function withdraw() public payable owners returns (bool) {
        require(address(this).balance > 0);
        return true; /// @notice for withdrawing from the contract
        /// @dev Withdraw by using the owners modifier and returns a boolean value

Note: I deployed this contract from the constructor of another contract that i inherited it into. This is the contract below in case it is needed:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";
import "./Timecontrolled.sol";

contract CallWithdraw is ChainlinkClient, TimeControlled {
    using Chainlink for Chainlink.Request;
    address public linkToken;
    uint256 public oraclePayment;
    address public oracle;
    bytes32 public jobId;
    uint256 public fundingPeriod = 5;

        address _linkToken,
        uint256 _oraclepayment,
        address _oracle,
        bytes32 _jobId
    ) public TimeControlled(true) {
        owner == msg.sender;
        oraclePayment = _oraclepayment;
        linkToken = _linkToken;
        oracle = _oracle;
        jobId = _jobId;

    function callWithdraw() external {
        // if owner does not call the withdraw function at the set time
        // the contract calls withdraw on its own
        require(address(this).balance > 0);
        Chainlink.Request memory req = buildChainlinkRequest(
        req.addUint("until", block.timestamp + fundingPeriod * 1 minutes);
        sendChainlinkRequestTo(oracle, req, oraclePayment);

    function fulfill(bytes32 _requestId)
        address(this).balance == 0;

Also this is my deploy script

from brownie import CallWithdraw, config
from scripts.helpful_scripts import get_account, network, get_contract
from web3 import Web3

oracle_payment = config["networks"][network.show_active()]["payment"]
oracle = config["networks"][network.show_active()]["oracle"]
job_Id = config["networks"][network.show_active()]["jobId"]

def deploy_call_withdraw_and_time_controlled():
    print(f"The network is {network.show_active()}")
    account = get_account()
    link_token = get_contract("link_token")
    print("Deploying contract...")
    call_withdraw = CallWithdraw.deploy(
        {"from": account},
    print("Transferring linktoken...")
        call_withdraw.address, Web3.toWei(1, "ether"), {"from": account}
    print("Linktoken transferred successfully!")

    return call_withdraw

def fund():

    call_withdraw = CallWithdraw[-1]
    account = get_account()
    call_withdraw.fund({"value": Web3.toWei(0.03, "ether"), "from": account})
    print(f"{account.balance()} is the current balance")
    call_withdraw.withdraw({"from": account})
    print(f"{account.balance()} is the current balance")

def get_contract_balance():
    call_withdraw = CallWithdraw[-1]
    print(f"{call_withdraw.balance()} is {call_withdraw.address} balance")

def main():

1 Answer 1


owner == msg.sender; in your constructor ;)

  • Yes i have it in my constructor, both constructors actually. What do i do about it? Sep 28, 2022 at 10:30
  • It's supposed to be =, not ==. "==" tests for equality, "=" sets. (which you probably already know, since you're correctly setting all the other variables everywhere in your code)
    – Foxxxey
    Sep 28, 2022 at 11:18
  • Thank you for responding. I changed the equality operator to assignment like you pointed out, i got the same result. I didn't get a withdrawal to my wallet as intended but an internal transaction occurred to the black hole address. This is the contract address in case you want to take a look on the goerli testnet 0xe2bB3aB7F050078fd8c7669451733f89CDF980e9. @Foxxxey Sep 28, 2022 at 12:46
  • You probably didnt. Your contract isnt verified so i had to do some tricks to read its storage directly, but the owner address is still set to 0. @christianolori
    – Foxxxey
    Sep 28, 2022 at 13:17
  • You were right. After changing the operator, i didn't re-deploy the contract. i just re-deployed it now and interacted with it and it worked! Thanks @Foxxxey. A little operator error can be a pain in the ass! Sep 28, 2022 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.