Enum fuel_tx::Transaction
source · [−]pub enum Transaction {
Script {
gas_price: Word,
gas_limit: Word,
byte_price: Word,
maturity: Word,
receipts_root: Bytes32,
script: Vec<u8>,
script_data: Vec<u8>,
inputs: Vec<Input>,
outputs: Vec<Output>,
witnesses: Vec<Witness>,
metadata: Option<Metadata>,
},
Create {
gas_price: Word,
gas_limit: Word,
byte_price: Word,
maturity: Word,
bytecode_witness_index: u8,
salt: Salt,
static_contracts: Vec<ContractId>,
storage_slots: Vec<StorageSlot>,
inputs: Vec<Input>,
outputs: Vec<Output>,
witnesses: Vec<Witness>,
metadata: Option<Metadata>,
},
}
Variants
Script
Create
Fields
gas_price: Word
gas_limit: Word
byte_price: Word
maturity: Word
bytecode_witness_index: u8
salt: Salt
static_contracts: Vec<ContractId>
storage_slots: Vec<StorageSlot>
Implementations
sourceimpl Transaction
impl Transaction
pub fn precompute_metadata(&mut self)
sourceimpl Transaction
impl Transaction
sourcepub const fn script_offset() -> usize
pub const fn script_offset() -> usize
For a serialized transaction of type Script
, return the bytes offset
of the script
sourcepub fn script_data_offset(&self) -> Option<usize>
pub fn script_data_offset(&self) -> Option<usize>
For a serialized transaction of type Script
, return the bytes offset
of the script data
sourcepub fn input_coin_predicate_offset(&self, index: usize) -> Option<usize>
pub fn input_coin_predicate_offset(&self, index: usize) -> Option<usize>
For a transaction of type Create
, return the offset of the data
relative to the serialized transaction for a given index of inputs,
if this input is of type Coin
.
sourcepub fn input_offset(&self, index: usize) -> Option<usize>
pub fn input_offset(&self, index: usize) -> Option<usize>
Return the serialized bytes offset of the input with the provided index
Return None
if index
is invalid
sourcepub fn output_offset(&self, index: usize) -> Option<usize>
pub fn output_offset(&self, index: usize) -> Option<usize>
Return the serialized bytes offset of the output with the provided index
Return None
if index
is invalid
sourcepub fn witness_offset(&self, index: usize) -> Option<usize>
pub fn witness_offset(&self, index: usize) -> Option<usize>
Return the serialized bytes offset of the witness with the provided index
Return None
if index
is invalid
sourceimpl Transaction
impl Transaction
pub fn validate(&self, block_height: Word) -> Result<(), ValidationError>
pub fn validate_input_signature(&self) -> Result<(), ValidationError>
pub fn validate_without_signature(
&self,
block_height: Word
) -> Result<(), ValidationError>
sourceimpl Transaction
impl Transaction
sourceimpl Transaction
impl Transaction
pub const fn script(
gas_price: Word,
gas_limit: Word,
byte_price: Word,
maturity: Word,
script: Vec<u8>,
script_data: Vec<u8>,
inputs: Vec<Input>,
outputs: Vec<Output>,
witnesses: Vec<Witness>
) -> Self
pub const fn create(
gas_price: Word,
gas_limit: Word,
byte_price: Word,
maturity: Word,
bytecode_witness_index: u8,
salt: Salt,
static_contracts: Vec<ContractId>,
storage_slots: Vec<StorageSlot>,
inputs: Vec<Input>,
outputs: Vec<Output>,
witnesses: Vec<Witness>
) -> Self
pub fn input_asset_ids(&self) -> impl Iterator<Item = &AssetId>
pub fn input_asset_ids_unique(&self) -> impl Iterator<Item = &AssetId>
pub fn input_contracts(&self) -> impl Iterator<Item = &ContractId>
pub const fn gas_price(&self) -> Word
pub fn set_gas_price(&mut self, price: Word)
pub const fn gas_limit(&self) -> Word
pub fn set_gas_limit(&mut self, limit: Word)
pub const fn byte_price(&self) -> Word
pub fn set_byte_price(&mut self, price: Word)
pub const fn maturity(&self) -> Word
pub fn set_maturity(&mut self, mat: Word)
pub const fn is_script(&self) -> bool
pub const fn metadata(&self) -> Option<&Metadata>
pub fn inputs(&self) -> &[Input]
pub fn outputs(&self) -> &[Output]
pub fn witnesses(&self) -> &[Witness]
pub fn set_witnesses(&mut self, new_witnesses: Vec<Witness>)
pub const fn receipts_root(&self) -> Option<&Bytes32>
pub fn set_receipts_root(&mut self, root: Bytes32) -> Option<Bytes32>
sourcepub fn add_unsigned_coin_input(
&mut self,
utxo_id: UtxoId,
owner: &PublicKey,
amount: Word,
asset_id: AssetId,
maturity: Word,
predicate: Vec<u8>,
predicate_data: Vec<u8>
)
pub fn add_unsigned_coin_input(
&mut self,
utxo_id: UtxoId,
owner: &PublicKey,
amount: Word,
asset_id: AssetId,
maturity: Word,
predicate: Vec<u8>,
predicate_data: Vec<u8>
)
Append a new unsigned input to the transaction.
When the transaction is constructed, Transaction::sign_inputs
should
be called for every secret key used with this method.
The production of the signatures can be done only after the full transaction skeleton is built because the input of the hash message is the ID of the final transaction.
sourcepub fn sign_inputs(&mut self, secret: &SecretKey)
pub fn sign_inputs(&mut self, secret: &SecretKey)
For all inputs of type coin
, check if its owner
equals the public
counterpart of the provided key. Sign all matches.
sourcepub fn metered_bytes_size(&self) -> usize
pub fn metered_bytes_size(&self) -> usize
Used for accounting purposes when charging byte based fees
Trait Implementations
sourceimpl Clone for Transaction
impl Clone for Transaction
sourcefn clone(&self) -> TransactionⓘNotable traits for Transactionimpl Read for Transactionimpl Write for Transaction
fn clone(&self) -> TransactionⓘNotable traits for Transactionimpl Read for Transactionimpl Write for Transaction
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Transaction
impl Debug for Transaction
sourceimpl Default for Transaction
impl Default for Transaction
sourceimpl Hash for Transaction
impl Hash for Transaction
sourceimpl PartialEq<Transaction> for Transaction
impl PartialEq<Transaction> for Transaction
sourcefn eq(&self, other: &Transaction) -> bool
fn eq(&self, other: &Transaction) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Transaction) -> bool
fn ne(&self, other: &Transaction) -> bool
This method tests for !=
.
sourceimpl Read for Transaction
impl Read for Transaction
sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
1.36.0 · sourcefn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like read
, except that it reads into a slice of buffers. Read more
sourcefn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
1.0.0 · sourcefn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
Read all bytes until EOF in this source, placing them into buf
. Read more
1.0.0 · sourcefn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to buf
. Read more
1.6.0 · sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read the exact number of bytes required to fill buf
. Read more
sourcefn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Pull some bytes from this source into the specified buffer. Read more
sourcefn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Read the exact number of bytes required to fill buf
. Read more
1.0.0 · sourcefn by_ref(&mut self) -> &mut Self
fn by_ref(&mut self) -> &mut Self
Creates a “by reference” adaptor for this instance of Read
. Read more
sourceimpl SizedBytes for Transaction
impl SizedBytes for Transaction
sourcefn serialized_size(&self) -> usize
fn serialized_size(&self) -> usize
Return the expected serialized size for an instance of the type.
sourceimpl Write for Transaction
impl Write for Transaction
sourcefn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)Determines if this Write
r has an efficient write_vectored
implementation. Read more
1.0.0 · sourcefn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
sourcefn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
impl Eq for Transaction
impl StructuralEq for Transaction
impl StructuralPartialEq for Transaction
Auto Trait Implementations
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Deserializable for T where
T: Default + Write,
impl<T> Deserializable for T where
T: Default + Write,
sourceimpl<T> SerializableVec for T where
T: SizedBytes + Read,
impl<T> SerializableVec for T where
T: SizedBytes + Read,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more