Files
revive/crates/integration/contracts/Selfdestruct.sol
T
xermicus 70037e1136 initial SELFDESTRUCT support (#400)
Note:
- The unstable interface in `v2509.0.0` of `polkadot-sdk` is required.
- The differential test fails against EVM in `v2509.0.0` of
`polkadot-sdk`.

---------

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-11-03 15:04:04 +01:00

67 lines
1.4 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8;
// TODO: This currently fails the differential test.
// The pallet doesn't send the correct balance back.
/* runner.json
{
"differential": false,
"actions": [
{
"Upload": {
"code": {
"Solidity": {
"contract": "SelfdestructTester"
}
}
}
},
{
"Instantiate": {
"code": {
"Solidity": {
"contract": "Selfdestruct"
}
},
"value": 123456789
}
},
{
"Call": {
"dest": {
"Instantiated": 0
}
}
}
]
}
*/
contract Selfdestruct {
address tester;
uint value;
constructor() payable {
require(msg.value > 0, "the test should have value");
value = msg.value;
SelfdestructTester s = new SelfdestructTester{value: msg.value}();
tester = address(s);
}
fallback() external {
(bool success, ) = tester.call(hex"");
require(success, "the call to the self destructing contract should succeed");
}
}
contract SelfdestructTester {
constructor() payable {}
fallback() external {
selfdestruct(payable(msg.sender));
}
}