We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [selfdestruct]

opcode for deleting a contract, original opcode called SUICIDE

Filter by
Sorted by
Tagged with
44
votes
5answers
20k 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 ...
21
votes
5answers
17k 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 ...
12
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
284 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 ...
8
votes
1answer
211 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 ...
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
137 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 { ...
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
636 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
1answer
1k views

What happens after selfdestruct is called?

https://ropsten.etherscan.io/address/0xf825d3b3d06a4b46379a3c276df7f26abd055463 After selfdestruct call was made, all the balance was transferred to the deployer of the contract. Why are withdraw ...
4
votes
2answers
81 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
285 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
128 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
163 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
258 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
173 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?
3
votes
0answers
303 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
1answer
248 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
2answers
39 views

Can you selfdestruct a contract more than once?

I read the Contract's state after a selfdestruct thread, but it doesn't answer the question whether you can selfdestruct multiple times.
2
votes
1answer
194 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
278 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
1answer
34 views

After a suicide operation, is contract’s nonce reset to 0?

Simple question, but I couldn’t find the answer in the yellow paper. Is it reset to 0 or is it kept at the latest value before destruction ?
2
votes
0answers
288 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
123 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
1k 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
179 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
34 views

Do events get emitted when calling selfdestruct()?

Are event emitted when a contract calls selfdestruct?
1
vote
1answer
663 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
80 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
1answer
191 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 ...
1
vote
2answers
159 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
1answer
31 views

What happens when a suicide operation transfer remaining funds to it’s own contract address?

equivalent solidity code : suicide(this); Does the operation succeeds at not transferring the balances while still erasing the code ? Or is contract’s code destroyed only after sending balances ...
1
vote
2answers
193 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
162 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
405 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
124 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
45 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
500 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
574 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
61 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
276 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
56 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
175 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
99 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
45 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
81 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 ...