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
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: 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
chainIDThe 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
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)Declaration
Swift
public func createHTTPAccessAPI(chainID: ChainID) -> FlowAccessProtocolParameters
chainIDThe chain id to determine which gRPC node to connect.
Return Value
An
AccessAPIclient -
Components that can be used to build a Flow transaction
See moreDeclaration
Swift
enum TransactionBuild -
Use domain-specific language (DSL) to construct
See moreFlow.TransactionDeclaration
Swift
@resultBuilder enum TransactionBuilder -
buildTransaction(chainID:Asynchronousbuilder: ) Build flow transaction using
TransactionBuilderwith async wayDeclaration
Swift
func buildTransaction(chainID: Flow.ChainID = flow.chainID, @Flow.TransactionBuilder builder: () -> [Flow.TransactionBuild]) async throws -> Flow.TransactionParameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDbuilderThe list of
Flow.TransactionBuildReturn Value
The type of
EventLoopFuture<Flow.Transaction> -
buildTransaction(chainID:Asynchronousscript: agrument: authorizer: payerAddress: proposerKey: limit: blockID: ) Build flow transaction using standard
Flow.Transactionwith 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.TransactionParameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDReturn Value
The type of
EventLoopFuture<Flow.Transaction> -
sendTransaction(chainID:AsynchronoussignedTransaction: ) Send signed Transaction to the network
Declaration
Parameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDsignedTransactionThe 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.IDParameters
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
-
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.IDParameters
chainIDThe chain id for the transaction, the default value is
flow.chainIDsignersA 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.IDParameters
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
func addContractToAccount(address: Flow.Address, contractName: String, code: String, signers: [FlowSigner]) async throws -> Flow.IDParameters
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. -
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.IDParameters
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. -
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.IDParameters
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. -
isAddressVaildate(address:Asynchronousnetwork: ) Declaration
-
isAddressVaildate(address:Asynchronousnetwork: ) Declaration
Swift
func isAddressVaildate(address: String, network: Flow.ChainID = .mainnet) async -> Bool -
Declaration
Swift
func removeContractFromAccount(address: Flow.Address, contractName: String, signers: [FlowSigner]) async throws -> Flow.ID -
Declaration
Swift
func updateContractOfAccount(address: Flow.Address, contractName: String, script: String, signers: [FlowSigner]) async throws -> Flow.ID -
Declaration
Swift
struct StorageInfo : Codable -
checkStorageInfo(address:Asynchronous) Declaration
Swift
func checkStorageInfo(address: Flow.Address) async throws -> StorageInfo -
verifyUserSignature(message:Asynchronoussignatures: ) 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, Hashableextension Flow.Address: Codableextension Flow.Address: CustomStringConvertible -
The signature algorithm supported by flow which include
See more.ECDSA_P256and.ECDSA_SECP256k1Declaration
Swift
enum SignatureAlgorithm : String, CaseIterable, Codable -
The hash algorithm supported by flow which include
See more.SHA2_256,.SHA2_384,.SHA3_256and.SHA3_384Declaration
Swift
enum HashAlgorithm : String, CaseIterable, Codable -
Brief information of
See moreFlow.BlockDeclaration
Swift
struct BlockHeader : Codable -
The data structure of
See moreFlow.Blockwhich issealedDeclaration
Swift
struct BlockSeal : Codable -
The data structure for the block in Flow blockchain
See moreDeclaration
Swift
struct Block : Codable -
Declaration
Swift
static let decimal: Int -
Declaration
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 -
Flow blockchain event
See moreDeclaration
Swift
struct Event : Codable -
Declaration
Swift
struct Snapshot : FlowEntity, Equatable, Codableextension 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, Hashableextension Flow.ID: Codableextension Flow.ID: CustomStringConvertible -
Represents a Cadence script
See moreDeclaration
Swift
struct Script : FlowEntity, Equatableextension Flow.Script: CustomStringConvertibleextension Flow.Script: Codable -
Declaration
Swift
struct ScriptResponse : FlowEntity, Equatable, Codableextension Flow.ScriptResponse: CustomStringConvertible -
The model to handle the signature data, which can present as a hex string
See moreDeclaration
Swift
struct Signature : FlowEntity, Equatable, Codableextension Flow.Signature: CustomStringConvertible -
The data structure of Transaction
See moreDeclaration
-
signTransaction(unsignedTransaction:Asynchronoussigners: ) Sign the unsigned transaction with a list of
FlowSignerDeclaration
Swift
func signTransaction(unsignedTransaction: Flow.Transaction, signers: [FlowSigner]) async throws -> Flow.TransactionParameters
unsignedTransactionThe transaction to be signed
signersA list of
FlowSignerto 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
-
Declaration
-
Declaration
Swift
struct PublicKey : FlowEntity, Equatable, Codableextension Flow.PublicKey: CustomStringConvertible -
Declaration
-
ping()AsynchronousDeclaration
Swift
public func ping() async throws -> Bool -
getLatestBlockHeader()AsynchronousDeclaration
Swift
public func getLatestBlockHeader() async throws -> BlockHeader -
getBlockHeaderById(id:Asynchronous) Declaration
Swift
public func getBlockHeaderById(id: ID) async throws -> BlockHeader -
getBlockHeaderByHeight(height:Asynchronous) Declaration
Swift
public func getBlockHeaderByHeight(height: UInt64) async throws -> BlockHeader -
getLatestBlock(sealed:Asynchronous) Declaration
Swift
public func getLatestBlock(sealed: Bool) async throws -> Block -
getBlockById(id:Asynchronous) -
getBlockByHeight(height:Asynchronous) Declaration
Swift
public func getBlockByHeight(height: UInt64) async throws -> Block -
getCollectionById(id:Asynchronous) Declaration
Swift
public func getCollectionById(id: ID) async throws -> Collection -
sendTransaction(transaction:Asynchronous) Declaration
Swift
public func sendTransaction(transaction: Transaction) async throws -> ID -
getTransactionById(id:Asynchronous) Declaration
Swift
public func getTransactionById(id: ID) async throws -> Transaction -
getTransactionResultById(id:Asynchronous) Declaration
Swift
public func getTransactionResultById(id: ID) async throws -> TransactionResult -
getAccountAtLatestBlock(address:Asynchronous) -
getAccountByBlockHeight(address:Asynchronousheight: ) Declaration
-
getEventsForHeightRange(type:Asynchronousrange: ) Declaration
Swift
public func getEventsForHeightRange(type: String, range: ClosedRange<UInt64>) async throws -> [Event.Result] -
getEventsForBlockIds(type:Asynchronousids: ) Declaration
-
executeScriptAtLatestBlock(script:Asynchronousarguments: ) Declaration
Swift
public func executeScriptAtLatestBlock(script: Script, arguments: [Argument]) async throws -> ScriptResponse -
getNetworkParameters()AsynchronousDeclaration
Swift
public func getNetworkParameters() async throws -> ChainID -
Declaration
Swift
enum Transport : Equatable, Hashable
View on GitHub