Transactions — HCS‑27
Note
- These flows are typically orchestrated by the higher-level SDK client.
- Direct transaction construction is useful for custom pipelines, batching, or advanced key management.
Sources
- Go: GitHub
Topic Memo ConventionDirect link to Topic Memo Convention
Checkpoint topics use the memo format hcs-27:<indexed>:<ttl>:<type>.
- TypeScript
- Go
// Not yet available.
import "github.com/hashgraph-online/standards-sdk-go/pkg/hcs27"
// Build a topic memo with 1-day TTL
memo := hcs27.BuildTopicMemo(86400)
// => "hcs-27:0:86400:0"
// Parse an existing memo
parsed, ok := hcs27.ParseTopicMemo("hcs-27:0:86400:0")
if ok {
fmt.Printf("TTL: %d seconds\n", parsed.TTLSeconds)
}
Create Checkpoint TopicDirect link to Create Checkpoint Topic
- TypeScript
- Go
// Not yet available.
import hedera "github.com/hashgraph/hedera-sdk-go/v2"
memo := hcs27.BuildTopicMemo(86400)
tx := hedera.NewTopicCreateTransaction().
SetTopicMemo(memo).
SetAdminKey(operatorKey.PublicKey()).
SetSubmitKey(operatorKey.PublicKey())
response, err := tx.Execute(hederaClient)
if err != nil {
log.Fatal(err)
}
receipt, err := response.GetReceipt(hederaClient)
topicID := receipt.TopicID.String()
Publish Checkpoint MessageDirect link to Publish Checkpoint Message
- TypeScript
- Go
// Not yet available.
import "encoding/json"
metadata := hcs27.CheckpointMetadata{
Type: "ans-checkpoint-v1",
Stream: hcs27.StreamID{Registry: "my-app", LogID: "events"},
Log: &hcs27.LogProfile{
Algorithm: "sha-256",
Leaf: "rfc6962-leaf",
Merkle: "rfc6962-node",
},
Root: hcs27.RootCommitment{
TreeSize: 50,
RootHashB64: "base64url-encoded-root-hash",
},
BatchRange: hcs27.BatchRange{Start: 1, End: 50},
}
metadataBytes, _ := json.Marshal(metadata)
message := hcs27.CheckpointMessage{
Protocol: "hcs-27",
Operation: "register",
Metadata: metadataBytes,
Memo: "initial checkpoint",
}
payload, _ := json.Marshal(message)
txMemo := hcs27.BuildTransactionMemo() // => "hcs-27:op:0:0"
topic, _ := hedera.TopicIDFromString(topicID)
response, err := hedera.NewTopicMessageSubmitTransaction().
SetTopicID(topic).
SetMessage(payload).
SetTransactionMemo(txMemo).
Execute(hederaClient)
Merkle Root ConstructionDirect link to Merkle Root Construction
- TypeScript
- Go
// Not yet available.
entries := []any{
map[string]any{"id": 1, "action": "create", "value": "foo"},
map[string]any{"id": 2, "action": "update", "value": "bar"},
map[string]any{"id": 3, "action": "delete", "value": "baz"},
}
rootHash, err := hcs27.MerkleRootFromEntries(entries)
if err != nil {
log.Fatal(err)
}
rootB64 := base64.RawURLEncoding.EncodeToString(rootHash)
fmt.Printf("Root: %s (tree size: %d)\n", rootB64, len(entries))
Inclusion Proof VerificationDirect link to Inclusion Proof Verification
- TypeScript
- Go
// Not yet available.
leafHash, _ := hcs27.LeafHashHexFromEntry(entries[1])
valid, err := hcs27.VerifyInclusionProof(
1, // leafIndex
3, // treeSize
leafHash, // leaf hash (hex)
auditPath, // []string of base64 sibling hashes
expectedRootB64, // expected root (base64)
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Inclusion proof valid: %v\n", valid)
Consistency Proof VerificationDirect link to Consistency Proof Verification
- TypeScript
- Go
// Not yet available.
consistent, err := hcs27.VerifyConsistencyProof(
50, // old tree size
150, // new tree size
oldRootB64, // old root (base64)
newRootB64, // new root (base64)
consistencyPath, // []string of base64 proof nodes
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Trees are consistent: %v\n", consistent)