Documentation
¶
Index ¶
- func DecodeProtobufVarint(buf []byte) (result uint64, buflen int, err error)
- func EncodeProtobufVarint(x uint64) []byte
- func ReadProtobufVarint(r bytereader) (uint64, int64, error)
- type Address
- type Amount
- type BodyCallSC
- type BodyExecuteSC
- type BodyRollBuy
- type BodyRollSell
- type BodyTransaction
- type ChainId
- type DataStoreItem
- type Operation
- type OperationBody
- type OperationType
- type PublicKey
- type RPC
- func (rpc *RPC) Close() error
- func (rpc *RPC) GetSlotTransfers(ctx context.Context, finality massagrpc.FinalityLevel) (chan *massagrpc.NewSlotTransfersResponse, io.Closer, error)
- func (rpc *RPC) GetStatus(ctx context.Context) (*massagrpc.PublicStatus, error)
- func (rpc *RPC) Public() massagrpc.PublicServiceClient
- func (rpc *RPC) SendOperations(ctx context.Context, op ...[]byte) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeProtobufVarint ¶
DecodeProtobufVarint decodes a varint encoded following protobuf conventions from the given byte slice. It returns the decoded value, the number of bytes consumed, and any error encountered.
func EncodeProtobufVarint ¶
EncodeProtobufVarint encodes the given integer using protobuf varint conventions.
func ReadProtobufVarint ¶
ReadProtobufVarint reads a protobuf varint from the given reader. It returns the decoded value, the number of bytes read, and any error encountered.
Types ¶
type Address ¶
type Address struct {
Category uint64 // 0 for User, 1 for Smart contract
Version uint64
Hash []byte // Underlying blake3 hash
}
Address represents a Massa blockchain address, which can be either a user account (Category 0) or a smart contract (Category 1).
See: https://docs.massa.net/docs/learn/operation-format-execution#address
func DecodeAddress ¶
DecodeAddress parses a Massa address string (AU for user, AS for smart contract) or a public key string (P prefix) into an Address. It validates the base58check checksum and returns an error if the address is malformed.
func (*Address) MarshalBinary ¶
MarshalBinary encodes the address in massa byte format (for compatibility).
func (*Address) ReadFrom ¶
ReadFrom reads a binary address from a given source, which is made of two varint (category, version) followed by 32 bytes of hash.
func (*Address) SetValue ¶
SetValue computes the hash of the provided buffer and sets it as address Hash.
type Amount ¶
type Amount uint64
Amount represents a Massa coin amount as a uint64 with 9 decimal places of precision. The maximum representable amount is 18,446,744,073.709551615 MAS.
See: https://docs.massa.net/docs/learn/operation-format-execution#coin-amounts
type BodyCallSC ¶
type BodyCallSC struct {
MaxGas uint64
MaxCoins Amount
Target *Address
Function string // Name of the function to call encoded as UTF-8 string
Param []byte
}
BodyCallSC represents a smart contract function call operation.
type BodyExecuteSC ¶
type BodyExecuteSC struct {
MaxGas uint64
MaxCoins Amount
Bytecode []byte // Raw bytes of bytecode to execute (up to 10MB)
Datastore []*DataStoreItem // Concatenated datastore items
}
BodyExecuteSC represents a smart contract execution operation.
type BodyRollBuy ¶
type BodyRollBuy struct {
Rolls uint64
}
BodyRollBuy represents a roll purchase operation for staking.
type BodyRollSell ¶
type BodyRollSell struct {
Rolls uint64
}
BodyRollSell represents a roll sale operation.
type BodyTransaction ¶
BodyTransaction represents a MAS coin transfer operation.
func (*BodyTransaction) Bytes ¶
func (tx *BodyTransaction) Bytes() []byte
Bytes returns the binary encoding of the transaction body.
func (*BodyTransaction) ReadFrom ¶
func (tx *BodyTransaction) ReadFrom(r io.Reader) (int64, error)
ReadFrom reads a transaction body from the given reader.
func (*BodyTransaction) Type ¶
func (tx *BodyTransaction) Type() OperationType
Type returns OpTransaction.
func (*BodyTransaction) UnmarshalBinary ¶
func (tx *BodyTransaction) UnmarshalBinary(buf []byte) error
UnmarshalBinary decodes a transaction body from its binary representation.
type ChainId ¶
type ChainId uint64
ChainId identifies a Massa blockchain network.
const ( MainNet ChainId = 77658377 BuildNet ChainId = 77658366 SecureNet ChainId = 77658383 LabNet ChainId = 77658376 Sandbox ChainId = 77 )
Well-known Massa chain IDs.
func (ChainId) AppendBinary ¶
AppendBinary appends the big-endian 8-byte encoding of the chain ID to b.
type DataStoreItem ¶
DataStoreItem represents a key-value pair in a smart contract datastore.
type Operation ¶
type Operation struct {
Fee Amount
Expire uint64 // expire_period, typically current period + 10
Body OperationBody
}
Operation represents a Massa operation consisting of a fee, expiration period, and a typed body.
func (*Operation) Bytes ¶
Bytes returns the binary representation of the operation (fee, expire, type, body).
func (*Operation) Hash ¶
Hash returns the blake3 hash of the operation contents prefixed with the chain ID and public key, as required by the Massa signing scheme.
func (*Operation) Sign ¶
Sign signs the given operation and returns a serialized signed operation suitable for submission to the network. The key must be an Ed25519 signer.
See: https://docs.massa.net/docs/learn/operation-format-execution
func (*Operation) UnmarshalBinary ¶
UnmarshalBinary decodes an operation from its binary representation.
type OperationBody ¶
type OperationBody interface {
Bytes() []byte
UnmarshalBinary(data []byte) error
Type() OperationType
ReadFrom(r io.Reader) (int64, error)
}
OperationBody is the interface implemented by all operation body types.
type OperationType ¶
type OperationType uint32
OperationType identifies the kind of operation in the Massa network.
const ( OpTransaction OperationType = iota // Transfer MAS coins OpRollBuy // Buy rolls for staking OpRollSell // Sell staking rolls OpExecuteSC // Execute smart contract bytecode OpCallSC // Call a smart contract function )
Massa operation types.
type PublicKey ¶
PublicKey represents a Massa Ed25519 public key with a version prefix.
func (*PublicKey) AsAddress ¶
AsAddress derives the user account Address from the public key by hashing the serialized key bytes with blake3.
func (*PublicKey) Bytes ¶
Bytes returns the binary encoding of the public key (version varint followed by the raw Ed25519 key bytes).
func (*PublicKey) MarshalBinary ¶
MarshalBinary encodes the public key in massa byte format (for compatibility).
func (*PublicKey) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*PublicKey) String ¶
String returns the Massa text representation of the public key (P prefix followed by base58check-encoded version and key bytes).
func (*PublicKey) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler by parsing a Massa public key string (e.g. "P1t4JZwHhWNLt4xYabCbukyVNxSbhYPdF6wCYuRmDuHD784juxd").
type RPC ¶
type RPC struct {
// contains filtered or unexported fields
}
RPC wraps gRPC client connections to a Massa node, providing convenient methods for common operations.
func New ¶
func New(target string, opts ...grpc.DialOption) (*RPC, error)
New returns a new RPC client connected to the given Massa node target (e.g. "localhost:33037").
func (*RPC) GetSlotTransfers ¶
func (rpc *RPC) GetSlotTransfers(ctx context.Context, finality massagrpc.FinalityLevel) (chan *massagrpc.NewSlotTransfersResponse, io.Closer, error)
GetSlotTransfers opens a streaming connection that receives transfer events for each new slot. It requires the Massa node to be compiled with feature massa-node/execution-trace. The returned channel delivers responses until the stream ends or encounters an error. The caller must call Close on the returned io.Closer to release resources.
func (*RPC) Public ¶
func (rpc *RPC) Public() massagrpc.PublicServiceClient
Public exposes the raw gRPC public service interface for advanced usage.