[−][src]Struct ergo_lib::chain::ergo_box::ErgoBox
Box (aka coin, or an unspent output) is a basic concept of a UTXO-based cryptocurrency. In Bitcoin, such an object is associated with some monetary value (arbitrary, but with predefined precision, so we use integer arithmetic to work with the value), and also a guarding script (aka proposition) to protect the box from unauthorized opening.
In other way, a box is a state element locked by some proposition (ErgoTree).
In Ergo, box is just a collection of registers, some with mandatory types and semantics, others could be used by applications in any way. We add additional fields in addition to amount and proposition~(which stored in the registers R0 and R1). Namely, register R2 contains additional tokens (a sequence of pairs (token identifier, value)). Register R3 contains height specified by user (protocol checks if it was <= current height when transaction was accepted) and also transaction identifier and box index in the transaction outputs. Registers R4-R9 are free for arbitrary usage.
A transaction is unsealing a box. As a box can not be open twice, any further valid transaction can not be linked to the same box.
Fields
value: BoxValue
amount of money associated with the box
ergo_tree: ErgoTree
guarding script, which should be evaluated to true in order to open this box
tokens: Vec<Token>
secondary tokens the box contains
additional_registers: NonMandatoryRegisters
additional registers the box can carry over
creation_height: u32
height when a transaction containing the box was created. This height is declared by user and should not exceed height of the block, containing the transaction with this box.
transaction_id: TxId
id of transaction which created the box
index: u16
number of box (from 0 to total number of boxes the transaction with transactionId created - 1)
Implementations
impl ErgoBox
[src]
pub const MAX_TOKENS_COUNT: usize
[src]
Maximum number of tokens in the box
pub fn new(
value: BoxValue,
ergo_tree: ErgoTree,
tokens: Vec<Token>,
additional_registers: NonMandatoryRegisters,
creation_height: u32,
transaction_id: TxId,
index: u16
) -> ErgoBox
[src]
value: BoxValue,
ergo_tree: ErgoTree,
tokens: Vec<Token>,
additional_registers: NonMandatoryRegisters,
creation_height: u32,
transaction_id: TxId,
index: u16
) -> ErgoBox
Crate new box
pub fn box_id(&self) -> BoxId
[src]
Box id (Blake2b256 hash of serialized box)
pub fn from_box_candidate(
box_candidate: &ErgoBoxCandidate,
transaction_id: TxId,
index: u16
) -> ErgoBox
[src]
box_candidate: &ErgoBoxCandidate,
transaction_id: TxId,
index: u16
) -> ErgoBox
Create ErgoBox from ErgoBoxCandidate by adding transaction id and index of the box in the transaction
pub fn get_register(&self, id: RegisterId) -> Option<Constant>
[src]
Get register value
Trait Implementations
impl Clone for ErgoBox
[src]
impl Debug for ErgoBox
[src]
impl<'de> Deserialize<'de> for ErgoBox
[src]
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for ErgoBox
[src]
impl ErgoBoxAssets for ErgoBox
[src]
impl ErgoBoxId for ErgoBox
[src]
impl From<ErgoBox> for Constant
[src]
impl From<ErgoBox> for Value
[src]
impl From<ErgoBox> for ErgoBoxCandidate
[src]
impl LiftIntoSType for ErgoBox
[src]
impl PartialEq<ErgoBox> for ErgoBox
[src]
impl Serialize for ErgoBox
[src]
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl SigmaSerializable for ErgoBox
[src]
pub fn sigma_serialize<W: SigmaByteWrite>(&self, w: &mut W) -> Result<(), Error>
[src]
pub fn sigma_parse<R: SigmaByteRead>(
r: &mut R
) -> Result<Self, SerializationError>
[src]
r: &mut R
) -> Result<Self, SerializationError>
pub fn sigma_serialize_bytes(&self) -> Vec<u8>
[src]
pub fn sigma_parse_bytes(mut bytes: Vec<u8>) -> Result<Self, SerializationError>
[src]
impl StoredNonPrimitive for ErgoBox
[src]
impl StructuralEq for ErgoBox
[src]
impl StructuralPartialEq for ErgoBox
[src]
impl TryExtractFrom<Value> for ErgoBox
[src]
pub fn try_extract_from(c: Value) -> Result<Self, TryExtractFromError>
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ErgoBox
[src]
impl !Send for ErgoBox
[src]
impl !Sync for ErgoBox
[src]
impl Unpin for ErgoBox
[src]
impl !UnwindSafe for ErgoBox
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> TryExtractFrom<Constant> for T where
T: TryExtractFrom<Value>,
[src]
T: TryExtractFrom<Value>,
pub fn try_extract_from(Constant) -> Result<T, TryExtractFromError>
[src]
impl<F> TryExtractInto<F> for F
[src]
pub fn try_extract_into<T>(Self) -> Result<T, TryExtractFromError> where
T: TryExtractFrom<F>,
[src]
T: TryExtractFrom<F>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,