ethers_core/types/
withdrawal.rs

1use crate::types::{Address, U256, U64};
2use serde::{Deserialize, Serialize};
3
4/// A validator withdrawal from the consensus layer.
5/// See EIP-4895: Beacon chain push withdrawals as operations.
6#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7pub struct Withdrawal {
8    /// Monotonically increasing identifier issued by consensus layer
9    pub index: U64,
10
11    /// Index of validator associated with withdrawal
12    #[serde(rename = "validatorIndex")]
13    pub validator_index: U64,
14
15    /// Target address for withdrawn ether
16    pub address: Address,
17
18    /// Value of withdrawal (in wei)
19    pub amount: U256,
20}
21
22impl rlp::Encodable for Withdrawal {
23    fn rlp_append(&self, s: &mut rlp::RlpStream) {
24        s.begin_list(4);
25        s.append(&self.index);
26        s.append(&self.validator_index);
27        s.append(&self.address);
28        s.append(&self.amount);
29    }
30}