Accounts
Every account can be accessed through two types:
As a Public Account with the type
PublicAccount, which represents the publicly available portion of an account.struct PublicAccount { let address: Address // Storage operations fun getCapability<T>(_ path: Path): Capability<T>? fun getLinkTarget(_ path: Path): Path? }Any code can get the
PublicAccountfor an account address using the built-ingetAccountfunction:fun getAccount(_ address: Address): PublicAccountAs an Authorized Account with type
AuthAccount, which represents the authorized portion of an account.Access to an
AuthAccountmeans having full access to its storage, public keys, and code.Only signed transactions can get the
AuthAccountfor an account. For each script signer of the transaction, the correspondingAuthAccountis passed to thepreparephase of the transaction.struct AuthAccount { let address: Address // Contract code fun setCode(_ code: [UInt8], ... contractInitializerArguments) // Key management fun addPublicKey(_ publicKey: [UInt8]) fun removePublicKey(_ index: Int) // Storage operations fun save<T>(_ value: T, to: Path) fun load<T>(from: Path): T? fun copy<T: AnyStruct>(from: Path): T? fun borrow<T: &Any>(from: Path): T? fun link<T: &Any>(_ newCapabilityPath: Path, target: Path): Capability<T>? fun getLinkTarget(_ path: Path): Path? fun unlink(_ path: Path) fun getCapability<T: &Any>(_ path Path): Capability<T>? }
Last updated
Was this helpful?