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
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: 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
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)
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
public enum TransactionBuild
-
Use domain-specific language (DSL) to construct
See moreFlow.Transaction
Declaration
Swift
@resultBuilder public class TransactionBuilder
-
Build flow transaction using
TransactionBuilder
with async wayDeclaration
Swift
public func asyncBuildTransaction(chainID: Flow.ChainID = flow.chainID, @Flow .TransactionBuilder builder: () -> [Flow.TransactionBuild]) throws -> EventLoopFuture<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>
-
Build flow transaction using
TransactionBuilder
Declaration
Swift
public func buildTransaction(chainID: Flow.ChainID = flow.chainID, @Flow .TransactionBuilder builder: () -> [Flow.TransactionBuild]) 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
Flow.Transaction
-
Send signed Transaction to the network
Declaration
Swift
public func sendTransaction(chainID: ChainID = flow.chainID, signedTransaction: Transaction) throws -> EventLoopFuture<Flow.ID>
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
-
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.ID
Parameters
chainID
The chain id for the transaction, the default value is
flow.chainID
signedTransaction
The 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
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
-
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) throws
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
completion
The 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
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
public func addContractToAccount(address: Flow.Address, contractName: String, code: String, signers: [FlowSigner]) throws -> EventLoopFuture<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. -
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
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. -
Removing a public key from an account
Declaration
Swift
public func removeAccountKeyByIndex(address: Flow.Address, keyIndex: Int, signers: [FlowSigner]) throws -> EventLoopFuture<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. -
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, Codable
extension Flow.Address: CustomStringConvertible
-
The signature algorithm supported by flow which include
See more.ECDSA_P256
and.ECDSA_SECP256k1
Declaration
Swift
public 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
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.Block
Declaration
Swift
public struct BlockHeader
-
The data structure of
See moreFlow.Block
which issealed
Declaration
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, Equatable
extension 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, Equatable
extension Flow.ScriptResponse: CustomStringConvertible
-
The model to handle the signature data, which can present as a hex string
See moreDeclaration
Swift
public struct Signature : FlowEntity, Equatable
extension Flow.Signature: CustomStringConvertible
-
Sign the unsigned transaction with a list of
FlowSigner
Declaration
Swift
public func signTransaction(unsignedTransaction: Flow.Transaction, signers: [FlowSigner]) throws -> Flow.Transaction
Parameters
unsignedTransaction
The transaction to be signed
signers
A list of
FlowSigner
to 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 : FlowAccessProtocol
extension Flow.AccessAPI: FlowAccessBlockProtocol