[][src]Struct ergo_lib::chain::ergo_box::ErgoBox

pub struct ErgoBox {
    pub value: BoxValue,
    pub ergo_tree: ErgoTree,
    pub tokens: Vec<Token>,
    pub additional_registers: NonMandatoryRegisters,
    pub creation_height: u32,
    pub transaction_id: TxId,
    pub index: u16,
    // some fields omitted
}

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]

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]

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]

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]

impl SigmaSerializable for ErgoBox[src]

impl StoredNonPrimitive for ErgoBox[src]

impl StructuralEq for ErgoBox[src]

impl StructuralPartialEq for ErgoBox[src]

impl TryExtractFrom<Value> for ErgoBox[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryExtractFrom<Constant> for T where
    T: TryExtractFrom<Value>, 
[src]

impl<F> TryExtractInto<F> for F[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,