-
Notifications
You must be signed in to change notification settings - Fork 1
Account
Aptos Blockchain Account
public struct Account: Equatable
Equatable
The account address associated with the account
public let accountAddress: AccountAddress
The private key for the account
public let privateKey: PrivateKey
Generate a new account instance with a random private key.
public static func generate() throws -> Account
This function generates a new private key and derives the associated account address. A new account instance is created with the generated address and private key.
An error of type Error if there was a problem generating the private key or account address.
A new Account instance with a randomly generated private key and associated account address.
Load an account from a private key in hex format.
public static func loadKey(_ key: String) throws -> Account
This function takes a private key in hex format and attempts to load it into an account by creating a PrivateKey instance from the hex string and then deriving an AccountAddress from the public key. A new Account instance is created using the derived AccountAddress and the PrivateKey.
- key: A private key in hex format.
An error of type PrivateKeyError if the private key cannot be derived from the hex string, or AccountAddressError if the account address cannot be derived from the private key.
An Account instance containing the derived AccountAddress and PrivateKey.
Load an account from a JSON file.
public static func load(_ path: String) throws -> Account
This function loads an account object from a JSON file by reading the file content from the provided path, deserializing the JSON data, retrieving the account_address and private_key keys, and then constructing and returning an account object from them.
- path: A string representing the path to the JSON file.
An error of type AptosError if the JSON file is invalid, if the account_address key is missing, or if the private_key key is missing.
An account object constructed from the account_address and private_key keys in the JSON file.
Store the account information to a file at the given path.
public func store(_ path: String) throws
This function takes a path as a string and stores the account information in a JSON file with keys for the account address and the private key in hex format.
- path: A string representing the file path to store the account information.
An error of type AptosError if there is an issue writing to the file.
Returns the account's account address.
public func address() -> AccountAddress
An AccountAddress object
Returns the hexadecimal representation of the authorization key for the account
public func authKey() throws -> String
A String object
Use the private key to sign the data inputted.
public func sign(_ data: Data) throws -> Signature
- data: The data being serialized / signed
A Signature object
Returns the public key of the associated account
public func publicKey() throws -> PublicKey
A PublicKey object
public static func == (lhs: Account, rhs: Account) -> Bool
Generated at 2023-07-20T02:24:43+0000 using swift-doc 1.0.0-rc.1.
Types
- Account
- AccountAddress
- AccountAddressTag
- AccountResponse
- AnyTransactionArgument
- AptosError
- AptosRestClientError
- BoolTag
- ClientConfig
- Collection
- Ed25519Authenticator
- Ed25519BIP32
- EntryFunction
- HTTPMethod
- InfoResponse
- InvalidPropertyType
- Mnemonic
- Mnemonic.Error
- ModuleBundle
- ModuleId
- MultiAgentAuthenticator
- MultiAgentRawTransaction
- MultiEd25519Authenticator
- MultiPublicKey
- MultiSignature
- Object
- PrivateKey
- Property
- PropertyMap
- PublicKey
- RawTransaction
- RotatingProofChallenge
- Royalty
- Script
- ScriptArgument
- SeedMode
- Serializer
- Signature
- SignedTransaction
- StructTag
- StructTagValue
- Token
- TransactionArgument
- U128Tag
- U16Tag
- U256Tag
- U32Tag
- U64Tag
- U8Tag
- UInt128
- UInt128Errors
- Wallet
- Wordlists
Protocols
Global Variables
Global Functions
- _struct(_:)
- account(_:ledgerVersion:)
- accountBalance(_:_:)
- accountResource(_:_:_:)
- accountResources(_:_:)
- accountSequenceNumber(_:_:)
- addTokenProperty(_:_:_:)
- aggregatorValue(_:_:_:)
- asyncData(with:method:headers:body:)
- bcsTransfer(_:_:_:)
- bool()
- burnToken(_:_:)
- claimToken(_:_:_:_:_:_:)
- createBcsSignedTransaction(_:_:)
- createBcsSignedTransaction(_:_:_:)
- createBcsTransaction(_:_:)
- createBcsTransaction(_:_:_:)
- createCollection(_:_:_:_:)
- createCollection(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)
- createCollectionPayload(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)
- createMultiAgentBcsTransaction(_:_:_:)
- createToken(_:_:_:_:_:_:_:)
- decodeData(_:with:keyDecodingStrategy:dataDecodingStrategy:dateDecodingStrategy:)
- decodeUrl(_:with:)
- decodeUrl(with:_:)
- decodeUrl(with:_:_:)
- deserialize(from:)
- directTransferToken(_:_:_:_:_:_:_:)
- fixedBytes(length:)
- freezeToken(_:_:)
- fundAccount(_:_:)
- getCollection(_:_:)
- getTableItem(_:_:_:_:_:_:)
- getToken(_:_:_:_:_:)
- getTokenBalance(_:_:_:_:_:)
- getTokenData(_:_:_:_:)
- info()
- map(keyDecoder:valueDecoder:)
- mintSoulBoundToken(_:_:_:_:_:_:_:)
- mintToken(_:_:_:_:_:_:)
- mintTokenPayload(_:_:_:_:_:)
- offerToken(_:_:_:_:_:_:_:)
- publishPackage(_:_:_:)
- readObject(address:)
- remaining()
- removeTokenProperty(_:_:_:)
- sequence(valueDecoder:)
- serialize(_:)
- simulateTransaction(_:_:)
- string(_:)
- submitBcsTransaction(_:)
- submitTransaction(_:_:)
- toBytes(_:)
- transactionPending(_:)
- transfer(_:_:_:)
- u128(_:)
- u16(_:)
- u256(_:)
- u32(_:)
- u64(_:)
- u8(_:)
- uleb128()
- unfreezeToken(_:_:)
- updateTokenProperty(_:_:_:)
- verify(_:)
- waitForTransaction(_:)