anchor

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package anchor computes the 8-byte discriminators the Anchor framework writes at the start of instruction data and program account data. It is pure logic over crypto/sha256 with no dependency on the rest of the SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountDisc

func AccountDisc(name string) [8]byte

AccountDisc returns the 8-byte tag Anchor writes at the start of a program account's data: sha256("account:" + name)[:8]. name is the PascalCase Rust struct (e.g. "Pool", "UserPosition").

func MethodDisc

func MethodDisc(name string) [8]byte

MethodDisc returns the 8-byte discriminator Anchor emits at the start of an instruction's data: sha256("global:" + name)[:8]. name is the snake_case Rust method on the program (e.g. "initialize", "swap").

func Sighash

func Sighash(namespace, name string) [8]byte

Sighash returns the first 8 bytes of sha256(namespace + ":" + name). Anchor uses this scheme for several discriminators; MethodDisc and AccountDisc wrap it with the common namespaces. Exposed for non-standard namespaces (e.g. "state:" on legacy state methods).

Types

This section is empty.

Jump to

Keyboard shortcuts

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