Questions tagged [selfdestruct]

opcode for deleting a contract, original opcode called SUICIDE

Filter by
Sorted by
Tagged with
41
votes
3answers
19k views

Why are selfdestructs used in contract programming?

I'm reading bits and pieces that selfdestructs within contracts are a good thing. Can someone explain what the benefits are of doing a contract selfdestruct when it comes to Ethereum programming? Is ...
18
votes
4answers
16k views

How can I return struct when function is called?

I'd like to return struct type User. However, when I tried the following getUser function, it returns an error. Is there any way that struct data would be returned from a function? Contract struct ...
11
votes
3answers
4k views

Contract's state after a Selfdestruct

What happens to the state of a smart contract when it is selfdestruct. Are the last state variables still visible on the blockchain afterwards?
9
votes
1answer
261 views

How was the state-bloat attack that led to the EIP 150 hardfork performed?

I understand that SELFDESTRUCT and mispricing of opcodes allowed many empty accounts to be created cheaply as explained in Why were empty accounts allowed to be on the blockchain? The answer to that ...
7
votes
3answers
1k views

What is actually removed during a contract suicide, and why doesn't this cause the blockchain to change?

I'm trying to get my head around how contract suicides work, and what actually happens during them. I understand why we use them. This post states that when the SUICIDE opcode is executed, the data ...
7
votes
1answer
4k views

how can a contract destroy other contract (suicide accounts)?

I learnt from the yellowpaper that at the end of a contract execution, there could be a list of suicide accounts that will be removed. my question is, why and how would one smart contract remove ...
7
votes
1answer
135 views

Is a suiciding contract susceptible to re-entrancy?

If my contract calls suicide() referencing a contract as the recipient of funds, and that recipient contract default function calls back into my contract, will the call succeed? contract A { ...
7
votes
1answer
208 views

When does a SUICIDE opcode becomes effective?

The documentation (https://github.com/ethereum/wiki/wiki/Subtleties) states that SUICIDE becomes effective at the end of the transaction, but in block 116525, the same contract was able to SUICIDE ...
5
votes
2answers
1k views

Will contract selfdestruct also return tokens?

If I have tokens assigned to a smart contract, will "killing" the contract send leftover tokens to the owner of the contract? I know that remaining Ether stored in the contract is sent to owner in ...
4
votes
1answer
629 views

How to suicide existing contract?

Is there any way to suicide contract which was never designed for that? If so what will happen with ethers that this contract is holding?
4
votes
2answers
73 views

Understanding the formal description of a transaction and its associated refunds

Excerpt from page 8 of the yellow paper: I fully understand that contracts can self-destruct and, when that happens, according to this thread, all the balance is refunded to the address specified as ...
4
votes
1answer
270 views

Question about suicide traces in Parity

I use Parity's trace facility extensively to help me account for all transactions on individual accounts. I've been able to get almost complete accuracy (off-chain) of account balances for each block, ...
4
votes
2answers
127 views

Calculate how much space can be saved after self-destructing a contract

I want to do some brief analysis to quantify how much one could free when self-destructing a contract. How could I calculate how much space can nodes save when selfdestructing a given contract? I ...
3
votes
3answers
3k views

How to kill crowdsale contract?

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 ...
3
votes
2answers
161 views

Is a race possible when checking the contract for liveness?

I wonder if a race is possible when performing a check of a return value of a call similar to eth.getCode(greeter.contractAddress) for being zero. That is, is it possible that the contract was alive ...
3
votes
1answer
857 views

What is happening after a self destruct is called for?

https://ropsten.etherscan.io/address/0xf825d3b3d06a4b46379a3c276df7f26abd055463 After the self-destruct call was made, all the balance was transferred to the deployer of the contract. Why are ...
3
votes
1answer
253 views

Should governance and token smart contracts be “unstoppable” or upgradeable? [closed]

Selfdestruct (aka suicide) functions stop contracts from functioning and clean up data on the blockchain. They can be used in upgrading contracts. Selfdestructing and upgradable contracts using a ...
3
votes
1answer
162 views

Why are there multiple suicide calls from one address to a contract in the same block?

There are several contracts whose internal Tx have only suicide calls from the same contract/user address over and over again. What is the need of having multiple calls?
2
votes
1answer
239 views

Can I redeploy a previous self-destructed smart contract?

If I deploy a smart contract, and then self destruct it. Then later send it ether by mistake, can I re-deploy it and be able to access that "lost" ether through the smart contract?
2
votes
1answer
132 views

How can I call contract method that suicide and continue execution?

Can I call another contract that eventually will call selfdestruct, and keep executing my function? For example, say I have two contracts as follows: contract Destructor { address owner; ...
2
votes
1answer
264 views

Overriding Solidity selfdestruct

I create a contract and implement a cleanup function like this modifier ownerOnly { if(msg.sender != owner) revert(); _; } function cleanup() public ownerOnly { if(!canDelete()) { //...
2
votes
0answers
292 views

Upgrading the truffle Migrations contract

In the standard truffle migrations contract the purpose of the upgrade function is upgrade the Migrations contract itself by copying the last_completed_migration of the old Migrations contract to the ...
2
votes
0answers
273 views

how can I detect if an address contained a contract that called selfdestruct?

I would like to create a web3-based JS function like this: function hasSelfDestructed(address) { if (... address was a contract, but has called selfdestruct ...) return true else return ...
2
votes
2answers
104 views

is selfdestruct a good practice?

A contract after selfdestruct cannot manage transactions, and as such any ether sent to it is lost. Wouldn't be better to switch to a contract defined state "dismissed" and reject any ether sent by ...
1
vote
1answer
638 views

Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested

function endSuply() public { require(msg.sender == admin,"only admin can end the token sale"); require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))),"balance not ...
1
vote
1answer
174 views

Does a selfdestruct affect child contracts?

Say, I create a smart contract A and this contract creates another smart contract B. If I call selfdestruct on A, will this affect in any way contract B? Or can I still call functions on B after A is ...
1
vote
2answers
32 views

Do events get emitted when calling selfdestruct()?

Are event emitted when a contract calls selfdestruct?
1
vote
1answer
607 views

Solidity - selfdestruct

I'm just wondering what would happen if I don't put a selfdestrut() method in my smart contract. As I read from the Solidity documentation (Self-destruct): Even if a contract’s code does not ...
1
vote
1answer
78 views

Kamikaze contracts

Compiling a simple contract on Remix with the most recent nightly I get the following warning "Use of selfdestruct can block calling contracts unexpectedly. Be especially careful if this ...
1
vote
2answers
154 views

Does not killing an old contract bloat the blockchain?

I deployed and tested a contract (on testnet, but the same question goes for mainnet too), now I'm finished with it, moved on to new contracts. Should I remove the old one? Does it do any harm, ...
1
vote
2answers
144 views

“Self-destruct” use cases?

According to solidity.readthedocs.io (Link) here is the definition of Self-destruct: "Definition: The only way to remove code from the blockchain is when a contract at that address performs the ...
1
vote
1answer
135 views

contract kill function

as per ethereum docs Even if a contract’s code does not contain a call to selfdestruct, it can still perform that operation using delegatecall or callcode. is this real? 1.if it is then even if ...
1
vote
1answer
392 views

Why does selfdestruct() have an address requirement?

Why must selfdestruct take the contract's original msg.sender argument? Isn't the idea that it 'self' destructs?
1
vote
1answer
111 views

Does SUICIDE also free up stored hashes? [duplicate]

Here's a contract: pragma solidity ^0.4.19; contract StoreAndFree { mapping(int=>int) myStore; function StoreAndFree() public { for (int i=1; i<100; i++) { myStore[...
1
vote
1answer
1k views

Self-destruct token contract

If token contract 'Bob' has no delegatecalls/ selfdestruct functionality but I transfer the ownership of the contract to contract 'Mallory' and this contract HAS selfdestruct functionality, then the ...
1
vote
0answers
41 views

How can I see the transactions which move funds from a destroyed contract?

I got this external account from which I called a function of this contract which subsequently called selfdestruct and sent all the funds to the caller. Where can I see the tx making this transfer? ...
1
vote
1answer
432 views

Smart Contract storage

I was about to create my first smart contract which I came across these questions: Where exactly the contract code gets stored, I read that it kind of stores in blockchain so does that mean every ...
1
vote
1answer
502 views

How selfdestruct() works?

I'm wondering about how selfdestruct() actually works. Does it actually delete contract codes from the storage? Or just delete the contract address from state trie? If just deleting the contract ...
0
votes
1answer
46 views

Check if contract is destructed

Once a contract is no longer valid (eg after calling selfdestruct on it), one can still call functions on it although the contract won't behave as expected. In javascript, how can one check if the ...
0
votes
2answers
209 views

Self Destruct Transaction

how to make transaction like THIS TRANSACTION anyone can help me how to build it
0
votes
1answer
27 views

Short of running one's own node, how can I see the code of suicided contracts?

I'm interested in looking at the code in instances of the Parity Multisig wallet attacks, but the contracts have self-destructed. How can I get ahold of the exact bytecode that was executed in a given ...
0
votes
2answers
35 views

Self Destruct Design pattern - Loss of funds issue

I was exploring on self destruct design pattern for a time bound smart contract. So my contract should not accept any further state change after a certain given time period. While working on that I ...
0
votes
2answers
144 views

Mocha test at kill() function

How to test with Mocha and Chai that a call at the kill() function of a Smart Contract (i.e., which does the selfdestruct) has gone right?
0
votes
1answer
88 views

converting “now” to “day”?

Consider we need to determine an expiry date for a contract such that after this date the contract will be destroyed as follows: uint256 public expiryDate; constructor(uint256 duration) ...
0
votes
1answer
38 views

Since ERC token names, symbols cannot be reserved, anyone recommend selfdestruct/suicide method call?

As we know contracts are unique .. has anyone 'reserved' a token name/ symbol before final deployment, by putting a suicide by owner method.. so this dummy can be 'removed' just before the same token ...
0
votes
1answer
75 views

Is it possible to run out of gas in a method before reaching the self-destruct call?

I'd like to implement a self-destruct method for a smart contract that pools money from people as a last resort. Before calling self-destruct, I'd like to refund all the money to the users and send ...
0
votes
1answer
68 views

What happens to old contracts?

Say the makers of a contract all die so no one left has a stake in or knows or cares about that contract. Say the contract never calls self-destruct on itself. What happens to this old, unused ...
0
votes
1answer
145 views

Explain the multi-sig wallet loss by deletion of “code”? [duplicate]

In recent news about the potential loss of 300M USD. Could someone please explain how it is possible to "kill" a number multi-sig wallets by removing code? As a programmer I fail to understand how ...
0
votes
1answer
46 views

How does contract know where the fund (or the amount of Ether) is by executing “suicide”?

It's said if we run: suicide(address recipient); At the end of the contract, the recipient will receive the amount of Ether owned by the contract. Question 1: How does the contract (and this ...
0
votes
1answer
181 views

Self destruct to multiple parties?

var endval = this.balance / 2; counterparty1.send(endval); counterparty2.send(endval); selfdestruct(creator); Is there anyway to selfdestruct to two parties? I have the code above, but now you ...