-
Notifications
You must be signed in to change notification settings - Fork 1
AccountAddress
The Aptos Blockchain Account Address
public struct AccountAddress: KeyProtocol, Equatable, CustomStringConvertible, Hashable
CustomStringConvertible
, Equatable
, Hashable
, KeyProtocol
public init(address: Data) throws
The address data itself
public let address: Data
public var description: String
Gives the hex value of the address
public func hex() -> String
A String value represnting the address's hex value
Create an AccountAddress instance from a hexadecimal string.
public static func fromHex(_ address: String) throws -> AccountAddress
This function creates an AccountAddress instance from a hexadecimal string representing the account address. If the provided hexadecimal string starts with "0x", the function removes it before attempting to create the AccountAddress instance. If the length of the hexadecimal string is less than AccountAddress.length times 2, the function pads it with leading zeros to reach the required length.
- address: A string representing the hexadecimal account address to create the AccountAddress instance from.
An error of type AptosError indicating that the provided hexadecimal string is invalid and cannot be converted to an AccountAddress instance.
An AccountAddress instance created from the provided hexadecimal string.
Create an AccountAddress instance from a PublicKey.
public static func fromKey(_ key: PublicKey) throws -> AccountAddress
This function creates an AccountAddress instance from a provided PublicKey. The function generates a new address by appending the ED25519 authorization key scheme value to the byte representation of the provided public key, and then computes the SHA3-256 hash of the resulting byte array. The resulting hash is used to create a new AccountAddress instance.
- key: A PublicKey instance representing the public key to create the AccountAddress instance from.
An error of type AptosError indicating that the provided PublicKey is invalid and cannot be converted to an AccountAddress instance.
An AccountAddress instance created from the provided PublicKey.
Create an AccountAddress instance from a MultiPublicKey.
public static func fromMultiEd25519(keys: MultiPublicKey) throws -> AccountAddress
This function creates an AccountAddress instance from a provided MultiPublicKey. The function generates a new address by appending the Multi ED25519 authorization key scheme value to the byte representation of the provided MultiPublicKey, and then computes the SHA3-256 hash of the resulting byte array. The resulting hash is used to create a new AccountAddress instance.
- keys: A MultiPublicKey instance representing the multiple public keys to create the AccountAddress instance from.
An error of type AptosError indicating that the provided MultiPublicKey is invalid and cannot be converted to an AccountAddress instance.
An AccountAddress instance created from the provided MultiPublicKey.
Create an AccountAddress instance for a resource account.
public static func forResourceAccount(_ creator: AccountAddress, seed: Data) throws -> AccountAddress
This function creates an AccountAddress instance for a resource account given the creator's address and a seed value. The function generates a new address by concatenating the byte representation of the creator's address, the provided seed value, and the DERIVE_RESOURCE_ACCOUNT_ADDRESS authorization key scheme value. It then computes the SHA3-256 hash of the resulting byte array to generate a new AccountAddress instance.
- creator: An AccountAddress instance representing the address of the account that will create the resource account.
- seed: A Data value used to create a unique resource account.
An error of type AptosError indicating that the provided creator address or seed is invalid and cannot be used to create a resource account.
An AccountAddress instance representing the newly created resource account.
Generates an AccountAddress
for a GUID object.
public static func forGuidObject(_ creator: AccountAddress, _ creationNum: Int) throws -> AccountAddress
This function takes in a creator address and a creationNum
which it uses to serialize into an array of bytes.
It then appends the creator address and deriveObjectAddressFromGuid
to this array. It uses this byte array
to compute a SHA-256 hash. This hash is then returned as a new AccountAddress
.
Note: This function uses the SHA-256 algorithm for hashing which is a part of the SHA-2 (Secure Hash Algorithm 2) set of cryptographic hash functions. Hash functions are fundamental to modern cryptography. These functions map binary strings of an arbitrary length to small binary strings of a fixed length.
- creator: The account address of the creator.
- creationNum: The creation number of the object.
This function throws an error if the process of creating the AccountAddress
fails.
An AccountAddress
which is generated for a GUID object.
Create an AccountAddress instance for a named object.
public static func forNamedObject(_ creator: AccountAddress, seed: Data) throws -> AccountAddress
This function creates an AccountAddress instance for a named object given the creator's address and a seed value. The function generates a new address by concatenating the byte representation of the creator's address, the provided seed value, and the DERIVE_OBJECT_ADDRESS_FROM_SEED authorization key scheme value. It then computes the SHA3-256 hash of the resulting byte array to generate a new AccountAddress instance.
- creator: An AccountAddress instance representing the address of the account that will create the named object.
- seed: A Data value used to create a unique named object.
An error of type AptosError indicating that the provided creator address or seed is invalid and cannot be used to create a named object.
An AccountAddress instance representing the newly created named object.
Generates an AccountAddress for a named token by concatenating the collectionName, the tokenName, and the separator "::" as a Data and calling the forNamedObject function with the resulting Data as the seed.
public static func forNamedToken(_ creator: AccountAddress, _ collectionName: String, _ tokenName: String) throws -> AccountAddress
- creator: The AccountAddress of the account that creates the token.
- collectionName: A String that represents the name of the collection to which the token belongs.
- tokenName: A String that represents the name of the token.
An error of type AptosError.stringToDataFailure if collectionName, tokenName, or "::" can't be converted into Data.
An AccountAddress object that represents the named token.
Derive an AccountAddress for a named collection.
public static func forNamedCollection(_ creator: AccountAddress, _ collectionName: String) throws -> AccountAddress
This function takes the creator's AccountAddress and the name of the collection as a String. The collection name is then converted to data using UTF-8 encoding. The forNamedObject function is called with the creator's address and the collection name data as the seed. This returns an AccountAddress derived from the creator's address and collection name seed, which represents the named collection.
- creator: The creator's AccountAddress.
- collectionName: The name of the collection as a String.
An AptosError object of type stringToDataFailure if the conversion of the collection name string to data using UTF-8 encoding fails.
An AccountAddress that represents the named collection.
public static func deserialize(from deserializer: Deserializer) throws -> AccountAddress
public func serialize(_ serializer: Serializer) throws
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(_:)