How to Deploy Static and Dynamic Dapps on Spheron
Learn how to seamlessly connect your Git provider, configure deployment settings, and effortlessly launch your dapps and compute instances on Spheron's decentralized...
Learn how to seamlessly connect your Git provider, configure deployment settings, and effortlessly launch your dapps and compute instances on Spheron's decentralized...
Spheron is a game-changing solution revolutionizing decentralized application (dApp) infrastructure. With its comprehensive set of tools and services rooted in Web3 Infra, Spheron empowers developers to meet the dynamic demands of the digital landscape. Going beyond traditional Web2 infrastructures, Spheron offers a wide range of services including web hosting, storage, and compute capabilities, serving as a vital component in the Web3 ecosystem. Its exceptional performance not only rivals Web2 counterparts but also showcases the potential of Web3 technology for the next generation of applications.
Learn more about Spheron through their documentation.
Deploying static apps on Spheron is a straightforward process. Follow these steps to deploy your static apps on Spheron:
Checkout our Framework Guide for more info.
Deploying compute instances on Spheron is simple and effortless, whether you’re using a Docker image from Docker Hub or deploying a marketplace app. Follow these steps to deploy your compute instance on Spheron:
Checkout our Compute Documentation for more info.
npm i @spheron/storage
import { SpheronClient, ProtocolEnum } from "@spheron/storage";
const client = new SpheronClient({ token });
let currentlyUploaded = 0;
const { uploadId, bucketId, protocolLink, dynamicLinks } = await client.upload(
filePath,
{
protocol: ProtocolEnum.IPFS,
name,
onUploadInitiated: (uploadId) => {
console.log(`Upload with id ${uploadId} started...`);
},
onChunkUploaded: (uploadedSize, totalSize) => {
currentlyUploaded += uploadedSize;
console.log(`Uploaded ${currentlyUploaded} of ${totalSize} Bytes.`);
},
}
);
Checkout our Storage SDK Documentation for more info.
npm i @spheron/browser-upload
You have to set up a web server with an endpoint that will be used by the frontend to fetch the token for upload.
import { SpheronClient, ProtocolEnum } from "@spheron/storage";
...
app.get("/initiate-upload", async (req, res, next) => {
try {
const bucketName = "example-browser-upload"; // use your preferred name
const protocol = ProtocolEnum.IPFS; // use your preferred protocol
const token = process.env.SPHERON_TOKEN; // add your access token in .env or paste it here
const client = new SpheronClient({ token });
const { uploadToken } = await client.createSingleUploadToken({
name: bucketName,
protocol,
});
res.status(200).json({
uploadToken,
});
} catch (error) {
console.error(error);
next(error);
}
});
You have to send a request to your server to create the uploadToken that will be used to upload files from the browser.
import { upload } from "@spheron/browser-upload";
...
const response = await fetch(`<BACKEND_URL>/initiate-upload`); // get the temporary access token from server
const resJson = await response.json();
const token = resJson.uploadToken;
let currentlyUploaded = 0;
const { uploadId, bucketId, protocolLink, dynamicLinks } = await upload(files, {
token,
onChunkUploaded: (uploadedSize, totalSize) => {
currentlyUploaded += uploadedSize;
console.log(`Uploaded ${currentlyUploaded} of ${totalSize} Bytes.`);
},
});
...
Checkout our Browser Upload SDK for more info.
To install the Spheron CLI, run the following command in your terminal:
sudo npm install -g @spheron/cli
To install the Spheron CLI, open your terminal as administrator mode and run the following command:
npm install -g @spheron/cli
The spheron init
command allows you to initialize a new Spheron project. A spheron.json
file is created in your current path that describes your project. It will be utilized by the spheron publish
command.
spheron init
Upon running this command, a prompter will appear that will allow you to select protocol, add project name, add path, and select framework. Here is how it will look:
? Project name: (Code)
? Upload protocol: (Use arrow keys)
❯ Arweave
Filecoin
IPFS
The spheron publish
command allows you to upload your project using the configuration that is described in the spheron.json
file of your project.
spheron publish
Make sure that you create a production build before running the `spheron publish` command.
Here is an example of how the result will look:
Spheron CLI 1.0.7
Publishing your dapp to IPFS 🚀
Uploading directory build
Upload started, ID of deployment: 643fce207c3c7a0012df33a7
⠙ Uploading to IPFS
✓ Success! Upload finished !
Here are upload details:
Upload ID: 643fce207c3c7a0012df33a7
Bucket ID: 643fce207c3c7a0012df33a5
Protocol Link: https://bafybeicrjwhn6nifl7tcuhkcitquvpumj426qa7r7ppcya5skmqly5n2la.ipfs.sphn.link
Dynamic Links: https://testapp-edab50.spheron.app
Checkout our CLI Documentation for more info.
Dedicated Gateways are IPFS gateways specifically designed to enhance access to pinned content across the network by offering faster speeds and increased rate limits.
Using Dedicated Gateways offers several benefits:
Follow these steps to create a Dedicated Gateway:
To access content through your Dedicated Gateway, simply follow these steps:
https://{gateway-name}.spheron.link/ipfs/{cid}
Checkout our Gateway Documentation for more info.