Implementation of ERC-4337: Account Abstraction in Swift
For a high-level overview, read this blog post.
For Kotlin library, see this.
In Package.swift:
dependencies: [
.package(url: "https://github.com/syn-mcj/aa-swift.git", .upToNextMajor(from: "0.1.3"))
]
In Xcode:
- Navigate to Project -> Package Dependencies -> Add.
- Enter
https://github.com/syn-mcj/aa-kotlin.git
in the Search bar. - Add package.
Send User Operation with Alchemy provider:
let provider = try AlchemyProvider(
...
).withAlchemyGasManager(
config: ...
)
let account = try LightSmartContractAccount(...)
provider.connect(account: account)
let encodedFn = ABIFunctionEncoder("mint") // contract function name
try await encodedFn.encode(provider.getAddress()) // function parameters
try await provider.sendUserOperation(
data: UserOperationCallData(
target: contractAddress,
data: encodedFn.encoded()
)
)
Check the Example app for the full code:
This repository is based on Alchemy's aa-sdk. Going through their Account Kit documentation will give you a good idea of the structure of this library.
Contributions are welcome. Just open a well-structured issue or a PR.