pub enum Erc20Call {
Transfer {
to: [u8; 20],
amount: U256,
},
Approve {
spender: [u8; 20],
amount: U256,
},
TransferFrom {
from: [u8; 20],
to: [u8; 20],
amount: U256,
},
}Expand description
Parsed ERC-20 function call.
Represents one of the three primary ERC-20 functions with their decoded parameters.
§Examples
use txgate_chain::erc20::Erc20Call;
use alloy_primitives::U256;
let transfer = Erc20Call::Transfer {
to: [0x12; 20],
amount: U256::from(1_000_000u64),
};
let approve = Erc20Call::Approve {
spender: [0x34; 20],
amount: U256::MAX, // Unlimited approval
};
let transfer_from = Erc20Call::TransferFrom {
from: [0x12; 20],
to: [0x34; 20],
amount: U256::from(500_000u64),
};Variants§
Transfer
ERC-20 transfer(address to, uint256 amount) call.
Transfers amount tokens from the caller to to.
Fields
Approve
ERC-20 approve(address spender, uint256 amount) call.
Approves spender to transfer up to amount tokens on behalf of the caller.
Fields
TransferFrom
ERC-20 transferFrom(address from, address to, uint256 amount) call.
Transfers amount tokens from from to to, using the caller’s allowance.
Implementations§
Source§impl Erc20Call
impl Erc20Call
Sourcepub const fn recipient(&self) -> &[u8; 20]
pub const fn recipient(&self) -> &[u8; 20]
Returns the actual recipient address for this call.
For Transfer and TransferFrom, returns the to address.
For Approve, returns the spender address.
Sourcepub const fn is_transfer(&self) -> bool
pub const fn is_transfer(&self) -> bool
Returns true if this is a transfer operation (Transfer or TransferFrom).
Sourcepub const fn is_approval(&self) -> bool
pub const fn is_approval(&self) -> bool
Returns true if this is an approval operation.
Trait Implementations§
impl Eq for Erc20Call
impl StructuralPartialEq for Erc20Call
Auto Trait Implementations§
impl Freeze for Erc20Call
impl RefUnwindSafe for Erc20Call
impl Send for Erc20Call
impl Sync for Erc20Call
impl Unpin for Erc20Call
impl UnwindSafe for Erc20Call
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more