Swiftpack.co - Package - CosmosSwift/swift-abci


Swift5.3+ platforms

Build blockchain applications in Swift on top of the Tendermint consensus. swift-abci uses SwiftNIO as its server core.

  • Swift version: 5.3.x
  • SwiftNIO version: 2.0.x
  • ABCI version: 0.33.8 (tendermint 0.33.8-1a8e42d)


Requires macOS or a variant of Linux with the Swift 5.3.x toolchain installed.

In your Package.swift file, add the repository as a dependency as such:

import PackageDescription

let package = Package(
    name: "swift-abci-app",
    products: [
        .executable(name: "swift-abci-app", targets: ["swift-abci-app"]),
    dependencies: [
        .package(url: "https://github.com/cosmosswift/swift-abci.git", .upToNextMajor(from: "1.0.0")),
    targets: [
            name: "swift-abci-app", 
            dependencies: [
                .product(name: "ABCI", package: "ABCI"), 
                .product(name: "ABCINIO", package: "ABCI"),

Getting Started

  1. Import ABCI and ABCINIO
import ABCI
import ABCINIO
  1. Define a class complying to the ABCIApplication protocol:
final class Application : ABCIApplication {
    func info(request: RequestInfo) -> ResponseInfo {
    func initChain(request: RequestInitChain) -> ResponseInitChain {
    func query(request: RequestQuery) -> ResponseQuery {
    func beginBlock(request: RequestBeginBlock) -> ResponseBeginBlock {
    func checkTx(request: RequestCheckTx) -> ResponseCheckTx {
    func deliverTx(request: RequestDeliverTx) -> ResponseDeliverTx {
    func endBlock(request: RequestEndBlock) -> ResponseEndBlock {

    func commit() -> ResponseCommit {
  1. Implement the relevant Tendermint ABCI callbacks

See the example app ABCICounter. Check the abci spec for more details.

  1. Inititialize NIOABCIServer, with the application:
let server = NIOABCIServer(application: Application())
  1. Start the server
try server.start()
  1. Compile and run
swift run swift-abci-app
  1. Run Tendermint

Initialise and run Tendermint (for instance in Docker):

# initialise tendermint
docker run -it --rm -v "/tmp:/tendermint" tendermint/tendermint:v0.33.8 init

# update the default config to allow tendermint to listen on 26657 from the localhost
sed 's/' /tmp/config/config.toml > /tmp/delme
rm /tmp/config/config.toml
mv /tmp/delme /tmp/config/config.toml

# run a single tendermint node
docker run -it --rm -v "/tmp:/tendermint" -p "26656-26657:26656-26657"  tendermint/tendermint:v0.33.8 node --proxy_app="tcp://host.docker.internal:26658"


Pre requisites: protoc with the swift generation plugin is installed on your system (https://github.com/apple/swift-protobuf).

For protoc swift plugin information: https://github.com/apple/swift-protobuf/blob/master/Documentation/PLUGIN.md

Update the types.pb.swift file:

  1. update the proto file (and possibly its import dependencies) from https://github.com/tendermint/tendermint/abci and put it in ./protobuf/...

  2. From the project root: protoc --swift_opt=FileNaming=PathToUnderscores --swift_out=./Sources/ABCI/ -I=./protobuf/ $(find protobuf/tendermint/ -iname "*.proto")


  1. run swift build


The docs for the latest tagged release are always available at the wiki.


For bugs or feature requests, file a new issue.

For all other support requests, please email opensource@katalysis.io.


SemVer changes are documented for each release on the releases page.


Check out CONTRIBUTING.md for more information on how to help with swift-abci.


Check out CONTRIBUTORS.txt to see the full list. This list is updated for each release.


Stars: 5

Used By

Total: 0


0.33.8 - Ventura - 2020-10-20 17:54:28