Flow
public final class Flow
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
FlowclassDeclaration
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: AccessAPI { get }
-
Config the chainID for Flow Swift SDK
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
chainIDThe chain id to be configured.
-
Create an access API client of
Accessby 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)Parameters
chainIDThe chain id to determine which gRPC node to connect.
Return Value
An
AccessAPIclient -
The list of all the acceptable property
See moreDeclaration
Swift
public enum TransactionBuild -
Use domain-specific language (DSL) to construct
See moreFlow.TransactionDeclaration
Swift
@resultBuilder public class TransactionBuilder -
Build flow transaction using
TransactionBuilderwith async wayDeclaration
Swift
public func asyncBuildTransaction(chainID: Flow.ChainID = flow.chainID, @Flow .TransactionBuilder builder: () -> [Flow.TransactionBuild]) throws -> EventLoopFuture<Flow.Transaction>Parameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDbuilderThe list of
Flow.TransactionBuildReturn Value
The type of
EventLoopFuture<Flow.Transaction> -
Build flow transaction using
TransactionBuilderDeclaration
Swift
public func buildTransaction(chainID: Flow.ChainID = flow.chainID, @Flow .TransactionBuilder builder: () -> [Flow.TransactionBuild]) throws -> Flow.TransactionParameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDbuilderThe list of
Flow.TransactionBuildReturn Value
The type of
Flow.Transaction -
Send signed Transaction to the network
Declaration
Swift
public func sendTransaction(chainID: ChainID = flow.chainID, signedTransaction: Transaction) throws -> EventLoopFuture<Flow.ID>Parameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDsignedTransactionThe signed Flow transaction
Return Value
A future value of transaction id
-
Send signed Transaction to the network in sync way
Declaration
Swift
public func sendTransactionWithWait(chainID: Flow.ChainID = flow.chainID, signers: [FlowSigner], @Flow .TransactionBuilder builder: () -> [Flow.TransactionBuild]) throws -> Flow.IDParameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDsignedTransactionThe signed Flow transaction
Return Value
The transaction id
-
Build, sign and send transaction to the network
Declaration
Swift
public func sendTransaction(chainID: Flow.ChainID = flow.chainID, signers: [FlowSigner], @Flow .TransactionBuilder builder: () -> [Flow.TransactionBuild]) throws -> EventLoopFuture<Flow.ID>Parameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDsignersA list of
FlowSigner, which will sign the transactionbuilderThe list of
Flow.TransactionBuildReturn Value
The transaction id
-
Build, sign and send transaction to the network with block
Declaration
Swift
public func sendTransaction(chainID: Flow.ChainID = flow.chainID, signers: [FlowSigner], @Flow .TransactionBuilder builder: () -> [Flow.TransactionBuild], completion: @escaping (Result<Flow.ID, Error>) -> Void) throwsParameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDsignersA list of
FlowSigner, which will sign the transactionbuilderThe list of
Flow.TransactionBuildcompletionThe block to handle the response
-
Add public key to account
Declaration
Swift
public func addKeyToAccount(address: Flow.Address, accountKey: Flow.AccountKey, signers: [FlowSigner]) throws -> EventLoopFuture<Flow.ID>Parameters
addressThe address of Account in
Flow.Addresstype.accountKeyThe public key to be added in
Flow.AccountKeytype.signersA list of
FlowSignerwill sign the transaction.Return Value
A future value will receive transaction id in
Flow.IDvalue. -
Add cadence contract to account
Declaration
Swift
public func addContractToAccount(address: Flow.Address, contractName: String, code: String, signers: [FlowSigner]) throws -> EventLoopFuture<Flow.ID>Parameters
addressThe address of Account in
Flow.Addresstype.contractNameThe name of the cadence script.
codeCadence code of the contract.
signersA list of
FlowSignerwill sign the transaction.Return Value
A future value will receive transaction id in
Flow.IDvalue. -
Create a account in Flow blockchain
Declaration
Swift
public func createAccount(address: Flow.Address, publicKeys: [Flow.AccountKey], contracts: [String: String] = [:], signers: [FlowSigner]) throws -> EventLoopFuture<Flow.ID>Parameters
addressThe proposer address of Account in
Flow.Addresstype.publicKeysA list of publicKeys to be added in the new account.
contractsA collection of cadence contracts, contract name is the
key, cadence code is thevalue.signersA list of
FlowSignerwill sign the transaction.Return Value
A future value will receive transaction id in
Flow.IDvalue. -
Removing a public key from an account
Declaration
Swift
public func removeAccountKeyByIndex(address: Flow.Address, keyIndex: Int, signers: [FlowSigner]) throws -> EventLoopFuture<Flow.ID>Parameters
addressThe proposer address of Account in
Flow.Addresstype.publicKeysA list of publicKeys to be added in the new account.
contractsA collection of cadence contracts, contract name is the
key, cadence code is thevalue.signersA list of
FlowSignerwill sign the transaction.Return Value
A future value will receive transaction id in
Flow.IDvalue. -
Undocumented
Declaration
Swift
public func removeContractFromAccount(address: Flow.Address, contractName: String, signers: [FlowSigner]) throws -> EventLoopFuture<Flow.ID> -
Undocumented
Declaration
Swift
public func updateContractOfAccount(address: Flow.Address, contractName: String, script: String, signers: [FlowSigner]) throws -> EventLoopFuture<Flow.ID> -
Undocumented
Declaration
Swift
public func verifyUserSignature(message: String, signatures: [Flow.TransactionSignature]) throws -> EventLoopFuture<Flow.ScriptResponse> -
List of common error in Flow Swift SDK
See moreDeclaration
-
The data structure of account in Flow blockchain
See moreDeclaration
Swift
public struct Account -
The data structure of account key in flow account
See moreDeclaration
Swift
public struct AccountKey -
The data structure of address in Flow blockchain At the most time, it represents account address
See moreDeclaration
Swift
public struct Address : FlowEntity, Equatable, Hashable, Codableextension Flow.Address: CustomStringConvertible -
The signature algorithm supported by flow which include
See more.ECDSA_P256and.ECDSA_SECP256k1Declaration
Swift
public enum SignatureAlgorithm : String, CaseIterable, Codable -
The hash algorithm supported by flow which include
See more.SHA2_256,.SHA2_384,.SHA3_256and.SHA3_384Declaration
Swift
public enum HashAlgorithm : String, CaseIterable, Codable -
The argument for Cadence code for encoding and decoding
See moreDeclaration
Swift
public struct Argument : Codable, Equatable -
Brief information of
See moreFlow.BlockDeclaration
Swift
public struct BlockHeader -
The data structure of
See moreFlow.Blockwhich issealedDeclaration
Swift
public struct BlockSeal -
The data structure for the block in Flow blockchain
See moreDeclaration
Swift
public struct Block -
Undocumented
See moreDeclaration
Swift
public class Cadence -
Identification the enviroment of flow
See moreDeclaration
Swift
public enum ChainID : CaseIterable, Hashable -
A batch of transactions that have been included in the same block
See moreDeclaration
Swift
public struct Collection -
Declaration
Swift
public struct CollectionGuarantee -
The prefix when encoding transaction and user with RLP
See moreDeclaration
Swift
public enum DomainTag : String -
Declaration
Swift
public struct Event -
Undocumented
See moreDeclaration
Swift
public struct Snapshot : FlowEntity, Equatableextension Flow.Snapshot: CustomStringConvertible -
The ID in Flow chain, which can represent as transaction id, block id and collection id etc.
See moreDeclaration
-
Declaration
-
Declaration
Swift
public struct ScriptResponse : FlowEntity, Equatableextension Flow.ScriptResponse: CustomStringConvertible -
The model to handle the signature data, which can present as a hex string
See moreDeclaration
Swift
public struct Signature : FlowEntity, Equatableextension Flow.Signature: CustomStringConvertible -
Sign the unsigned transaction with a list of
FlowSignerDeclaration
Swift
public func signTransaction(unsignedTransaction: Flow.Transaction, signers: [FlowSigner]) throws -> Flow.TransactionParameters
unsignedTransactionThe transaction to be signed
signersA list of
FlowSignerto sign the transactionReturn Value
The signed transaction
-
The data structure of Transaction
See moreDeclaration
Swift
public struct Transaction -
The transaction result in the chain
See moreDeclaration
Swift
public struct TransactionResult -
The class to represent the proposer key information in the transaction
See moreDeclaration
Swift
public struct TransactionProposalKey -
Undocumented
See moreDeclaration
Swift
public struct TransactionSignature : Comparable -
Undocumented
See moreDeclaration
Swift
public struct PublicKey : FlowEntity, Equatable -
Undocumented
See moreDeclaration
Swift
public struct Code : FlowEntity, Equatable -
The network client for access API More detail can be found here: https://docs.onflow.org/access-api
See moreDeclaration
Swift
public final class AccessAPI : FlowAccessProtocolextension Flow.AccessAPI: FlowAccessBlockProtocol
View on GitHub
Flow Class Reference