ledger

package
v0.97.3-pre Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 2 Imported by: 13

Documentation

Overview

Package ledger provides interface to LedgerContract native contract. It allows to access ledger contents like transactions and blocks.

Index

Constants

View Source
const Hash = "\xbe\xf2\x04\x31\x40\x36\x2a\x77\xc1\x50\x99\xc7\xe6\x4c\x12\xf7\x00\xb6\x65\xda"

Hash represents Ledger contract hash.

Variables

This section is empty.

Functions

func CurrentHash

func CurrentHash() interop.Hash256

CurrentHash represents `currentHash` method of Ledger native contract.

func CurrentIndex

func CurrentIndex() int

CurrentIndex represents `currentIndex` method of Ledger native contract.

func GetTransactionHeight

func GetTransactionHeight(hash interop.Hash256) int

GetTransactionHeight represents `getTransactionHeight` method of Ledger native contract.

Types

type Block

type Block struct {
	// Hash represents the hash (256 bit BE value in a 32 byte slice) of the
	// given block.
	Hash interop.Hash256
	// Version of the block.
	Version int
	// PrevHash represents the hash (256 bit BE value in a 32 byte slice) of the
	// previous block.
	PrevHash interop.Hash256
	// MerkleRoot represents the root hash (256 bit BE value in a 32 byte slice)
	// of a transaction list.
	MerkleRoot interop.Hash256
	// Timestamp represents millisecond-precision block timestamp.
	Timestamp int
	// Nonce represents block nonce.
	Nonce int
	// Index represents the height of the block.
	Index int
	// NextConsensus represents contract address of the next miner (160 bit BE
	// value in a 20 byte slice).
	NextConsensus interop.Hash160
	// TransactionsLength represents the length of block's transactions array.
	TransactionsLength int
}

Block represents a NEO block, it's a data structure that you can get block-related data from. It's similar to the Block class in the Neo .net framework. To use it you need to get it via GetBlock function call.

func GetBlock

func GetBlock(indexOrHash interface{}) *Block

GetBlock represents `getBlock` method of Ledger native contract.

type Transaction

type Transaction struct {
	// Hash represents the hash (256 bit BE value in a 32 byte slice) of the
	// given transaction (which also is its ID).
	Hash interop.Hash256
	// Version represents the transaction version.
	Version int
	// Nonce is a random number to avoid hash collision.
	Nonce int
	// Sender represents the sender (160 bit BE value in a 20 byte slice) of the
	// given Transaction.
	Sender interop.Hash160
	// SysFee represents fee to be burned.
	SysFee int
	// NetFee represents fee to be distributed to consensus nodes.
	NetFee int
	// ValidUntilBlock is the maximum blockchain height exceeding which
	// transaction should fail verification.
	ValidUntilBlock int
	// Script represents code to run in NeoVM for this transaction.
	Script []byte
}

Transaction represents a NEO transaction. It's similar to Transaction class in Neo .net framework.

func GetTransaction

func GetTransaction(hash interop.Hash256) *Transaction

GetTransaction represents `getTransaction` method of Ledger native contract.

func GetTransactionFromBlock

func GetTransactionFromBlock(indexOrHash interface{}, txIndex int) *Transaction

GetTransactionFromBlock represents `getTransactionFromBlock` method of Ledger native contract.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL