BlockChain SDK iOS aims to provide simple & intuitive interface for iOS apps to access various blockchains.
The code is in Swift and generated based on the OpenRPC specifications
.
import Blockchain_SDK_iOS
let configuration = Eth.Configuration(rpcConfiguration: .init(baseURL: URL(string: "https://eth-mainnet.alchemyapi.io/v2/...")!))
let eth = try Eth(configuration: configuration)
let config = Eth.Configuration(websocketConfiguration: .init(baseURL: URL(string: "wss://eth-mainnet.alchemyapi.io/v2/...")!))
let eth = try Eth(configuration: config)
let result = try await eth.eth_getBlockByHash(blockHash: "0x9e3b33ba48d2cec5314886e03bf205ec873e2a1171311d1534eaba6fbbcbe303", hydratedTransactions: true)
try eth.eth_getBlockByHash(blockHash: "0xfa4f674587a6f836de096f12b0f9612d4d2fa7f7f6c94db3acc06dbda8ff61cc",
hydratedTransactions: true)
.sink { completion in
print(completion)
} receiveValue: { value in
print(value)
}.store(in: &cancellables)
eth.connectWebSocket()
eth.webSocketStatusPublisher
.receive(on: RunLoop.main)
.sink { value in
print(value)
}.store(in: &cancellables)
try eth.eth_getBlockByHash(blockHash: "0xfa4f674587a6f836de096f12b0f9612d4d2fa7f7f6c94db3acc06dbda8ff61cc",
hydratedTransactions: true,
id: 1)
eth.webSocketResultPublisher
.sink { value in
print(value)
}.store(in: &cancellables)
eth.disconnectWebSocket()
- Xcode 12.x
- Swift 5.x
Use the url of this repo (https://github.com/ShenghaiWang/Blockchain_SDK_iOS.git).
Eth supports all the chains that are compatible with Etherum. If you want to access more chains that have different specifications, please send a pull request with the OpenRPC specification
files. We will generate the coresponding code ASAP.