types

package
v0.0.0-...-f36aa9e Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 6 Imported by: 8

Documentation

Index

Constants

View Source
const LogicSigMaxCost = 20000

LogicSigMaxCost is a max execution const of a TEAL program

View Source
const LogicSigMaxSize = 1000

LogicSigMaxSize is a max TEAL program size (with args)

Variables

This section is empty.

Functions

func OAdd

func OAdd(a uint64, b uint64) (res uint64, overflowed bool)

OAdd adds 2 values with overflow detection

func OAdd16

func OAdd16(a uint16, b uint16) (res uint16, overflowed bool)

OAdd16 adds 2 uint16 values with overflow detection

func OMul

func OMul(a uint64, b uint64) (res uint64, overflowed bool)

OMul multiplies 2 values with overflow detection

func OSub

func OSub(a uint64, b uint64) (res uint64, overflowed bool)

OSub subtracts b from a with overflow detection

Types

type Address

type Address [hashLenBytes]byte

Address represents an Algorand address.

func DecodeAddress

func DecodeAddress(addr string) (a Address, err error)

DecodeAddress turns a checksum address string into an Address object. It checks that the checksum is correct, and returns an error if it's not.

func (Address) String

func (a Address) String() string

String grabs a human-readable representation of the address. This representation includes a 4-byte checksum.

type AssetConfigTxnFields

type AssetConfigTxnFields struct {

	// ConfigAsset is the asset being configured or destroyed.
	// A zero value (including the creator address) means allocation.
	ConfigAsset AssetID `codec:"caid"`

	// AssetParams are the parameters for the asset being
	// created or re-configured.  A zero value means destruction.
	AssetParams AssetParams `codec:"apar"`
	// contains filtered or unexported fields
}

AssetConfigTxnFields captures the fields used for asset allocation, re-configuration, and destruction.

type AssetFreezeTxnFields

type AssetFreezeTxnFields struct {

	// FreezeAccount is the address of the account whose asset
	// slot is being frozen or un-frozen.
	FreezeAccount Address `codec:"fadd"`

	// FreezeAsset is the asset ID being frozen or un-frozen.
	FreezeAsset AssetID `codec:"faid"`

	// AssetFrozen is the new frozen value.
	AssetFrozen bool `codec:"afrz"`
	// contains filtered or unexported fields
}

AssetFreezeTxnFields captures the fields used for freezing asset slots.

type AssetID

type AssetID struct {
	Creator Address `codec:"c"`
	Index   uint64  `codec:"i"`
	// contains filtered or unexported fields
}

AssetID is a name of an asset.

type AssetParams

type AssetParams struct {

	// Total specifies the total number of units of this asset
	// created.
	Total uint64 `codec:"t"`

	// DefaultFrozen specifies whether slots for this asset
	// in user accounts are frozen by default or not.
	DefaultFrozen bool `codec:"df"`

	// UnitName specifies a hint for the name of a unit of
	// this asset.
	UnitName [assetUnitNameLen]byte `codec:"un"`

	// AssetName specifies a hint for the name of the asset.
	AssetName [assetNameLen]byte `codec:"an"`

	// Manager specifies an account that is allowed to change the
	// non-zero addresses in this AssetParams.
	Manager Address `codec:"m"`

	// Reserve specifies an account whose holdings of this asset
	// should be reported as "not minted".
	Reserve Address `codec:"r"`

	// Freeze specifies an account that is allowed to change the
	// frozen state of holdings of this asset.
	Freeze Address `codec:"f"`

	// Clawback specifies an account that is allowed to take units
	// of this asset from any account.
	Clawback Address `codec:"c"`
	// contains filtered or unexported fields
}

AssetParams describes the parameters of an asset.

type AssetTransferTxnFields

type AssetTransferTxnFields struct {
	XferAsset AssetID `codec:"xaid"`

	// AssetAmount is the amount of asset to transfer.
	// A zero amount transferred to self allocates that asset
	// in the account's Assets map.
	AssetAmount uint64 `codec:"aamt"`

	// AssetSender is the sender of the transfer.  If this is not
	// a zero value, the real transaction sender must be the Clawback
	// address from the AssetParams.  If this is the zero value,
	// the asset is sent from the transaction's Sender.
	AssetSender Address `codec:"asnd"`

	// AssetReceiver is the recipient of the transfer.
	AssetReceiver Address `codec:"arcv"`

	// AssetCloseTo indicates that the asset should be removed
	// from the account's Assets map, and specifies where the remaining
	// asset holdings should be transferred.  It's always valid to transfer
	// remaining asset holdings to the AssetID account.
	AssetCloseTo Address `codec:"aclose"`
	// contains filtered or unexported fields
}

AssetTransferTxnFields captures the fields used for asset transfers.

type Bid

type Bid struct {

	// BidderKey identifies the bidder placing this bid.
	BidderKey Address `codec:"bidder"`

	// BidCurrency specifies how much external currency the bidder
	// is putting in with this bid.
	BidCurrency uint64 `codec:"cur"`

	// MaxPrice specifies the maximum price, in units of external
	// currency per Algo, that the bidder is willing to pay.
	// This must be at least as high as the current price of the
	// auction in the block in which this bid appears.
	MaxPrice uint64 `codec:"price"`

	// BidID identifies this bid.  The first bid by a bidder (identified
	// by BidderKey) with a particular BidID on the blockchain will be
	// considered, preventing replay of bids.  Specifying a different
	// BidID allows the bidder to place multiple bids in an auction.
	BidID uint64 `codec:"id"`

	// AuctionKey specifies the auction for this bid.
	AuctionKey Address `codec:"auc"`

	// AuctionID identifies the auction for which this bid is intended.
	AuctionID uint64 `codec:"aid"`
	// contains filtered or unexported fields
}

Bid represents a bid by a user as part of an auction.

type Digest

type Digest [hashLenBytes]byte

Digest is a SHA512_256 hash

type Header struct {
	Sender      Address    `codec:"snd"`
	Fee         MicroAlgos `codec:"fee"`
	FirstValid  Round      `codec:"fv"`
	LastValid   Round      `codec:"lv"`
	Note        []byte     `codec:"note"`
	ReviewNote  []byte     `codec:"reviewnote"` // Uniqueness or app-level data about txn
	ReviewRate  uint64     `codec:"reviewrate"` // Uniqueness or app-level data about txn
	ReviewEval  uint64     `codec:"revieweval"` // Uniqueness or app-level data about txn
	RepAdjust   int64      `codec:"repadjust"`
	ItemID      int64      `codec:"itemid"`
	ItemStruct  ItemStruct `codec:"itemstruct"`
	ItemIterat  int64      `codec:"itemiteration"`
	CategoryID  int64      `codec:"categoryid"`
	GenesisID   string     `codec:"gen"`
	GenesisHash Digest     `codec:"gh"`

	// Group specifies that this transaction is part of a
	// transaction group (and, if so, specifies the hash
	// of a TxGroup).
	Group Digest `codec:"grp"`
	// contains filtered or unexported fields
}

Header captures the fields common to every transaction type.

type ItemStruct

type ItemStruct struct {
	ItemName   []byte `codec:"itemname"`
	CategoryNa []byte `codec:"categoryname"`
	// contains filtered or unexported fields
}

ItemStruct holds basic properties and an additional 3 different byte data properties.

type KeyregTxnFields

type KeyregTxnFields struct {
	VotePK          VotePK `codec:"votekey"`
	SelectionPK     VRFPK  `codec:"selkey"`
	VoteFirst       Round  `codec:"votefst"`
	VoteLast        Round  `codec:"votelst"`
	VoteKeyDilution uint64 `codec:"votekd"`
	// contains filtered or unexported fields
}

KeyregTxnFields captures the fields used for key registration transactions.

type LogicSig

type LogicSig struct {

	// Logic signed by Sig or Msig
	// OR hashed to be the Address of an account.
	Logic []byte `codec:"l"`

	Sig  Signature   `codec:"sig"`
	Msig MultisigSig `codec:"msig"`

	// Args are not signed, but checked by Logic
	Args [][]byte `codec:"arg"`
	// contains filtered or unexported fields
}

LogicSig contains logic for validating a transaction. LogicSig is signed by an account, allowing delegation of operations. OR LogicSig defines a contract account.

type MasterDerivationKey

type MasterDerivationKey [masterDerivationKeyLenBytes]byte

MasterDerivationKey is the secret key used to derive keys in wallets

type MicroAlgos

type MicroAlgos uint64

MicroAlgos are the base unit of currency in Algorand

func ToMicroAlgos

func ToMicroAlgos(algos float64) MicroAlgos

ToMicroAlgos converts amount in Algos to microAlgos

func (MicroAlgos) ToAlgos

func (microalgos MicroAlgos) ToAlgos() float64

ToAlgos converts amount in microAlgos to Algos

type MultisigSig

type MultisigSig struct {
	Version   uint8            `codec:"v"`
	Threshold uint8            `codec:"thr"`
	Subsigs   []MultisigSubsig `codec:"subsig"`
	// contains filtered or unexported fields
}

MultisigSig holds multiple Subsigs, as well as threshold and version info

func (MultisigSig) Blank

func (msig MultisigSig) Blank() bool

Blank returns true iff the msig is empty. We need this instead of just comparing with == MultisigSig{}, because Subsigs is a slice.

type MultisigSubsig

type MultisigSubsig struct {
	Key ed25519.PublicKey `codec:"pk"`
	Sig Signature         `codec:"s"`
	// contains filtered or unexported fields
}

MultisigSubsig contains a single public key and, optionally, a signature

type NoteField

type NoteField struct {

	// Type indicates which type of a message this is
	Type NoteFieldType `codec:"t"`

	// SignedBid, for NoteBid type
	SignedBid SignedBid `codec:"b"`
	// contains filtered or unexported fields
}

NoteField is the struct that represents an auction message.

type NoteFieldType

type NoteFieldType string

NoteFieldType indicates a type of auction message encoded into a transaction's Note field.

const (
	// NoteDeposit indicates a SignedDeposit message.
	NoteDeposit NoteFieldType = "d"

	// NoteBid indicates a SignedBid message.
	NoteBid NoteFieldType = "b"

	// NoteSettlement indicates a SignedSettlement message.
	NoteSettlement NoteFieldType = "s"

	// NoteParams indicates a SignedParams message.
	NoteParams NoteFieldType = "p"
)

type PaymentTxnFields

type PaymentTxnFields struct {
	Receiver Address    `codec:"rcv"`
	Amount   MicroAlgos `codec:"amt"`

	// When CloseRemainderTo is set, it indicates that the
	// transaction is requesting that the account should be
	// closed, and all remaining funds be transferred to this
	// address.
	CloseRemainderTo Address `codec:"close"`
	// contains filtered or unexported fields
}

PaymentTxnFields captures the fields used by payment transactions.

type ReviewTxnFields

type ReviewTxnFields struct {
	ReceiverReview Address    `codec:"rcv"`
	AmountReview   MicroAlgos `codec:"amt"`

	// When CloseRemainderToReview is set, it indicates that the
	// transaction is requesting that the account should be
	// closed, and all remaining funds be transferred to this
	// address.
	CloseRemainderToReview Address `codec:"close"`
	// contains filtered or unexported fields
}

ReviewTxnFields captures the fields used by review transactions.

type Round

type Round uint64

Round represents a round of the Algorand consensus protocol

type Signature

type Signature [ed25519.SignatureSize]byte

Signature is an ed25519 signature

type SignedBid

type SignedBid struct {

	// Bid contains information about the bid.
	Bid Bid `codec:"bid"`

	// Sig is a signature by the bidder, as identified in the bid
	// (Bid.BidderKey) over the hash of the Bid.
	Sig Signature `codec:"sig"`
	// contains filtered or unexported fields
}

SignedBid represents a signed bid by a bidder.

type SignedTxn

type SignedTxn struct {
	Sig  Signature   `codec:"sig"`
	Msig MultisigSig `codec:"msig"`
	Lsig LogicSig    `codec:"lsig"`
	Txn  Transaction `codec:"txn"`
	// contains filtered or unexported fields
}

SignedTxn wraps a transaction and a signature. The encoding of this struct is suitable to broadcast on the network

type Transaction

type Transaction struct {

	// Type of transaction
	Type TxType `codec:"type"`

	// Common fields for all types of transactions
	Header

	// Fields for different types of transactions
	KeyregTxnFields
	PaymentTxnFields
	ReviewTxnFields
	AssetConfigTxnFields
	AssetTransferTxnFields
	AssetFreezeTxnFields
	// contains filtered or unexported fields
}

Transaction describes a transaction that can appear in a block.

type TxGroup

type TxGroup struct {

	// TxGroupHashes specifies a list of hashes of transactions that must appear
	// together, sequentially, in a block in order for the group to be
	// valid.  Each hash in the list is a hash of a transaction with
	// the `Group` field omitted.
	TxGroupHashes []Digest `codec:"txlist"`
	// contains filtered or unexported fields
}

TxGroup describes a group of transactions that must appear together in a specific order in a block.

type TxType

type TxType string

TxType identifies the type of the transaction

const (
	// ReviewTx is the TxType for review transactions
	ReviewTx TxType = "review"
	// PaymentTx is the TxType for payment transactions
	PaymentTx TxType = "pay"
	// KeyRegistrationTx is the TxType for key registration transactions
	KeyRegistrationTx TxType = "keyreg"
	// AssetConfigTx creates, re-configures, or destroys an asset
	AssetConfigTx TxType = "acfg"
	// AssetTransferTx transfers assets between accounts (optionally closing)
	AssetTransferTx TxType = "axfer"
	// AssetFreezeTx changes the freeze status of an asset
	AssetFreezeTx TxType = "afrz"
)

type VRFPK

type VRFPK [ed25519.PublicKeySize]byte

VRFPK is the VRF public key used in key registration transactions

type VotePK

type VotePK [ed25519.PublicKeySize]byte

VotePK is the participation public key used in key registration transactions

Jump to

Keyboard shortcuts

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