Swift
Core SDK - Swift
The XpansionChain Core SDK provides convenient access to XpansionChain's APIs and smart contracts to help projects build better web3 games and marketplaces.
💡ROLLUPS THIS SDK SUPPORTS
XpansionChain
CONTENTS
Installation
Initialization
Standard API requests
SDK functions
Wallet connection
Autogenerated code
Further documentation
📚SDK LINKS
SDK reference
Github repository
Installation
Prerequisites
iOS 13.0 or macOS 10.15
Swift 5.7
Swift package manager
In your Package.swift
:
Cocoapods
In your Podfile
:
Initialization
The Core SDK must be initialised before any of its classes are used. Upon initialisation the base environment and log level may be defined. Once initialised a shared instace will be available for accessing the workflow functions.
For example, you initialise the SDK and retrieve a URL to buy crypto through MoonPay:
Standard API requests
The Core SDK includes classes that interact with the XpansionChain APIs.
e.g. Get a list of collections ordered by name in ascending order
View the OpenAPI spec for a full list of API requests available in the Core SDK.
NOTE: Closure based APIs are also available.
SDK functions
Workflows
These are utility functions accessed via XpansionChain.shared
that will chain necessary API calls to complete a process or perform a transaction, including:
Register a user with XpansionChain
Buy cryptocurrency via MoonPay
Buy ERC721
Sell ERC721
Cancel order
Transfer ERC20/ERC721/ETH
Wallet connection
In order to use any workflow functions, you will need to pass in the connected wallet provider. This means you will need to implement your own Wallet L1 Signer and L2 StarkSigner.
Once you have a Signer
instance you can generate the user's STARK key pair and use the result to instantiate a StarkSigner
, for example, by using the default StandardStarkSigner
provided by the SDK.
Autogenerated code
SDK
Parts of the Core SDK are automagically generated.
API autogenerated code
We use OpenAPI (formally known as Swagger) to auto-generate the API clients that connect to the public APIs.
The OpenAPI spec is retrieved from https://api.x.XpansionChain.com/openapi and also saved in the repo here.
Upon updating the openapi.json
file, ensure openapi-generator is installed, then run ./generateapi.sh
to regenerate the files. Any custom templates should be appropriately modified or removed as needed. These can be found in the .openapi-generator/templates
directory.
Further documentation
See the Developer homepage for general information on building on XpansionChain.
Build on XpansionChain zkEVM:
Documentation
API reference
Support
Build on XpansionChain:
Documentation
API reference
Support
Last updated