Flow
public final class Flow
extension Flow: FlowAccessProtocol
The namespace and class for Flow
Singleton class to make the class more accessible in global scope
Please use flow
to access to its singleton entity.
-
Singleton object for
Flow
classDeclaration
Swift
public static let shared: Flow
-
The chainID for the SDK environment, it be be changed by config func. The default value is
.mainnet
.Declaration
Swift
public private(set) var chainID: Flow.ChainID { get }
-
The access API client
Declaration
Swift
public private(set) var accessAPI: FlowAccessProtocol { get }
-
Config the chainID for Flow Swift SDK Default access client will be HTTP Client
For using default node:
flow.configure(chainID: .testnet)
For custom node:
let endpoint = Flow.ChainID.Endpoint(node: "flow-testnet.g.alchemy.com", port: 443) let chainID = Flow.ChainID.custom(name: "Alchemy-Testnet", endpoint:endpoint) flow.configure(chainID: chainID)
Declaration
Swift
public func configure(chainID: ChainID)
Parameters
chainID
The chain id to be configured.
-
Config the chainID and accessNode for Flow Swift SDK
For using default node:
flow.configure(chainID: .testnet)
For custom node:
let accessAPI = Flow.GRPCAccessAPI(chainID: .mainnet)! let chainID = Flow.ChainID.mainnet flow.configure(chainID: chainID, accessAPI: accessAPI)
Declaration
Swift
public func configure(chainID: ChainID, accessAPI: FlowAccessProtocol)
Parameters
chainID
The chain id to be configured.
-
Create an access API client of
Access
by chainIDFor using default node:
let client = flow.createAccessAPI(chainID: .testnet)
For custom node:
let endpoint = Flow.ChainID.Endpoint(node: "flow-testnet.g.alchemy.com", port: 443) let chainID = Flow.ChainID.custom(name: "Alchemy-Testnet", endpoint:endpoint) let client = flow.createAccessAPI(chainID: chainID)
Declaration
Swift
public func createHTTPAccessAPI(chainID: ChainID) -> FlowAccessProtocol
Parameters
chainID
The chain id to determine which gRPC node to connect.
Return Value
An
AccessAPI
client -
The list of all the acceptable property
See moreDeclaration
Swift
enum TransactionBuild
-
Use domain-specific language (DSL) to construct
See moreFlow.Transaction
Declaration
Swift
@resultBuilder enum TransactionBuilder
-
buildTransaction(chainID:
Asynchronousbuilder: ) Build flow transaction using
TransactionBuilder
with async wayDeclaration
Swift
func buildTransaction(chainID: Flow.ChainID = flow.chainID, @Flow.TransactionBuilder builder: () -> [Flow.TransactionBuild]) async throws -> Flow.Transaction
Parameters
chainID
The chain id for the transaction, the default value is
flow.chainID
builder
The list of
Flow.TransactionBuild
Return Value
The type of
EventLoopFuture<Flow.Transaction>
-
buildTransaction(chainID:
Asynchronousscript: agrument: authorizer: payerAddress: proposerKey: limit: blockID: ) Build flow transaction using standard
Flow.Transaction
with async wayDeclaration
Swift
func buildTransaction(chainID: Flow.ChainID = flow.chainID, script: String, agrument: [Flow.Argument] = [], authorizer: [Flow.Address] = [], payerAddress: Flow.Address, proposerKey: Flow.TransactionProposalKey, limit: BigUInt = BigUInt(9999), blockID: Flow.ID?) async throws -> Flow.Transaction
Parameters
chainID
The chain id for the transaction, the default value is
flow.chainID
Return Value
The type of
EventLoopFuture<Flow.Transaction>
-
sendTransaction(chainID:
AsynchronoussignedTransaction: ) Send signed Transaction to the network
Declaration
Parameters
chainID
The chain id for the transaction, the default value is
flow.chainID
signedTransaction
The signed Flow transaction
Return Value
A future value of transaction id
-
sendTransaction(chainID:
Asynchronoussigners: builder: ) Build, sign and send transaction to the network
Declaration
Swift
func sendTransaction(chainID: Flow.ChainID = flow.chainID, signers: [FlowSigner], @Flow.TransactionBuilder builder: () -> [Flow.TransactionBuild]) async throws -> Flow.ID
Parameters
chainID
The chain id for the transaction, the default value is
flow.chainID
signers
A list of
FlowSigner
, which will sign the transactionbuilder
The list of
Flow.TransactionBuild
Return Value
The transaction id
-
sendTransaction(chainID:
Asynchronoussigners: script: agrument: authorizer: payerAddress: proposerKey: limit: blockID: ) Build, sign and send transaction to the network
Declaration
Swift
func sendTransaction(chainID: Flow.ChainID = flow.chainID, signers: [FlowSigner], script: String, agrument: [Flow.Argument] = [], authorizer: [Flow.Address] = [], payerAddress: Flow.Address, proposerKey: Flow.TransactionProposalKey, limit: BigUInt = BigUInt(9999), blockID: Flow.ID?) async throws -> Flow.ID
Parameters
chainID
The chain id for the transaction, the default value is
flow.chainID
signers
A list of
FlowSigner
, which will sign the transactionReturn Value
The transaction id
-
addKeyToAccount(address:
AsynchronousaccountKey: signers: ) Add public key to account
Declaration
Swift
func addKeyToAccount(address: Flow.Address, accountKey: Flow.AccountKey, signers: [FlowSigner]) async throws -> Flow.ID
Parameters
address
The address of Account in
Flow.Address
type.accountKey
The public key to be added in
Flow.AccountKey
type.signers
A list of
FlowSigner
will sign the transaction.Return Value
A future value will receive transaction id in
Flow.ID
value. -
Add cadence contract to account
Declaration
Swift
func addContractToAccount(address: Flow.Address, contractName: String, code: String, signers: [FlowSigner]) async throws -> Flow.ID
Parameters
address
The address of Account in
Flow.Address
type.contractName
The name of the cadence script.
code
Cadence code of the contract.
signers
A list of
FlowSigner
will sign the transaction.Return Value
A future value will receive transaction id in
Flow.ID
value. -
createAccount(address:
AsynchronousaccountKey: contracts: signers: ) Create a account in Flow blockchain
Declaration
Swift
func createAccount(address: Flow.Address, accountKey: Flow.AccountKey, contracts: [String: String] = [:], signers: [FlowSigner]) async throws -> Flow.ID
Parameters
address
The proposer address of Account in
Flow.Address
type.publicKeys
A list of publicKeys to be added in the new account.
contracts
A collection of cadence contracts, contract name is the
key
, cadence code is thevalue
.signers
A list of
FlowSigner
will sign the transaction.Return Value
A future value will receive transaction id in
Flow.ID
value. -
removeAccountKeyByIndex(address:
AsynchronouskeyIndex: signers: ) Removing a public key from an account
Declaration
Swift
func removeAccountKeyByIndex(address: Flow.Address, keyIndex: Int, signers: [FlowSigner]) async throws -> Flow.ID
Parameters
address
The proposer address of Account in
Flow.Address
type.publicKeys
A list of publicKeys to be added in the new account.
contracts
A collection of cadence contracts, contract name is the
key
, cadence code is thevalue
.signers
A list of
FlowSigner
will sign the transaction.Return Value
A future value will receive transaction id in
Flow.ID
value. -
isAddressVaildate(address:
Asynchronousnetwork: ) Undocumented
Declaration
-
isAddressVaildate(address:
Asynchronousnetwork: ) Undocumented
Declaration
Swift
func isAddressVaildate(address: String, network: Flow.ChainID = .mainnet) async -> Bool
-
Undocumented
Declaration
Swift
func removeContractFromAccount(address: Flow.Address, contractName: String, signers: [FlowSigner]) async throws -> Flow.ID
-
Undocumented
Declaration
Swift
func updateContractOfAccount(address: Flow.Address, contractName: String, script: String, signers: [FlowSigner]) async throws -> Flow.ID
-
Undocumented
See moreDeclaration
Swift
struct StorageInfo : Codable
-
checkStorageInfo(address:
Asynchronous) Undocumented
Declaration
Swift
func checkStorageInfo(address: Flow.Address) async throws -> StorageInfo
-
verifyUserSignature(message:
Asynchronoussignatures: ) Undocumented
Declaration
Swift
func verifyUserSignature(message: String, signatures: [Flow.TransactionSignature]) async throws -> Bool
-
The argument for Cadence code for encoding and decoding
See moreDeclaration
-
List of common error in Flow Swift SDK
See moreDeclaration
-
The data structure of account in Flow blockchain
See moreDeclaration
Swift
struct Account : Codable
-
The data structure of account key in flow account
See moreDeclaration
Swift
struct AccountKey : Codable
-
The data structure of address in Flow blockchain At the most time, it represents account address
See moreDeclaration
Swift
struct Address : FlowEntity, Equatable, Hashable
extension Flow.Address: Codable
extension Flow.Address: CustomStringConvertible
-
The signature algorithm supported by flow which include
See more.ECDSA_P256
and.ECDSA_SECP256k1
Declaration
Swift
enum SignatureAlgorithm : String, CaseIterable, Codable
-
The hash algorithm supported by flow which include
See more.SHA2_256
,.SHA2_384
,.SHA3_256
and.SHA3_384
Declaration
Swift
enum HashAlgorithm : String, CaseIterable, Codable
-
Brief information of
See moreFlow.Block
Declaration
Swift
struct BlockHeader : Codable
-
The data structure of
See moreFlow.Block
which issealed
Declaration
Swift
struct BlockSeal : Codable
-
The data structure for the block in Flow blockchain
See moreDeclaration
Swift
struct Block : Codable
-
Undocumented
Declaration
Swift
static let decimal: Int
-
Undocumented
See moreDeclaration
Swift
class Cadence
-
Identification the enviroment of flow
See moreDeclaration
Swift
enum ChainID : CaseIterable, Hashable, Codable
-
A batch of transactions that have been included in the same block
See moreDeclaration
Swift
struct Collection : Codable
-
Declaration
Swift
struct CollectionGuarantee : Codable
-
The prefix when encoding transaction and user with RLP
See moreDeclaration
Swift
enum DomainTag
-
Declaration
Swift
struct Event : Codable
-
Undocumented
See moreDeclaration
Swift
struct Snapshot : FlowEntity, Equatable, Codable
extension Flow.Snapshot: CustomStringConvertible
-
The ID in Flow chain, which can represent as transaction id, block id and collection id etc.
See moreDeclaration
Swift
struct ID : FlowEntity, Equatable, Hashable
extension Flow.ID: Codable
extension Flow.ID: CustomStringConvertible
-
Declaration
Swift
struct Script : FlowEntity, Equatable
extension Flow.Script: CustomStringConvertible
extension Flow.Script: Codable
-
Declaration
Swift
struct ScriptResponse : FlowEntity, Equatable, Codable
extension Flow.ScriptResponse: CustomStringConvertible
-
The model to handle the signature data, which can present as a hex string
See moreDeclaration
Swift
struct Signature : FlowEntity, Equatable, Codable
extension Flow.Signature: CustomStringConvertible
-
The data structure of Transaction
See moreDeclaration
-
signTransaction(unsignedTransaction:
Asynchronoussigners: ) Sign the unsigned transaction with a list of
FlowSigner
Declaration
Swift
func signTransaction(unsignedTransaction: Flow.Transaction, signers: [FlowSigner]) async throws -> Flow.Transaction
Parameters
unsignedTransaction
The transaction to be signed
signers
A list of
FlowSigner
to sign the transactionReturn Value
The signed transaction
-
The transaction result in the chain
See moreDeclaration
Swift
struct TransactionResult : Codable
-
The class to represent the proposer key information in the transaction
See moreDeclaration
-
Undocumented
See moreDeclaration
-
Undocumented
See moreDeclaration
Swift
struct PublicKey : FlowEntity, Equatable, Codable
extension Flow.PublicKey: CustomStringConvertible
-
Undocumented
See moreDeclaration
-
ping()
AsynchronousUndocumented
Declaration
Swift
public func ping() async throws -> Bool
-
getLatestBlockHeader()
AsynchronousUndocumented
Declaration
Swift
public func getLatestBlockHeader() async throws -> BlockHeader
-
getBlockHeaderById(id:
Asynchronous) Undocumented
Declaration
Swift
public func getBlockHeaderById(id: ID) async throws -> BlockHeader
-
getBlockHeaderByHeight(height:
Asynchronous) Undocumented
Declaration
Swift
public func getBlockHeaderByHeight(height: UInt64) async throws -> BlockHeader
-
getLatestBlock(sealed:
Asynchronous) Undocumented
Declaration
Swift
public func getLatestBlock(sealed: Bool) async throws -> Block
-
getBlockById(id:
Asynchronous) Undocumented
-
getBlockByHeight(height:
Asynchronous) Undocumented
Declaration
Swift
public func getBlockByHeight(height: UInt64) async throws -> Block
-
getCollectionById(id:
Asynchronous) Undocumented
Declaration
Swift
public func getCollectionById(id: ID) async throws -> Collection
-
sendTransaction(transaction:
Asynchronous) Undocumented
Declaration
Swift
public func sendTransaction(transaction: Transaction) async throws -> ID
-
getTransactionById(id:
Asynchronous) Undocumented
Declaration
Swift
public func getTransactionById(id: ID) async throws -> Transaction
-
getTransactionResultById(id:
Asynchronous) Undocumented
Declaration
Swift
public func getTransactionResultById(id: ID) async throws -> TransactionResult
-
getAccountAtLatestBlock(address:
Asynchronous) Undocumented
-
getAccountByBlockHeight(address:
Asynchronousheight: ) Undocumented
Declaration
-
getEventsForHeightRange(type:
Asynchronousrange: ) Undocumented
Declaration
Swift
public func getEventsForHeightRange(type: String, range: ClosedRange<UInt64>) async throws -> [Event.Result]
-
getEventsForBlockIds(type:
Asynchronousids: ) Undocumented
Declaration
-
executeScriptAtLatestBlock(script:
Asynchronousarguments: ) Undocumented
Declaration
Swift
public func executeScriptAtLatestBlock(script: Script, arguments: [Argument]) async throws -> ScriptResponse
-
getNetworkParameters()
AsynchronousUndocumented
Declaration
Swift
public func getNetworkParameters() async throws -> ChainID
-
Undocumented
See moreDeclaration
Swift
enum Transport : Equatable, Hashable