Deployment
Smart contract
When you are ready for testnet/mainnet, we recommend to deploy your contract using stellar registry. Some commands to get you started.
# Note --source-account argument is omitted for clarity
# First publish your contract to the registry
stellar registry publish
# Then deploy an instance with constructor parameters
stellar registry deploy \
--deployed-name my-contract \
--published-name my-contract \
-- \
--param1 value1
# Can access the help docs with --help
stellar registry deploy \
--deployed-name my-contract \
--published-name my-contract \
-- \
--help
# Install the deployed contract locally
stellar registry create-alias my-contract
Additionally, you might want to have a look into registering your contract with Stellar.Expert.
We provide a template GitHub action which you have to adjust based on your needs. This action compiles your contract(s), create some signed attestations and registers the specific Wasm to Stellar.Expert. You then need to download and upload that specific Wasm using the aforementioned stellar registry commands.
dApp
Once you are ready to deploy your dApp, you can run:
npm run build
This will bundle your application in the /dist folder. Then you have mainly two approaches to serve its content:
- A centralized service provider like GitHub Pages, Vercel, Netlify, etc.
- A decentralized solution like IPFS.
As we are developing a blockchain application and decentralization is one of the core principle of what we do, we recommend to deploy on your application following a decentralized approach.
If for some reason you still prefer a centralized solution, you can have a look at this extensive guide from Vite.
The rest of this guide will focus on a decentralized deployment. We provide a GitHub action workflow which builds the application, creates a signed attestation and deploys the files to IPFS:
- Push on
dapp_production, - The IPFS workflow runs and produces an IPFS address (CID),
The CID can be used with any IPFS gateway. This might not seem very convenient for your users, luckily in the ecosystem we have a gateway with which it is very easy to integrate:
Thanks to that provider, you can have a website under your-dapp.xlm.sh.
IPFS is not magical in the sense that we have some setup to do. You need an entry point to upload your files to if you don't yourself want to run an IPFS node. Our GitHub action integrates with Storacha and following are some instructions.
Storacha setup
Follow Storacha's documentation to create a Space and obtain its Proof (a UCAN proof string). Following is a quick start.
If you do not have an account, you will be prompted to create one and select a plan. The free plan is more than enough for what we want to do.
Install the CLI:
npm install @storacha/cli
Create an account or log in:
storacha login
Create a space:
storacha space create scaffold
This will generate a space which is identifiable by a DID, something like did:key:z6Mk....
The next step is to create a key, this is STORACHA_PRINCIPAL:
storacha key create --json
The key itself has its own DID. Use that DID to create a delegation proof:
export AUDIENCE=did:key:z6Mk...
storacha delegation create $AUDIENCE -c space/blob/add -c space/index/add -c filecoin/offer -c upload/add --base64
This is your STORACHA_PROOF.