3

I want to just simply kill this contract what code do i type into the get console to kill this contract so that the funds are returned to the owner which is me. Please let me know how you did it so I can apply the geth command code to kill my other contracts as well.

contract address: 0x999d5f024439A0EcfD554753e9E4A9eDa9261B73

JSON:

[ { "constant": false, "inputs": [], "name": "checkGoalReached", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "deadline", "outputs": [ { "name": "", "type": "uint256", "value": "1496312040" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "beneficiary", "outputs": [ { "name": "", "type": "address", "value": "0x64c0118a896bb075448a7f0cd6e760a41cff800c" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "tokenReward", "outputs": [ { "name": "", "type": "address", "value": "0x64c0118a896bb075448a7f0cd6e760a41cff800c" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "", "type": "uint256", "value": "0" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "fundingGoal", "outputs": [ { "name": "", "type": "uint256", "value": "1e+22" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "amountRaised", "outputs": [ { "name": "", "type": "uint256", "value": "200000000000000000" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "price", "outputs": [ { "name": "", "type": "uint256", "value": "1e+21" } ], "payable": false, "type": "function" }, { "constant": false, "inputs": [], "name": "safeWithdrawal", "outputs": [], "payable": false, "type": "function" }, { "inputs": [ { "name": "ifSuccessfulSendTo", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "if Successful Send To", "template": "elements_input_address" }, { "name": "fundingGoalInEthers", "type": "uint256", "index": 1, "typeShort": "uint", "bits": "256", "displayName": "funding Goal In Ethers", "template": "elements_input_uint" }, { "name": "durationInMinutes", "type": "uint256", "index": 2, "typeShort": "uint", "bits": "256", "displayName": "duration In Minutes", "template": "elements_input_uint" }, { "name": "etherCostOfEachToken", "type": "uint256", "index": 3, "typeShort": "uint", "bits": "256", "displayName": "ether Cost Of Each Token", "template": "elements_input_uint" }, { "name": "addressOfTokenUsedAsReward", "type": "address", "index": 4, "typeShort": "address", "bits": "", "displayName": "address Of Token Used As Reward", "template": "elements_input_address" } ], "payable": false, "type": "constructor" }, { "payable": true, "type": "fallback" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "beneficiary", "type": "address" }, { "indexed": false, "name": "amountRaised", "type": "uint256" } ], "name": "GoalReached", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "backer", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" }, { "indexed": false, "name": "isContribution", "type": "bool" } ], "name": "FundTransfer", "type": "event" } ]

10
  • 2
    Hi there. Do you have the actual Solidity code, rather than the ABI? It would make it easier for people to read the flow of your contract... Commented Jul 8, 2017 at 8:19
  • I do not I am really new to this I created this contract over 3 months ago by just copying the code the ethereum website offered which back then was basically copy code and create a coin. Then copy code to create the crowdfund.
    – tyco
    Commented Jul 8, 2017 at 8:49
  • The only drop down options the contract gives me is the check goal reached and the safe withdrawal which both do not work. I know I did not write the contract wrong because I just copied what the said to copy. Maybe I am missing something easy but the safe withdrawal does nothing and it attempts to put money into the crowdsale from the looks of it which is not what I want. That is when I looked up just killing the contract however I do not know the exact code for the geth console
    – tyco
    Commented Jul 8, 2017 at 8:53
  • When I was creating this contract the greeter code was not even available from what I saw and the only info I can find is how to kill the greeter contract. If I can just know the command to kill this contract I would be fine.
    – tyco
    Commented Jul 8, 2017 at 8:54
  • 1
    @tyco Do you remember which tutorial were you following?
    – Ismael
    Commented Jul 8, 2017 at 22:15

3 Answers 3

4

Ethereum smart contracts are immutable. You cannot change their source code once they are deployed. You should have included the kill/suicide/selfdestruct code before deployment. However, I see two functions in the ABI that might be useful, one is safeWithdrawal and the other is ifSuccessfulSendTo. The second one is a variable I guess, but it looks like the contract already has a function that uses this. But the first one is definitely a function. Have you tried executing it?

2
  • Yes when i execute the safe withdrawal it executes on the blockchain and says ethereum is sent but it never is tranferred. Also it seems to be set up to deposit ethereum from my wallet into the contract. I want to just get all the ethereum out of the contract. Again I just copied the code that ethereum provided me a few months ago before their was any greeter tutorials or anything like that.
    – tyco
    Commented Jul 9, 2017 at 0:04
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – eth
    Commented Jul 9, 2017 at 2:33
2

It does not look like you have any function included in the contract that makes the contract "killable" or mortal. As Ethereum contracts are immutable as soon as they are deployed to the Blockchain there is no way to add a kill method after they are deployed. For your future contracts I'd recommend you to inherit from a mortal contract that specifies the kill switch and then let all you contracts inherit from this contract. It looks like this:

contract owned {

    address owner;

    /*this function is executed at initialization and sets the owner of the contract */
    function owned() { owner = msg.sender; }

    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }
}

contract mortal is owned {

    /* Function to recover the funds on the contract */
    function kill() onlyOwner() {
        selfdestruct(owner);
    }

}

contract yourContract is owned, mortal {
    // Your contract logic goes here
}

This way you will always be able to kill your contracts. Your contract the way you presented is neither mortal nor killable.

If you find this answer because you were looking at the tutorial Crowdsale by the Ethereum foundation then be advised that you can use the function safeWithdrawal to withdraw funds. There are some prerequisites:

  • The crowdsale has to be over (afterDeadline)
  • You have to withdraw the funds with the same account that you used for transferring the funds to the Crowdsale contract
  • You can only withdraw as much as you put into the contract.
2
  • That option was not available when i created this contract and I just copied the code that the ethereum website provided. Is there a code I can enter into my geth consolle that would at least return the funds of that contract to the owner or the contributors which are all me in this case.
    – tyco
    Commented Jul 8, 2017 at 9:46
  • I really hope my ethereum is not trapped by creating those crowdfund sale contracts. That would suck..
    – tyco
    Commented Jul 8, 2017 at 10:20
0

You can't release the funds all at once if it was funded from multiple addresses

  1. Open the Crowd sale Contract on Mist Ethereum Wallet
  2. From Write From Contract, Select Function Safe Withdrawal
  3. Execute from the account that sent the refund and you should be refunded

you can see the latest transaction from an account page, do you have the tx hash or address you are trying to get a refund at?

Your Answer

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

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