Environment Information

Transaction Information

To get the addresses of the signers of a transaction, use the address field of each signing AuthAccount that is passed to the transaction's prepare phase.

There is currently no API that allows getting other transaction information. Please let us know if your use-case demands it by request this feature in an issue.

Block Information

To get information about a block, the functions getCurrentBlock and getBlock can be used:

  • cadence•fun getCurrentBlock(): Block

    Returns the current block, i.e. the block which contains the currently executed transaction.

  • cadence•fun getBlock(at height: UInt64): Block?

    Returns the block at the given height. If the given block does not exist the function returns nil.

The Block type contains the identifier, height, and timestamp:

1
pub struct Block {
2
/// The ID of the block.
3
///
4
/// It is essentially the hash of the block.
5
///
6
pub let id: [UInt8; 32]
7
8
/// The height of the block.
9
///
10
/// If the blockchain is viewed as a tree with the genesis block at the root,
11
// the height of a node is the number of edges between the node and the genesis block
12
///
13
pub let height: UInt64
14
15
/// The view of the block.
16
///
17
/// It is a detail of the consensus algorithm. It is a monotonically increasing integer
18
/// and counts rounds in the consensus algorithm. Since not all rounds result in a finalized block,
19
/// the view number is strictly greater than or equal to the block height
20
///
21
pub let view: UInt64
22
23
/// The timestamp of the block.
24
///
25
/// Unix timestamp of when the proposer claims it constructed the block.
26
///
27
/// NOTE: It is included by the proposer, there are no guarantees on how much the time stamp can deviate from the true time the block was published.
28
/// Consider observing blocks’ status changes off-chain yourself to get a more reliable value.
29
///
30
pub let timestamp: UFix64
31
}