Struct odra_modules::erc20::Erc20HostRef
source · pub struct Erc20HostRef { /* private fields */ }Expand description
Erc20 Host Ref.
Implementations§
source§impl Erc20HostRef
impl Erc20HostRef
sourcepub fn init(
&mut self,
symbol: String,
name: String,
decimals: u8,
initial_supply: Option<U256>
)
pub fn init( &mut self, symbol: String, name: String, decimals: u8, initial_supply: Option<U256> )
Initializes the contract with the given metadata and initial supply.
sourcepub fn transfer(&mut self, recipient: &Address, amount: &U256)
pub fn transfer(&mut self, recipient: &Address, amount: &U256)
Transfers tokens from the caller to the recipient.
sourcepub fn transfer_from(
&mut self,
owner: &Address,
recipient: &Address,
amount: &U256
)
pub fn transfer_from( &mut self, owner: &Address, recipient: &Address, amount: &U256 )
Transfers tokens from the owner to the recipient using the spender’s allowance.
sourcepub fn approve(&mut self, spender: &Address, amount: &U256)
pub fn approve(&mut self, spender: &Address, amount: &U256)
Approves the spender to spend the given amount of tokens on behalf of the caller.
sourcepub fn total_supply(&self) -> U256
pub fn total_supply(&self) -> U256
Returns the total supply of the token.
sourcepub fn balance_of(&self, address: &Address) -> U256
pub fn balance_of(&self, address: &Address) -> U256
Returns the balance of the given address.
sourcepub fn allowance(&self, owner: &Address, spender: &Address) -> U256
pub fn allowance(&self, owner: &Address, spender: &Address) -> U256
Returns the amount of tokens the owner has allowed the spender to spend.
source§impl Erc20HostRef
impl Erc20HostRef
sourcepub fn try_init(
&mut self,
symbol: String,
name: String,
decimals: u8,
initial_supply: Option<U256>
) -> OdraResult<()>
pub fn try_init( &mut self, symbol: String, name: String, decimals: u8, initial_supply: Option<U256> ) -> OdraResult<()>
Initializes the contract with the given metadata and initial supply.
Does not fail in case of error, returns odra::OdraResult instead.
sourcepub fn try_transfer(
&mut self,
recipient: &Address,
amount: &U256
) -> OdraResult<()>
pub fn try_transfer( &mut self, recipient: &Address, amount: &U256 ) -> OdraResult<()>
Transfers tokens from the caller to the recipient.
Does not fail in case of error, returns odra::OdraResult instead.
sourcepub fn try_transfer_from(
&mut self,
owner: &Address,
recipient: &Address,
amount: &U256
) -> OdraResult<()>
pub fn try_transfer_from( &mut self, owner: &Address, recipient: &Address, amount: &U256 ) -> OdraResult<()>
Transfers tokens from the owner to the recipient using the spender’s allowance.
Does not fail in case of error, returns odra::OdraResult instead.
sourcepub fn try_approve(
&mut self,
spender: &Address,
amount: &U256
) -> OdraResult<()>
pub fn try_approve( &mut self, spender: &Address, amount: &U256 ) -> OdraResult<()>
Approves the spender to spend the given amount of tokens on behalf of the caller.
Does not fail in case of error, returns odra::OdraResult instead.
sourcepub fn try_name(&self) -> OdraResult<String>
pub fn try_name(&self) -> OdraResult<String>
Returns the name of the token.
Does not fail in case of error, returns odra::OdraResult instead.
sourcepub fn try_symbol(&self) -> OdraResult<String>
pub fn try_symbol(&self) -> OdraResult<String>
Returns the symbol of the token.
Does not fail in case of error, returns odra::OdraResult instead.
sourcepub fn try_decimals(&self) -> OdraResult<u8>
pub fn try_decimals(&self) -> OdraResult<u8>
Returns the number of decimals the token uses.
Does not fail in case of error, returns odra::OdraResult instead.
sourcepub fn try_total_supply(&self) -> OdraResult<U256>
pub fn try_total_supply(&self) -> OdraResult<U256>
Returns the total supply of the token.
Does not fail in case of error, returns odra::OdraResult instead.
sourcepub fn try_balance_of(&self, address: &Address) -> OdraResult<U256>
pub fn try_balance_of(&self, address: &Address) -> OdraResult<U256>
Returns the balance of the given address.
Does not fail in case of error, returns odra::OdraResult instead.
sourcepub fn try_allowance(
&self,
owner: &Address,
spender: &Address
) -> OdraResult<U256>
pub fn try_allowance( &self, owner: &Address, spender: &Address ) -> OdraResult<U256>
Returns the amount of tokens the owner has allowed the spender to spend.
Does not fail in case of error, returns odra::OdraResult instead.
Trait Implementations§
source§impl EntryPointsCallerProvider for Erc20HostRef
impl EntryPointsCallerProvider for Erc20HostRef
source§fn entry_points_caller(env: &HostEnv) -> EntryPointsCaller
fn entry_points_caller(env: &HostEnv) -> EntryPointsCaller
source§impl HostRef for Erc20HostRef
impl HostRef for Erc20HostRef
source§fn new(address: Address, env: HostEnv) -> Self
fn new(address: Address, env: HostEnv) -> Self
source§fn with_tokens(&self, tokens: U512) -> Self
fn with_tokens(&self, tokens: U512) -> Self
source§fn get_event<T>(&self, index: i32) -> Result<T, EventError>where
T: FromBytes + EventInstance,
fn get_event<T>(&self, index: i32) -> Result<T, EventError>where
T: FromBytes + EventInstance,
source§fn last_call(&self) -> ContractCallResult
fn last_call(&self) -> ContractCallResult
Auto Trait Implementations§
impl Freeze for Erc20HostRef
impl !RefUnwindSafe for Erc20HostRef
impl !Send for Erc20HostRef
impl !Sync for Erc20HostRef
impl Unpin for Erc20HostRef
impl !UnwindSafe for Erc20HostRef
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
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.source§impl<T> HostRefLoader for Twhere
T: EntryPointsCallerProvider + HostRef,
impl<T> HostRefLoader for Twhere
T: EntryPointsCallerProvider + HostRef,
source§impl<T> PipeAsRef for T
impl<T> PipeAsRef for T
source§impl<T> PipeBorrow for T
impl<T> PipeBorrow for T
source§impl<T> PipeDeref for T
impl<T> PipeDeref for T
source§impl<T> PipeRef for T
impl<T> PipeRef for T
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_dbg<F, R>(self, func: F) -> Self
fn tap_dbg<F, R>(self, func: F) -> Self
tap in debug builds, and does nothing in release builds.source§fn tap_mut_dbg<F, R>(self, func: F) -> Self
fn tap_mut_dbg<F, R>(self, func: F) -> Self
tap_mut in debug builds, and does nothing in release builds.source§impl<T, U> TapAsRef<U> for Twhere
U: ?Sized,
impl<T, U> TapAsRef<U> for Twhere
U: ?Sized,
source§fn tap_ref<F, R>(self, func: F) -> Self
fn tap_ref<F, R>(self, func: F) -> Self
source§fn tap_ref_dbg<F, R>(self, func: F) -> Self
fn tap_ref_dbg<F, R>(self, func: F) -> Self
tap_ref in debug builds, and does nothing in release builds.source§fn tap_ref_mut<F, R>(self, func: F) -> Self
fn tap_ref_mut<F, R>(self, func: F) -> Self
source§impl<T, U> TapBorrow<U> for Twhere
U: ?Sized,
impl<T, U> TapBorrow<U> for Twhere
U: ?Sized,
source§fn tap_borrow<F, R>(self, func: F) -> Self
fn tap_borrow<F, R>(self, func: F) -> Self
source§fn tap_borrow_dbg<F, R>(self, func: F) -> Self
fn tap_borrow_dbg<F, R>(self, func: F) -> Self
tap_borrow in debug builds, and does nothing in release builds.source§fn tap_borrow_mut<F, R>(self, func: F) -> Self
fn tap_borrow_mut<F, R>(self, func: F) -> Self
source§impl<T> TapDeref for T
impl<T> TapDeref for T
source§fn tap_deref_dbg<F, R>(self, func: F) -> Self
fn tap_deref_dbg<F, R>(self, func: F) -> Self
tap_deref in debug builds, and does nothing in release builds.source§fn tap_deref_mut<F, R>(self, func: F) -> Self
fn tap_deref_mut<F, R>(self, func: F) -> Self
self for modification.