Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ func RandomAccount(flowClient access.Client) (flow.Address, *flow.AccountKey, cr
}

func GetReferenceBlockId(flowClient access.Client) flow.Identifier {
block, err := flowClient.GetLatestBlock(context.Background(), true)
// We use the latest finalized block as the reference block ID.
// This is the block that has been finalized and is guaranteed to be included in the chain.
// It is the best choice for a reference block ID, as block sealing lags behind finalization
// and using a sealed block may cause the reference to fall outside the expiration window.
block, err := flowClient.GetLatestBlock(context.Background(), false)
Handle(err)

return block.ID
Expand Down
5 changes: 5 additions & 0 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ func (t *Transaction) Argument(i int, options ...jsoncdc.Option) (cadence.Value,
//
// For example, if a transaction references a block with height of X and the network limit is 10,
// a block with height X+10 is the last block that is allowed to include this transaction.
//
// It is recommended to use the latest finalized block as the reference block ID.
// Transaction expiry is determined by the height difference between the reference block
// and the block that includes the transaction. Block sealing lags behind finalization and
// using the latest sealed block may cause the reference to fall outside the expiration window.
func (t *Transaction) SetReferenceBlockID(blockID Identifier) *Transaction {
t.ReferenceBlockID = blockID
return t
Expand Down
Loading