bind

package
v0.0.0-...-67263d3 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 8 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// ChunkSizeInBytes is the default maximum size of a chunk in bytes
	// 55k is the value used in aptos-core. We're using 30k to leave some room as deployments
	// will be done via mcms proposals
	// https://github.com/aptos-labs/aptos-core/blob/e0002dd4ca29d1b65fe10c555ac730a773a54b2f/aptos-move/framework/src/chunked_publish.rs#L13-L13
	ChunkSizeInBytes = 30_000

	// DefaultDeployMaxGasAmount is the default max gas for package deployment transactions.
	// The SDK default (100_000) is too low for deploying Move packages which involve
	// resource account creation + code publishing. Unused gas is not charged on Aptos.
	DefaultDeployMaxGasAmount = uint64(20_000_000)
)
View Source
const (
	// LargePackagesModuleAddress is the predeployed address of the LargePackages module.
	// It is available on mainnet and testnet only.
	// https://github.com/aptos-labs/aptos-core/blob/e0002dd4ca29d1b65fe10c555ac730a773a54b2f/aptos-move/framework/src/chunked_publish.rs#L9-L9
	LargePackagesModuleAddress = "0x0e1ca3011bdd07246d4d16d909dbb2d6953a86c4735d5acf5865d962c630cce7"
)

Variables

This section is empty.

Functions

func AssembleChunks

func AssembleChunks(chunks []ChunkedPayload) (metadata []byte, bytecode [][]byte)

AssembleChunks takes a chunked payload and assembles it back into the original metadata and bytecode

func DeployPackageToObject

func DeployPackageToObject(
	auth aptos.TransactionSigner,
	client aptos.AptosRpcClient,

	packageName contracts.Package,

	namedAddresses map[string]aptos.AccountAddress,

	options ...any,
) (aptos.AccountAddress, *api.PendingTransaction, error)

DeployPackageToObject deploys a package to a new named object address The package will be compiled using the CLI and then deployed using 0x1::object_code_deployment::publish If the package is too large to be deployed in one go, it will be chunked and deployed using the LargePackages contract The resulting address will be calculated using the deployer's account address and the next sequence number, following the Aptos NamedObjectScheme

func DeployPackageToResourceAccount

func DeployPackageToResourceAccount(
	auth aptos.TransactionSigner,
	client aptos.AptosRpcClient,

	packageName contracts.Package,

	seed string,

	namedAddresses map[string]aptos.AccountAddress,

	options ...any,
) (aptos.AccountAddress, *api.PendingTransaction, error)

DeployPackageToResourceAccount deploys a package to a new resource account The package will be compiled using the CLI and then deployed using 0x1::resource_account::create_resource_account_and_publish_package The resulting address will be calculated using the deployer's account address and the given seed, following the Aptos ResourceAccountScheme

func UpgradePackageToObject

func UpgradePackageToObject(
	auth aptos.TransactionSigner,
	client aptos.AptosRpcClient,

	packageName contracts.Package,

	namedAddresses map[string]aptos.AccountAddress,
	objectAddress aptos.AccountAddress,

	options ...any,
) (*api.PendingTransaction, error)

UpgradePackageToObject upgrades a package or deploys a new package onto an existing code object. The package will be compiled using the CLI and then deployed using 0x1::object_code_deployment::upgrade. If the package is too large to be deployed in a single transaction or if the force large packages flag is set, it will be chunked and deployed using the LargePackages contract.

Types

type BoundContract

type BoundContract struct {
	// contains filtered or unexported fields
}

func NewBoundContract

func NewBoundContract(address aptos.AccountAddress, packageName, moduleName string, client aptos.AptosRpcClient) *BoundContract

func (*BoundContract) Call

func (c *BoundContract) Call(opts *CallOpts, module ModuleInformation, function string, argTypes []aptos.TypeTag, args [][]byte) ([]any, error)

func (*BoundContract) Encode

func (c *BoundContract) Encode(function string, typeArgs, paramTypes []string, paramValues []any) (moduleInfo ModuleInformation, fun string, argTypes []aptos.TypeTag, args [][]byte, err error)

func (*BoundContract) Transact

func (c *BoundContract) Transact(opts *TransactOpts, module ModuleInformation, function string, argTypes []aptos.TypeTag, args [][]byte) (*api.PendingTransaction, error)

type CallOpts

type CallOpts struct {
	// Optional ledger version to query at. If nil, the latest ledger version is used.
	LedgerVersion *uint64
}

type ChunkedPayload

type ChunkedPayload struct {
	Metadata    []byte
	CodeIndices []uint16
	Chunks      [][]byte
}

func CreateChunks

func CreateChunks(output compile.CompiledPackage, chunkSizeByte uint) ([]ChunkedPayload, error)

CreateChunks splits the metadata and bytecode into chunks of size chunkSizeByte

type Event

type Event interface {
	EventName() string
}

Event is an interface that all events must implement.

type FunctionInfo

type FunctionInfo struct {
	Package    string              `json:"package"`
	Module     string              `json:"module"`
	Name       string              `json:"name"`
	Parameters []FunctionParameter `json:"parameters"`
}

func (FunctionInfo) String

func (f FunctionInfo) String() string

type FunctionInfos

type FunctionInfos []FunctionInfo

func CombineFunctionInfos

func CombineFunctionInfos(infos ...FunctionInfos) FunctionInfos

func MustParseFunctionInfo

func MustParseFunctionInfo(info ...string) FunctionInfos

func ParseFunctionInfo

func ParseFunctionInfo(info ...string) (FunctionInfos, error)

func (FunctionInfos) String

func (f FunctionInfos) String() string

type FunctionParameter

type FunctionParameter struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type LargePackagesInterface

type LargePackagesInterface interface {
	StageCodeChunk(opts *TransactOpts, metadataChunk []byte, codeIndices []uint16, codeChunks [][]byte) (*api.PendingTransaction, error)
	StageCodeChunkAndPublishToAccount(opts *TransactOpts, metadataChunk []byte, codeIndices []uint16, codeChunks [][]byte) (*api.PendingTransaction, error)
	StageCodeChunkAndPublishToObject(opts *TransactOpts, metadataChunk []byte, codeIndices []uint16, codeChunks [][]byte) (*api.PendingTransaction, error)
	StageCodeChunkAndUpgradeObjectCode(opts *TransactOpts, metadataChunk []byte, codeIndices []uint16, codeChunks [][]byte, objectAddress aptos.AccountAddress) (*api.PendingTransaction, error)
}

type LargePackagesTransactor

type LargePackagesTransactor struct {
	*BoundContract
}

func (LargePackagesTransactor) CleanupStagingArea

func (l LargePackagesTransactor) CleanupStagingArea(opts *TransactOpts) (*api.PendingTransaction, error)

func (LargePackagesTransactor) StageCodeChunk

func (l LargePackagesTransactor) StageCodeChunk(opts *TransactOpts, metadataChunk []byte, codeIndices []uint16, codeChunks [][]byte) (*api.PendingTransaction, error)

func (LargePackagesTransactor) StageCodeChunkAndPublishToAccount

func (l LargePackagesTransactor) StageCodeChunkAndPublishToAccount(opts *TransactOpts, metadataChunk []byte, codeIndices []uint16, codeChunks [][]byte) (*api.PendingTransaction, error)

func (LargePackagesTransactor) StageCodeChunkAndPublishToObject

func (l LargePackagesTransactor) StageCodeChunkAndPublishToObject(opts *TransactOpts, metadataChunk []byte, codeIndices []uint16, codeChunks [][]byte) (*api.PendingTransaction, error)

func (LargePackagesTransactor) StageCodeChunkAndUpgradeObjectCode

func (l LargePackagesTransactor) StageCodeChunkAndUpgradeObjectCode(opts *TransactOpts, metadataChunk []byte, codeIndices []uint16, codeChunks [][]byte, objectAddress aptos.AccountAddress) (*api.PendingTransaction, error)

type ModuleInformation

type ModuleInformation struct {
	PackageName string
	ModuleName  string
	Address     aptos.AccountAddress
}

type StdElement

type StdElement[K, V any] struct {
	Key   K
	Value V
}

type StdObject

type StdObject struct {
	Inner aptos.AccountAddress
}

StdObject is a binding for 0x1::object::Object

func (StdObject) Address

func (obj StdObject) Address() aptos.AccountAddress

type StdOption

type StdOption[T any] struct {
	Vec []T
}

StdOption is a binding for 0x1::option::Option Vec is guaranteed to be of size <0,1>, with 0 representing an unset option::none and 1 representing a set option::some

func (StdOption[T]) Value

func (opt StdOption[T]) Value() *T

type StdSimpleMap

type StdSimpleMap[K, V any] struct {
	Data []StdElement[K, V]
}

StdSimpleMap is a binding for 0x1::simple_map::SimpleMap

type TransactOpts

type TransactOpts struct {
	Signer aptos.TransactionSigner

	MaxGasAmount      *uint64
	GasUnitPrice      *uint64
	ExpirationSeconds *uint64
	SequenceNumber    *uint64
}

Jump to

Keyboard shortcuts

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