Get Contracts Self-Destructions
Overview
The Get Contracts Self-Destructions endpoint obtains data on smart contracts' self-destructions.
At least one of the following parameters must be specified: contract
, origin
, or caller
.
The range should be defined by either block_number
, timestamp
, or block_hash
.
Multiple values can be set for the contract
parameter with a maximum of five items.
Use Cases
Several possible combinations of parameters should be considered, where origin
refers to the address
of an EOA wallet, contract
is the address of a smart contract being self-destructed, caller
represents the
address of a smart contract that triggers the self-destruction of another smart contract. To retrieve specific
details about contracts' self-destructions, follow the guidelines below.
- For getting data on a contract's self-destruction, specify
contract
. - For all contracts' self-destructions initiated by an EOA wallet, specify
origin
. - For all contracts' self-destructions triggered by another smart contract, specify
caller
. - For all contracts' elf-destructions triggered by another smart contract but initiated by
an EOA wallet, specify both
origin
andcaller
.
The caller
and origin
parameters can both represent an EOA wallet but the actual purpose
of the caller
field is to be used as the smart contract's address that triggers the self-destruction
of another smart contract.
Querying via Postman
If you prefer querying via Postman, the description of PARSIQ Endpoints for Get Contracts Self-Destructions (opens in a new tab) might come in handy. There you will find examples and responses for good and bad requests as well as parameter definitions and their example values.
Usage
In this example, we receive data from all blocks where the origin
address 0xcc2c2cd417a9c39cf0e48622988dbec0b1b37064
initiated the self-destruction of contract 0xfc934b64a945b0c99e09b9c137dabe271a5a1a06
through another smart contract
0x19dfe459b4ac00d9cbcc237159d5f1e48205e123
specified as caller
.
import * as Parsiq from '@parsiq/parsiq.js';
const client = Parsiq.createClient(process.env.API_KEY, Parsiq.ChainId.ETH_MAINNET);
const selfDestructions = client.contracts.selfDestructions.getByBlockRange(
1, 'latest',
{
contract: ['0xfc934b64a945b0c99e09b9c137dabe271a5a1a06'],
origin: '0xcc2c2cd417a9c39cf0e48622988dbec0b1b37064',
caller: '0x19dfe459b4ac00d9cbcc237159d5f1e48205e123'
},
{
limit: 1
}
);
for await (const selfDestruction of selfDestructions) {
console.log(selfDestruction);
}
Output:
{
id: '0000000000250d98-0007-00000003',
contract: '0xfc934b64a945b0c99e09b9c137dabe271a5a1a06',
caller: '0x19dfe459b4ac00d9cbcc237159d5f1e48205e123',
tx_hash: '0xcd5c2996bacdf42bba4c1dc66b453df6a92b77f86a7f575a706487da001c1650',
block_hash: '0x62094ff27e5aa257dab3a2798370d207996d0814933c585d79fc6efc73f7ac2a',
data: null,
origin: '0xcc2c2cd417a9c39cf0e48622988dbec0b1b37064',
block_number: 2428312,
timestamp: 1476300836,
value: '0',
op_code: 'SELFDESTRUCT'
}
Parameters
chainId
version
block_number_start
block_number_end
origin
contract
caller
offset
limit
estimate_cu