Skip to content

Latest commit

 

History

History
1114 lines (655 loc) · 23.1 KB

WalletClient.md

File metadata and controls

1114 lines (655 loc) · 23.1 KB

@martiandao/aptos-web3-bip44.js / Exports / WalletClient

Class: WalletClient

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new WalletClient(node_url, faucet_url)

Parameters

Name Type
node_url any
faucet_url any

Defined in

wallet_client.ts:44

Properties

aptosClient

aptosClient: AptosClient

Defined in

wallet_client.ts:40


faucetClient

faucetClient: FaucetClient

Defined in

wallet_client.ts:38


tokenClient

tokenClient: TokenClient

Defined in

wallet_client.ts:42

Methods

accountTransactions

accountTransactions(accountAddress): Promise<{ data: any = item.payload; from: any = item.sender; gas: any = item.gas_used; gasPrice: any = item.gas_unit_price; hash: any = item.hash; price: any ; success: any = item.success; timestamp: any = item.timestamp; toAddress: any ; type: any = item.type; version: any = item.version; vmStatus: any = item.vm_status }[]>

returns the list of on-chain transactions sent by the said account

Parameters

Name Type Description
accountAddress MaybeHexString address of the desired account

Returns

Promise<{ data: any = item.payload; from: any = item.sender; gas: any = item.gas_used; gasPrice: any = item.gas_unit_price; hash: any = item.hash; price: any ; success: any = item.success; timestamp: any = item.timestamp; toAddress: any ; type: any = item.type; version: any = item.version; vmStatus: any = item.vm_status }[]>

list of transactions

Defined in

wallet_client.ts:240


airdrop

airdrop(address, amount): Promise<string[]>

airdrops test coins in the given account

Parameters

Name Type Description
address string address of the receiver's account
amount number amount to be airdropped

Returns

Promise<string[]>

list of transaction hashs

Defined in

wallet_client.ts:211


cancelTokenOffer

cancelTokenOffer(account, receiver_address, creator_address, collection_name, token_name): Promise<string>

cancels an NFT offer

Parameters

Name Type Description
account AptosAccount AptosAccount of the signing account
receiver_address string address of the receiver account
creator_address string address of the creator account
collection_name string collection name
token_name string NFT name

Returns

Promise<string>

transaction hash

Defined in

wallet_client.ts:424


claimToken

claimToken(account, sender_address, creator_address, collection_name, token_name): Promise<string>

claims offered NFT

Parameters

Name Type Description
account AptosAccount AptosAccount of the signing account
sender_address string address of the sender account
creator_address string address of the creator account
collection_name string collection name
token_name string NFT name

Returns

Promise<string>

transaction hash

Defined in

wallet_client.ts:452


createCollection

createCollection(account, name, description, uri): Promise<string>

creates an NFT collection

Parameters

Name Type Description
account AptosAccount AptosAccount object of the signing account
name string collection name
description string collection description
uri string collection URI

Returns

Promise<string>

transaction hash

Defined in

wallet_client.ts:338


createNewAccount

createNewAccount(code): Promise<AccountMetaData>

Creates a new account in the provided wallet

Parameters

Name Type Description
code string mnemonic phrase of the wallet

Returns

Promise<AccountMetaData>

Defined in

wallet_client.ts:136


createToken

createToken(account, collection_name, name, description, supply, uri, royalty_points_per_million?): Promise<string>

creates an NFT

Parameters

Name Type Default value Description
account AptosAccount undefined AptosAccount object of the signing account
collection_name string undefined collection name
name string undefined NFT name
description string undefined NFT description
supply number undefined supply for the NFT
uri string undefined NFT URI
royalty_points_per_million number 0 royalty points per million

Returns

Promise<string>

transaction hash

Defined in

wallet_client.ts:361


createWallet

createWallet(): Promise<Wallet>

Creates a new wallet which contains a single account, which is registered on Aptos

Returns

Promise<Wallet>

A wallet object

Defined in

wallet_client.ts:124


getAccountResource

getAccountResource(accountAddress, resourceType): Promise<any>

returns info about a particular resource inside an account

Parameters

Name Type Description
accountAddress string address of the desired account
resourceType string type of the desired resource

Returns

Promise<any>

resource information

Defined in

wallet_client.ts:842


getBalance

getBalance(address): Promise<number>

returns the balance of the said account

Parameters

Name Type Description
address string | HexString address of the desired account

Returns

Promise<number>

balance of the account

Defined in

wallet_client.ts:223


getCoinBalance

getCoinBalance(address, coin_type_path): Promise<number>

returns the balance of the coin for an account

Parameters

Name Type Description
address string address of the desired account
coin_type_path string address path of the desired coin

Returns

Promise<number>

number of coins

Defined in

wallet_client.ts:1035


getCoinData

getCoinData(coin_type_path): Promise<any>

returns the information about the coin

Parameters

Name Type Description
coin_type_path string address path of the desired coin

Returns

Promise<any>

coin information

Defined in

wallet_client.ts:1020


getCollection

getCollection(address, collectionName): Promise<any>

returns the information about a collection of an account

Parameters

Name Type Description
address string address of the desired account
collectionName string collection name

Returns

Promise<any>

collection information

Defined in

wallet_client.ts:786


getCustomResource

getCustomResource(address, resourceType, fieldName, keyType, valueType, key): Promise<any>

Parameters

Name Type
address string
resourceType string
fieldName string
keyType string
valueType string
key any

Returns

Promise<any>

Defined in

wallet_client.ts:807


getEventStream

getEventStream(address, eventHandleStruct, fieldName): Promise<any>

Parameters

Name Type
address string
eventHandleStruct string
fieldName string

Returns

Promise<any>

Defined in

wallet_client.ts:641


getReceivedEvents

getReceivedEvents(address): Promise<Event[]>

returns the list of events involving transactions of Aptos Coins received by the said account

Parameters

Name Type Description
address string address of the desired account

Returns

Promise<Event[]>

list of events

Defined in

wallet_client.ts:319


getSentEvents

getSentEvents(address): Promise<OnChainTransaction[]>

returns the list of events involving transactions starting from the said account

Parameters

Name Type Description
address MaybeHexString address of the desired account

Returns

Promise<OnChainTransaction[]>

list of events

Defined in

wallet_client.ts:306


getToken

getToken(tokenId): Promise<any>

returns the token information (including the collection information) about a said tokenID

Parameters

Name Type Description
tokenId TokenId token ID of the desired token

Returns

Promise<any>

token information

Defined in

wallet_client.ts:758


getTokenIds

getTokenIds(address): Promise<any[]>

returns a list of token IDs of the tokens in a user's account (including the tokens that were minted)

Parameters

Name Type Description
address string address of the desired account

Returns

Promise<any[]>

list of token IDs

Defined in

wallet_client.ts:667


getTokens

getTokens(address): Promise<any[]>

returns the tokens in an account

Parameters

Name Type Description
address string address of the desired account

Returns

Promise<any[]>

list of tokens and their collection data

Defined in

wallet_client.ts:717


importWallet

importWallet(code): Promise<Wallet>

Each mnemonic phrase corresponds to a single wallet Wallet can contain multiple accounts An account corresponds to a key pair + address

Get all the accounts of a user from their mnemonic phrase

Parameters

Name Type Description
code string The mnemonic phrase (12 word)

Returns

Promise<Wallet>

Wallet object containing all accounts of a user

Defined in

wallet_client.ts:60


initializeCoin

initializeCoin(account, coin_type_path, name, symbol, scaling_factor): Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

initializes a coin

precondition: a module of the desired coin has to be deployed in the signer's account

Parameters

Name Type Description
account AptosAccount AptosAccount object of the signing account
coin_type_path string address path of the desired coin
name string name of the coin
symbol string symbol of the coin
scaling_factor number scaling factor of the coin

Returns

Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

transaction hash

Defined in

wallet_client.ts:871


mintCoin

mintCoin(account, coin_type_path, dst_address, amount): Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

mints a coin in a receiver account

precondition: the signer should have minting capability unless specifically granted, only the account where the module of the desired coin lies has the minting capability

Parameters

Name Type Description
account AptosAccount AptosAccount object of the signing account
coin_type_path string address path of the desired coin
dst_address string address of the receiver account
amount number amount to be minted

Returns

Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

transaction hash

Defined in

wallet_client.ts:951


offerToken

offerToken(account, receiver_address, creator_address, collection_name, token_name, amount): Promise<string>

offers an NFT to another account

Parameters

Name Type Description
account AptosAccount AptosAccount object of the signing account
receiver_address string address of the receiver account
creator_address string address of the creator account
collection_name string collection name
token_name string NFT name
amount number amount to receive while offering the token

Returns

Promise<string>

transaction hash

Defined in

wallet_client.ts:394


registerCoin

registerCoin(account, coin_type_path): Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

registers a coin for an account

creates the resource for the desired account such that the account can start transacting in the desired coin

Parameters

Name Type Description
account AptosAccount AptosAccount object of the signing account
coin_type_path string address path of the desired coin

Returns

Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

transaction hash

Defined in

wallet_client.ts:914


rotateAuthKey

rotateAuthKey(code, metaData): Promise<{ authkey: string = ""; success: boolean = false; vm_status: any = transactionStatus.vm_status }>

Rotates the auth key

Parameters

Name Type Description
code string mnemonic phrase for the desired wallet
metaData AccountMetaData metadata for the desired account

Returns

Promise<{ authkey: string = ""; success: boolean = false; vm_status: any = transactionStatus.vm_status }>

status object

Defined in

wallet_client.ts:601


signAndSubmitTransaction

signAndSubmitTransaction(account, txnRequest): Promise<string>

Parameters

Name Type
account AptosAccount
txnRequest UserTransactionRequest

Returns

Promise<string>

Defined in

wallet_client.ts:508


signAndSubmitTransactions

signAndSubmitTransactions(account, txnRequests): Promise<any[]>

Parameters

Name Type
account AptosAccount
txnRequests UserTransactionRequest[]

Returns

Promise<any[]>

Defined in

wallet_client.ts:522


signGenericTransaction

signGenericTransaction(account, func, args, type_args): Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

sign a generic transaction

Parameters

Name Type Description
account AptosAccount AptosAccount of the signing account
func string function name to be called
args string[] arguments of the function to be called
type_args string[] type arguments of the function to be called

Returns

Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

transaction hash

Defined in

wallet_client.ts:479


signTransaction

signTransaction(account, txnRequest): Promise<SubmitTransactionRequest>

Parameters

Name Type
account AptosAccount
txnRequest UserTransactionRequest

Returns

Promise<SubmitTransactionRequest>

Defined in

wallet_client.ts:549


submitBCSSimulation

submitBCSSimulation(bcsBody): Promise<OnChainTransaction>

Parameters

Name Type
bcsBody Uint8Array

Returns

Promise<OnChainTransaction>

Defined in

wallet_client.ts:584


submitSignedBCSTransaction

submitSignedBCSTransaction(signedTxn): Promise<PendingTransaction>

Parameters

Name Type
signedTxn Uint8Array

Returns

Promise<PendingTransaction>

Defined in

wallet_client.ts:576


submitTransaction

submitTransaction(signedTxn): Promise<PendingTransaction>

Parameters

Name Type
signedTxn SubmitTransactionRequest

Returns

Promise<PendingTransaction>

Defined in

wallet_client.ts:558


transfer

transfer(account, recipient_address, amount): Promise<string | Error>

transfers Aptos Coins from signer to receiver

Parameters

Name Type Description
account AptosAccount AptosAccount object of the signing account
recipient_address string | HexString address of the receiver account
amount number amount of aptos coins to be transferred

Returns

Promise<string | Error>

transaction hash

Defined in

wallet_client.ts:267


transferCoin

transferCoin(account, coin_type_path, to_address, amount): Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

transfers coin (applicable for all altcoins on Aptos) to receiver account

Parameters

Name Type Description
account AptosAccount AptosAccount object of the signing account
coin_type_path string address path of the desired coin
to_address string address of the receiver account
amount number amount to be transferred

Returns

Promise<{ success: any = resp.success; txnHash: string ; vm_status: any = resp.vm_status }>

transaction hash

Defined in

wallet_client.ts:987


generateBCSSimulation

Static generateBCSSimulation(account, rawTxn): Promise<Uint8Array>

Parameters

Name Type
account AptosAccount
rawTxn RawTransaction

Returns

Promise<Uint8Array>

Defined in

wallet_client.ts:569


generateBCSTransaction

Static generateBCSTransaction(account, rawTxn): Promise<Uint8Array>

Parameters

Name Type
account AptosAccount
rawTxn RawTransaction

Returns

Promise<Uint8Array>

Defined in

wallet_client.ts:562


getAccountFromMetaData

Static getAccountFromMetaData(code, metaData): AptosAccount

returns an AptosAccount object for the desired account using the metadata of the account

Parameters

Name Type Description
code string mnemonic phrase of the wallet
metaData AccountMetaData metadata of the account to be fetched

Returns

AptosAccount

Defined in

wallet_client.ts:197


getAccountFromMnemonic

Static getAccountFromMnemonic(code): AptosAccount

returns an AptosAccount at position m/44'/COIN_TYPE'/0'/0/0

Parameters

Name Type Description
code string mnemonic phrase of the wallet

Returns

AptosAccount

AptosAccount object

Defined in

wallet_client.ts:182


getAccountFromPrivateKey

Static getAccountFromPrivateKey(privateKey, address?): AptosAccount

returns an AptosAccount object given a private key and address of the account

Parameters

Name Type Description
privateKey Buffer Private key of an account as a Buffer
address? string address of a user

Returns

AptosAccount

AptosAccount object

Defined in

wallet_client.ts:172


signMessage

Static signMessage(account, message): Promise<string>

Parameters

Name Type
account AptosAccount
message string

Returns

Promise<string>

Defined in

wallet_client.ts:590