Documentation
¶
Index ¶
- Constants
- Variables
- func ParseHex(hexStr string) ([]byte, error)
- func RawTransactionPrehash() []byte
- func Sha3256Hash(bytes [][]byte) (output []byte)
- func ToU128OrU256(val string) (num *big.Int, err error)
- func ToU64(val string) (uint64, error)
- type Account
- type AccountAddress
- func (aa *AccountAddress) DerivedAddress(seed []byte, typeByte uint8) (accountAddress AccountAddress)
- func (aa *AccountAddress) IsSpecial() bool
- func (aa *AccountAddress) MarshalBCS(bcs *bcs.Serializer)
- func (aa *AccountAddress) NamedObjectAddress(seed []byte) (accountAddress AccountAddress)
- func (aa *AccountAddress) ObjectAddressFromObject(objectAddress *AccountAddress) (accountAddress AccountAddress)
- func (aa *AccountAddress) ParseStringRelaxed(x string) error
- func (aa *AccountAddress) ResourceAccount(seed []byte) (accountAddress AccountAddress)
- func (aa *AccountAddress) String() string
- func (aa *AccountAddress) StringLong() string
- func (aa *AccountAddress) UnmarshalBCS(bcs *bcs.Deserializer)
- type AddressTag
- type BoolTag
- type ChainIdOption
- type Client
- type EntryFunction
- type ExpirationSeconds
- type FungibleAssetClient
- func (client *FungibleAssetClient) SimulateTransferPrimaryStore(publicKey []byte, fromAddress AccountAddress, receiverAddress AccountAddress, ...) (signedTxn *SignedTransaction, err error)
- func (client *FungibleAssetClient) Transfer(sender *Account, senderStore AccountAddress, receiverStore AccountAddress, ...) (signedTxn *SignedTransaction, err error)
- func (client *FungibleAssetClient) TransferPrimaryStore(sender *Account, receiverAddress AccountAddress, amount uint64, options ...any) (signedTxn *SignedTransaction, err error)
- type GasUnitPrice
- type MaxGasAmount
- type ModuleBundle
- type ModuleId
- type NetworkConfig
- type NodeClient
- type RawTransaction
- func (txn *RawTransaction) MarshalBCS(bcs *bcs.Serializer)
- func (txn *RawTransaction) Sign(sender *Account) (signedTxn *SignedTransaction, err error)
- func (txn *RawTransaction) SigningMessage() (message []byte, err error)
- func (txn *RawTransaction) SimulateTransaction(publicKey []byte) (signedTxn *SignedTransaction, err error)
- func (txn *RawTransaction) UnmarshalBCS(bcs *bcs.Deserializer)
- type Script
- type ScriptArgument
- type ScriptArgumentVariant
- type SequenceNumber
- type SignedTransaction
- type SignerTag
- type StructTag
- type TransactionPayload
- type TypeTag
- type TypeTagImpl
- type TypeTagType
- type U128Tag
- type U16Tag
- type U256Tag
- type U32Tag
- type U64Tag
- type U8Tag
- type VectorTag
- type ViewPayload
Constants ¶
const ( TransactionPayloadScript = 0 TransactionPayloadModuleBundle = 1 // Deprecated TransactionPayloadEntryFunction = 2 TransactionPayloadMultisig = 3 // TODO? defined in aptos-core/types/src/transaction/mod.rs )
const ContentTypeAptosSignedTxnBcs = "application/x.aptos.signed_transaction+bcs"
ContentTypeAptosSignedTxnBcs header for sending BCS transaction payloads
const ContentTypeAptosViewFunctionBcs = "application/x.aptos.view_function+bcs"
ContentTypeAptosViewFunctionBcs header for sending BCS view function payloads
Variables ¶
var AccountFour = AccountAddress{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}
var AccountOne = AccountAddress{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
var AccountThree = AccountAddress{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3}
var AccountTwo = AccountAddress{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}
var AccountZero = AccountAddress{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
var DevnetConfig = NetworkConfig{
Name: "devnet",
ChainId: 135,
}
var ErrAddressTooLong = errors.New("AccountAddress too long")
var ErrAddressTooShort = errors.New("AccountAddress too short")
var LocalnetConfig = NetworkConfig{
Name: "localnet",
ChainId: 4,
}
var MainnetConfig = NetworkConfig{
Name: "mainnet",
ChainId: 1,
}
var NamedNetworks map[string]NetworkConfig
NamedNetworks Map from network name to NetworkConfig
var TestnetConfig = NetworkConfig{
Name: "testnet",
ChainId: 2,
}
var TransactionPrefix *[]byte
Functions ¶
func RawTransactionPrehash ¶
func RawTransactionPrehash() []byte
RawTransactionPrehash Return the sha3-256 prehash for RawTransaction Do not write to the []byte returned
func Sha3256Hash ¶
Sha3256Hash takes a hash of the given sets of bytes
func ToU128OrU256 ¶
ToU128OrU256 TODO: move somewhere more useful
Types ¶
type Account ¶
type Account struct {
Address AccountAddress
Signer crypto.Signer
}
Account represents an on-chain account, with an associated signer, which may be a PrivateKey
func NewAccountFromSigner ¶
func NewEd25519Account ¶
NewEd25519Account creates an account with a new random Ed25519 private key
type AccountAddress ¶
type AccountAddress [32]byte
AccountAddress a 32-byte representation of an on-chain address
func (*AccountAddress) DerivedAddress ¶
func (aa *AccountAddress) DerivedAddress(seed []byte, typeByte uint8) (accountAddress AccountAddress)
DerivedAddress addresses are derived by the address, the seed, then the type byte
func (*AccountAddress) IsSpecial ¶
func (aa *AccountAddress) IsSpecial() bool
IsSpecial Returns whether the address is a "special" address. Addresses are considered special if the first 63 characters of the hex string are zero. In other words, an address is special if the first 31 bytes are zero and the last byte is smaller than `0b10000` (16). In other words, special is defined as an address that matches the following regex: `^0x0{63}[0-9a-f]$`. In short form this means the addresses in the range from `0x0` to `0xf` (inclusive) are special. For more details see the v1 address standard defined as part of AIP-40: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md
func (*AccountAddress) MarshalBCS ¶
func (aa *AccountAddress) MarshalBCS(bcs *bcs.Serializer)
MarshalBCS Converts the AccountAddress to BCS encoded bytes
func (*AccountAddress) NamedObjectAddress ¶
func (aa *AccountAddress) NamedObjectAddress(seed []byte) (accountAddress AccountAddress)
NamedObjectAddress derives a named object address based on the input address as the creator
func (*AccountAddress) ObjectAddressFromObject ¶
func (aa *AccountAddress) ObjectAddressFromObject(objectAddress *AccountAddress) (accountAddress AccountAddress)
ObjectAddressFromObject derives an object address based on the input address as the creator object
func (*AccountAddress) ParseStringRelaxed ¶
func (aa *AccountAddress) ParseStringRelaxed(x string) error
ParseStringRelaxed parses a string into an AccountAddress TODO: add strict mode checking
func (*AccountAddress) ResourceAccount ¶
func (aa *AccountAddress) ResourceAccount(seed []byte) (accountAddress AccountAddress)
ResourceAccount derives an object address based on the input address as the creator
func (*AccountAddress) String ¶
func (aa *AccountAddress) String() string
String Returns the canonical string representation of the AccountAddress
func (*AccountAddress) StringLong ¶
func (aa *AccountAddress) StringLong() string
StringLong Returns the long string representation of the AccountAddress
func (*AccountAddress) UnmarshalBCS ¶
func (aa *AccountAddress) UnmarshalBCS(bcs *bcs.Deserializer)
UnmarshalBCS Converts the AccountAddress from BCS encoded bytes
type AddressTag ¶
type AddressTag struct{}
func (*AddressTag) GetType ¶
func (xt *AddressTag) GetType() TypeTagType
func (*AddressTag) MarshalBCS ¶
func (xt *AddressTag) MarshalBCS(_ *bcs.Serializer)
func (*AddressTag) String ¶
func (xt *AddressTag) String() string
func (*AddressTag) UnmarshalBCS ¶
func (xt *AddressTag) UnmarshalBCS(_ *bcs.Deserializer)
type BoolTag ¶
type BoolTag struct{}
func (*BoolTag) GetType ¶
func (xt *BoolTag) GetType() TypeTagType
func (*BoolTag) MarshalBCS ¶
func (xt *BoolTag) MarshalBCS(_ *bcs.Serializer)
func (*BoolTag) UnmarshalBCS ¶
func (xt *BoolTag) UnmarshalBCS(_ *bcs.Deserializer)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a facade over the multiple types of underlying clients, as the user doesn't actually care where the data comes from. It will be then handled underneath
func NewClient ¶
func NewClient(config NetworkConfig) (client *Client, err error)
NewClient Creates a new client with a specific network config that can be extended in the future
type EntryFunction ¶
EntryFunction call a single published entry function
func (*EntryFunction) MarshalBCS ¶
func (sf *EntryFunction) MarshalBCS(serializer *bcs.Serializer)
func (*EntryFunction) UnmarshalBCS ¶
func (sf *EntryFunction) UnmarshalBCS(deserializer *bcs.Deserializer)
type ExpirationSeconds ¶
type ExpirationSeconds int64
ExpirationSeconds is an option to APTTransferTransaction
type FungibleAssetClient ¶
type FungibleAssetClient struct {
// contains filtered or unexported fields
}
FungibleAssetClient This is an example client around a single fungible asset
func NewFungibleAssetClient ¶
func NewFungibleAssetClient(client *Client, metadataAddress AccountAddress) (faClient *FungibleAssetClient, err error)
NewFungibleAssetClient verifies the address exists when creating the client TODO: Add lookup of other metadata information such as symbol, supply, etc
func (*FungibleAssetClient) SimulateTransferPrimaryStore ¶
func (client *FungibleAssetClient) SimulateTransferPrimaryStore(publicKey []byte, fromAddress AccountAddress, receiverAddress AccountAddress, amount uint64, options ...any) (signedTxn *SignedTransaction, err error)
func (*FungibleAssetClient) Transfer ¶
func (client *FungibleAssetClient) Transfer(sender *Account, senderStore AccountAddress, receiverStore AccountAddress, amount uint64) (signedTxn *SignedTransaction, err error)
func (*FungibleAssetClient) TransferPrimaryStore ¶
func (client *FungibleAssetClient) TransferPrimaryStore(sender *Account, receiverAddress AccountAddress, amount uint64, options ...any) (signedTxn *SignedTransaction, err error)
type ModuleBundle ¶
type ModuleBundle struct {
}
ModuleBundle is long deprecated and no longer used, but exist as an enum position in TransactionPayload
func (*ModuleBundle) MarshalBCS ¶
func (txn *ModuleBundle) MarshalBCS(bcs *bcs.Serializer)
func (*ModuleBundle) UnmarshalBCS ¶
func (txn *ModuleBundle) UnmarshalBCS(bcs *bcs.Deserializer)
type ModuleId ¶
type ModuleId struct {
Address AccountAddress
Name string
}
ModuleId the identifier for a module e.g. 0x1::coin
func (*ModuleId) MarshalBCS ¶
func (mod *ModuleId) MarshalBCS(bcs *bcs.Serializer)
func (*ModuleId) UnmarshalBCS ¶
func (mod *ModuleId) UnmarshalBCS(bcs *bcs.Deserializer)
type NetworkConfig ¶
type NetworkConfig struct {
Name string
ChainId uint8
NodeUrl string
IndexerUrl string
FaucetUrl string
}
NetworkConfig a configuration for the Client and which network to use. Use one of the preconfigured LocalnetConfig, DevnetConfig, TestnetConfig, or MainnetConfig unless you have your own full node
type NodeClient ¶
type NodeClient struct {
// contains filtered or unexported fields
}
func NewNodeClient ¶
func NewNodeClient(rpcUrl string, chainId uint8) (*NodeClient, error)
func (*NodeClient) BuildTransaction ¶
func (rc *NodeClient) BuildTransaction(sender AccountAddress, payload TransactionPayload, options ...any) (rawTxn *RawTransaction, err error)
BuildTransaction builds a raw transaction for signing Accepts options: MaxGasAmount, GasUnitPrice, ExpirationSeconds, SequenceNumber, ChainIdOption
type RawTransaction ¶
type RawTransaction struct {
Sender AccountAddress
SequenceNumber uint64
Payload TransactionPayload
MaxGasAmount uint64
GasUnitPrice uint64
// ExpirationTimestampSeconds is seconds since Unix epoch
ExpirationTimestampSeconds uint64
ChainId uint8
}
RawTransaction representation of a transaction's parts prior to signing
func (*RawTransaction) MarshalBCS ¶
func (txn *RawTransaction) MarshalBCS(bcs *bcs.Serializer)
func (*RawTransaction) Sign ¶
func (txn *RawTransaction) Sign(sender *Account) (signedTxn *SignedTransaction, err error)
func (*RawTransaction) SigningMessage ¶
func (txn *RawTransaction) SigningMessage() (message []byte, err error)
SigningMessage generates the bytes needed to be signed by a signer
func (*RawTransaction) SimulateTransaction ¶
func (txn *RawTransaction) SimulateTransaction(publicKey []byte) (signedTxn *SignedTransaction, err error)
func (*RawTransaction) UnmarshalBCS ¶
func (txn *RawTransaction) UnmarshalBCS(bcs *bcs.Deserializer)
type Script ¶
type Script struct {
Code []byte
ArgTypes []TypeTag
Args []ScriptArgument
}
Script A Move script as compiled code as a transaction
func (*Script) MarshalBCS ¶
func (sc *Script) MarshalBCS(serializer *bcs.Serializer)
func (*Script) UnmarshalBCS ¶
func (sc *Script) UnmarshalBCS(deserializer *bcs.Deserializer)
type ScriptArgument ¶
type ScriptArgument struct {
Variant ScriptArgumentVariant
Value any
}
ScriptArgument a Move script argument, which encodes its type with it TODO: improve typing
func (*ScriptArgument) MarshalBCS ¶
func (sa *ScriptArgument) MarshalBCS(bcs *bcs.Serializer)
func (*ScriptArgument) UnmarshalBCS ¶
func (sa *ScriptArgument) UnmarshalBCS(bcs *bcs.Deserializer)
type ScriptArgumentVariant ¶
type ScriptArgumentVariant uint8
const ( ScriptArgumentU8 ScriptArgumentVariant = 0 ScriptArgumentU64 ScriptArgumentVariant = 1 ScriptArgumentU128 ScriptArgumentVariant = 2 ScriptArgumentAddress ScriptArgumentVariant = 3 ScriptArgumentU8Vector ScriptArgumentVariant = 4 ScriptArgumentBool ScriptArgumentVariant = 5 ScriptArgumentU16 ScriptArgumentVariant = 6 ScriptArgumentU32 ScriptArgumentVariant = 7 ScriptArgumentU256 ScriptArgumentVariant = 8 )
type SequenceNumber ¶
type SequenceNumber uint64
SequenceNumber is an option to APTTransferTransaction
type SignedTransaction ¶
type SignedTransaction struct {
Transaction RawTransaction
Authenticator crypto.Authenticator
}
SignedTransaction a raw transaction plus its authenticator for a fully verifiable message
func (*SignedTransaction) Hash ¶
func (txn *SignedTransaction) Hash() ([]byte, error)
func (*SignedTransaction) MarshalBCS ¶
func (txn *SignedTransaction) MarshalBCS(bcs *bcs.Serializer)
func (*SignedTransaction) UnmarshalBCS ¶
func (txn *SignedTransaction) UnmarshalBCS(bcs *bcs.Deserializer)
func (*SignedTransaction) Verify ¶
func (txn *SignedTransaction) Verify() error
Verify checks a signed transaction's signature
type SignerTag ¶
type SignerTag struct{}
func (*SignerTag) GetType ¶
func (xt *SignerTag) GetType() TypeTagType
func (*SignerTag) MarshalBCS ¶
func (xt *SignerTag) MarshalBCS(_ *bcs.Serializer)
func (*SignerTag) UnmarshalBCS ¶
func (xt *SignerTag) UnmarshalBCS(_ *bcs.Deserializer)
type StructTag ¶
type StructTag struct {
Address AccountAddress
Module string
Name string
TypeParams []TypeTag
}
func NewObjectTag ¶
func NewObjectTag(inner TypeTagImpl) *StructTag
func NewOptionTag ¶
func NewOptionTag(inner TypeTagImpl) *StructTag
func NewStringTag ¶
func NewStringTag() *StructTag
func (*StructTag) GetType ¶
func (xt *StructTag) GetType() TypeTagType
func (*StructTag) MarshalBCS ¶
func (xt *StructTag) MarshalBCS(serializer *bcs.Serializer)
func (*StructTag) UnmarshalBCS ¶
func (xt *StructTag) UnmarshalBCS(deserializer *bcs.Deserializer)
type TransactionPayload ¶
TransactionPayload the actual instructions of which functions to call on chain
func (*TransactionPayload) MarshalBCS ¶
func (txn *TransactionPayload) MarshalBCS(bcs *bcs.Serializer)
func (*TransactionPayload) UnmarshalBCS ¶
func (txn *TransactionPayload) UnmarshalBCS(bcs *bcs.Deserializer)
type TypeTag ¶
type TypeTag struct {
Value TypeTagImpl
}
TypeTag is a wrapper around a TypeTagImpl e.g. BoolTag or U8Tag for the purpose of serialization and deserialization
func NewTypeTag ¶
func NewTypeTag(inner TypeTagImpl) TypeTag
func (*TypeTag) MarshalBCS ¶
func (tt *TypeTag) MarshalBCS(bcs *bcs.Serializer)
func (*TypeTag) UnmarshalBCS ¶
func (tt *TypeTag) UnmarshalBCS(des *bcs.Deserializer)
type TypeTagImpl ¶
type TypeTagImpl interface {
bcs.Struct
GetType() TypeTagType
String() string
}
TypeTagImpl is an interface describing all the different types of TypeTag. Unfortunately because of how serialization works, a wrapper TypeTag struct is needed to handle the differentiation between types
type TypeTagType ¶
type TypeTagType uint64
const ( TypeTagBool TypeTagType = 0 TypeTagU8 TypeTagType = 1 TypeTagU64 TypeTagType = 2 TypeTagU128 TypeTagType = 3 TypeTagAddress TypeTagType = 4 TypeTagSigner TypeTagType = 5 TypeTagVector TypeTagType = 6 TypeTagStruct TypeTagType = 7 TypeTagU16 TypeTagType = 8 TypeTagU32 TypeTagType = 9 TypeTagU256 TypeTagType = 10 )
type U128Tag ¶
type U128Tag struct{}
func (*U128Tag) GetType ¶
func (xt *U128Tag) GetType() TypeTagType
func (*U128Tag) MarshalBCS ¶
func (xt *U128Tag) MarshalBCS(_ *bcs.Serializer)
func (*U128Tag) UnmarshalBCS ¶
func (xt *U128Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U16Tag ¶
type U16Tag struct{}
func (*U16Tag) GetType ¶
func (xt *U16Tag) GetType() TypeTagType
func (*U16Tag) MarshalBCS ¶
func (xt *U16Tag) MarshalBCS(_ *bcs.Serializer)
func (*U16Tag) UnmarshalBCS ¶
func (xt *U16Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U256Tag ¶
type U256Tag struct{}
func (*U256Tag) GetType ¶
func (xt *U256Tag) GetType() TypeTagType
func (*U256Tag) MarshalBCS ¶
func (xt *U256Tag) MarshalBCS(_ *bcs.Serializer)
func (*U256Tag) UnmarshalBCS ¶
func (xt *U256Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U32Tag ¶
type U32Tag struct{}
func (*U32Tag) GetType ¶
func (xt *U32Tag) GetType() TypeTagType
func (*U32Tag) MarshalBCS ¶
func (xt *U32Tag) MarshalBCS(_ *bcs.Serializer)
func (*U32Tag) UnmarshalBCS ¶
func (xt *U32Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U64Tag ¶
type U64Tag struct{}
func (*U64Tag) GetType ¶
func (xt *U64Tag) GetType() TypeTagType
func (*U64Tag) MarshalBCS ¶
func (xt *U64Tag) MarshalBCS(_ *bcs.Serializer)
func (*U64Tag) UnmarshalBCS ¶
func (xt *U64Tag) UnmarshalBCS(_ *bcs.Deserializer)
type U8Tag ¶
type U8Tag struct{}
func (*U8Tag) GetType ¶
func (xt *U8Tag) GetType() TypeTagType
func (*U8Tag) MarshalBCS ¶
func (xt *U8Tag) MarshalBCS(_ *bcs.Serializer)
func (*U8Tag) UnmarshalBCS ¶
func (xt *U8Tag) UnmarshalBCS(_ *bcs.Deserializer)
type VectorTag ¶
type VectorTag struct {
TypeParam TypeTag
}
func NewVectorTag ¶
func NewVectorTag(inner TypeTagImpl) *VectorTag
func (*VectorTag) GetType ¶
func (xt *VectorTag) GetType() TypeTagType
func (*VectorTag) MarshalBCS ¶
func (xt *VectorTag) MarshalBCS(serializer *bcs.Serializer)
func (*VectorTag) UnmarshalBCS ¶
func (xt *VectorTag) UnmarshalBCS(deserializer *bcs.Deserializer)
type ViewPayload ¶
func (*ViewPayload) MarshalBCS ¶
func (vp *ViewPayload) MarshalBCS(serializer *bcs.Serializer)