aptos

package module
v0.0.0-...-61460eb Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 13 Imported by: 1

README

aptos-sdk

Aptos SDK is used to interact with the Aptos blockchain, it contains various functions can be used to web3 wallet.

Installation

go get

To obtain the latest version, simply require the project using :

go get -u github.com/okx/go-wallet-sdk/coins/aptos

Usage

New Address
	// address
	addr, err := aptos.NewAddress("1790962db820729606cd7b255ace1ac5ebb129ac8e9b2d8534d022194ab25b37", false)
	if err != nil {
		// todo
		fmt.Println(err)
	}

Transfer
	// transfer
	from := addr
	to := "0xedc4410aa38b512e3173fcd1e119abb13872d6928dce0842664ad6ada1ccd28"
	amount := 1000
	sequenceNumber := 1
	maxGasAmount := 10000
	gasUnitPrice := 100
	expirationTimestampSecs := time.Now().Unix() + 300
	chainId := 2
	seedHex := "1790962db820729606cd7b255ace1ac5ebb129ac8e9b2d8534d022194ab25b37"
	data, err := aptos.Transfer(from, uint64(sequenceNumber), uint64(maxGasAmount), uint64(gasUnitPrice), uint64(expirationTimestampSecs), uint8(chainId),
		to, uint64(amount), seedHex)
	if err != nil {
		// todo
		fmt.Println(err)
	}
	fmt.Println(data)

License

Most packages or folder are MIT licensed, see package or folder for the respective license.

Documentation

Index

Constants

View Source
const HexPrefix = "0x"

Variables

This section is empty.

Functions

func AddStake

func AddStake(from string, sequenceNumber uint64, maxGasAmount uint64, gasUnitPrice uint64, expirationTimestampSecs uint64, chainId uint8,
	poolAddress string, amount uint64, seedHex string) (string, error)

func AddStakePayload

func AddStakePayload(poolAddress string, amount uint64) (aptos_types.TransactionPayload, error)

func BuildSignedTransaction

func BuildSignedTransaction(from string, sequenceNumber uint64, maxGasAmount uint64, gasUnitPrice uint64, expirationTimestampSecs uint64, chainId uint8,
	payload aptos_types.TransactionPayload, seedHex string) (string, error)

func ClaimNFTTokenPayload

func ClaimNFTTokenPayload(sender string, creator string, collectionName string, tokenName string, propertyVersion uint64) (aptos_types.TransactionPayload, error)

func CoinBurnPayload

func CoinBurnPayload(amount uint64, tyArg string) (aptos_types.TransactionPayload, error)

func CoinMintPayload

func CoinMintPayload(receiveAddress string, amount uint64, tyArg string) (aptos_types.TransactionPayload, error)

func CoinRegisterPayload

func CoinRegisterPayload(tyArg string) (aptos_types.TransactionPayload, error)

func CoinTransferPayload

func CoinTransferPayload(to string, amount uint64, tyArg string) (aptos_types.TransactionPayload, error)

func ConvertArgs

func ConvertArgs(args []interface{}, arg_types []aptos_types.MoveType) ([][]byte, error)

func ExpandAddress

func ExpandAddress(address string) string

func GetAddressByPubKey

func GetAddressByPubKey(pubKeyHex string, shortEnable bool) (string, error)

func GetRawTxHash

func GetRawTxHash(rawTxn *aptos_types.RawTransaction) (string, error)

func GetSigningHash

func GetSigningHash(from string, sequenceNumber uint64, maxGasAmount uint64, gasUnitPrice uint64, expirationTimestampSecs uint64, chainId uint8,
	to string, amount uint64) (string, error)

func GetTransactionHash

func GetTransactionHash(hexStr string) (string, error)

pub enum Transaction { /// Transaction submitted by the user. e.g: P2P payment transaction, publishing module /// transaction, etc. /// TODO: We need to rename SignedTransaction to SignedUserTransaction, as well as all the other /// transaction aptos_types we had in our codebase. UserTransaction(SignedTransaction),

/// Transaction that applies a WriteSet to the current storage, it's applied manually via db-bootstrapper. GenesisTransaction(WriteSetPayload),

/// Transaction to update the block metadata resource at the beginning of a block. BlockMetadata(BlockMetadata),

/// Transaction to let the executor update the global state tree and record the root hash /// in the TransactionInfo /// The hash value inside is unique block id which can generate unique hash of state checkpoint transaction StateCheckpoint(HashValue), }

func Interface2U128

func Interface2U128(value interface{}) (*serde.Uint128, error)

func Interface2U64

func Interface2U64(value interface{}) (uint64, error)

func MakeRawTransaction

func MakeRawTransaction(from string, sequenceNumber uint64, maxGasAmount uint64, gasUnitPrice uint64,
	expirationTimestampSecs uint64, chainId uint8, payload aptos_types.TransactionPayload) (*aptos_types.RawTransaction, error)

func NewAddress

func NewAddress(seedHex string, shortEnable bool) (string, error)

func OfferNFTTokenPayload

func OfferNFTTokenPayload(receiver string, creator string, collectionName string, tokenName string, propertyVersion uint64, amount uint64) (aptos_types.TransactionPayload, error)

func PayloadFromJsonAndAbi

func PayloadFromJsonAndAbi(payload string, abi string) (aptos_types.TransactionPayload, error)

func ReactivateStake

func ReactivateStake(from string, sequenceNumber uint64, maxGasAmount uint64, gasUnitPrice uint64, expirationTimestampSecs uint64, chainId uint8,
	poolAddress string, amount uint64, seedHex string) (string, error)

func ReactivateStakePayload

func ReactivateStakePayload(poolAddress string, amount uint64) (aptos_types.TransactionPayload, error)

func ShortenAddress

func ShortenAddress(address string) string

func SignMessage

func SignMessage(priKey, message string) (string, error)

func SignRawTransaction

func SignRawTransaction(rawTxn *aptos_types.RawTransaction, seedHex string) (string, error)

func SignedTx

func SignedTx(rawTxn *aptos_types.RawTransaction, signDataHex string, pubKey string) (string, error)

func SimulateTransaction

func SimulateTransaction(rawTxn *aptos_types.RawTransaction, seedHex string) (string, error)

func String2U128

func String2U128(str string) (*serde.Uint128, error)

func Transfer

func Transfer(from string, sequenceNumber uint64, maxGasAmount uint64, gasUnitPrice uint64, expirationTimestampSecs uint64, chainId uint8,
	to string, amount uint64, seedHex string) (string, error)

func TransferPayload

func TransferPayload(to string, amount uint64) (aptos_types.TransactionPayload, error)

func Unlock

func Unlock(from string, sequenceNumber uint64, maxGasAmount uint64, gasUnitPrice uint64, expirationTimestampSecs uint64, chainId uint8,
	poolAddress string, amount uint64, seedHex string) (string, error)

func UnlockPayload

func UnlockPayload(poolAddress string, amount uint64) (aptos_types.TransactionPayload, error)

func ValidateAddress

func ValidateAddress(address string, shortEnable bool) bool

hex 32bytes

func Withdraw

func Withdraw(from string, sequenceNumber uint64, maxGasAmount uint64, gasUnitPrice uint64, expirationTimestampSecs uint64, chainId uint8,
	poolAddress string, amount uint64, seedHex string) (string, error)

func WithdrawPayload

func WithdrawPayload(poolAddress string, amount uint64) (aptos_types.TransactionPayload, error)

Types

type AptosWallet

type AptosWallet struct {
	wallet.WalletBase
}

func (*AptosWallet) GetRandomPrivateKey

func (aw *AptosWallet) GetRandomPrivateKey() (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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