Starknet SDK for Swift to interact with the starknet rpc nodes.
In XCode, go to your project, then select Package Dependencies tab. Click the + button, and in the window that just appeared search for starknet.swift package or paste the following url directly: https://github.com/software-mansion/starknet.swift. Select package and install it.
Just add the package to the dependencies array in your Package.swift file:
dependencies: [
...
.package(url: "https://github.com/software-mansion/starknet.swift.git", from: "0.7.0")
]
Then add `starknet.swift` to the dependencies array of every target you want to use the package in.The package offers two library products:
Starknet– statically linked variant. Prefer this when you control the final app binary and want to avoid extra runtime bundles.StarknetDynamic– dynamically linked variant. Use this for SwiftUI previews or any build pipeline that performs aggressive dead-symbol stripping.
If you rely on SwiftUI previews or hit missing native symbol errors (_generate_k, _Sign, etc.), switch the dependency in your target to StarknetDynamic.
You can find the documentation of the project here.
In the Examples folder you can find a demo ios application.
Before running it, make sure to run compatible version of starknet-devnet with a given configuration:
starknet-devnet --port 5050 --seed 0`
To install starknet devnet, please run:
cargo install \
--locked \
--git https://github.com/0xSpaceShard/starknet-devnet-rs.git \
--rev fc5a275
Run the demo app on ios simulator, to be able to access the local devnet instance.
Install hooks by running install_hooks.sh script from Scripts folder.
This project uses SwiftFormat for linting and formatting code. You can install it by running brew install swiftformat. Unformatted code will be rejected by pre push hook and lint github action. To format code in the project, run
swiftformat .in main project directory.
Due to reliability on starknet-devnet-rs for testing, tests can be ran on macOS targets only.
You will need to set some environment variables:
DEVNET_PATH- points tostarknet-devnet-rscliSCARB_PATH- points toscarbcli.SNCAST_PATH- points tosncastcli.
You can set them in XCode scheme or by running these commands:
export DEVNET_PATH="$(which starknet-devnet)"
export SCARB_PATH="$(which scarb)"
export SNCAST_PATH="$(which sncast)"This assumes you already have the following tools installed:
starknet-devnet-rsscarbstarknet-foundry- providessncastcli
This project depends on two binary frameworks.
- crypto-cpp from starkware, with c bindings. Compiled for ios and macosx targets. Built in this repo
- poseidon from CryptoExperts. Compiled for ios and macosx targets. Built in this repo
- generate_k method, from starknet-rs sdk, wrapped in a c binding. Compiled for ios and macosx targets. Built in this repo
This product includes software developed by the "Marcin Krzyzanowski" (http://krzyzanowskim.com/).
