Introduction
Kalp's API Gateway is a powerful tool that simplifies generating and managing API endpoints, making it easier for developers to create, deploy, and maintain secure and scalable APIs. Whether building microservices or looking to unify multiple API services, Kalp’s API Gateway streamlines the process, providing enhanced control over routing, security, and performance.
In this tutorial, we’ll walk through the steps of generating API endpoints using Kalp’s API Gateway.
Prerequisites
- A Kalp Studio Account. Create your account on Kalp Studio here.
- A Custodial Wallet: Before proceeding further, you would need to have a Kalp Studio’s Custodial Wallet connected, for this tutorial, we are connecting our wallet on the Ethereum Blockchain and Holesky Network. If you haven’t connected your wallet yet, please go through our first tutorial of this series here: Creating your Custodial Ethereum Wallet on Holsekey Network, using Kalp Studio.
- A Deployed Solidity Smart Contract: To generate API Endpoints, we must first deploy our desired smart contract on Kalp Studio using the Kalp Instant Deployer. To ensure you deploy your smart contract on Kalp Studio, take a look at the second tutorial of this series: Create Your First Smart Contract in Solidity and Upload it to Kalp Instant Deployer.
What is an API Gateway?
Before diving into the specifics, it’s important to understand what an API Gateway is. Essentially, it acts as an intermediary between clients and backend services. It handles request routing, composition, and protocol translation, ensuring your APIs are secure, efficient, and maintainable.
Kalp Studio provides a robust platform that allows developers to efficiently create, manage, and generate API endpoints for their smart contracts.
Deploying Your Smart Contract on Kalp Instant Deployer (A Recap)
Let’s take a quick review of how we can deploy our Solidity Smart Contract on Kalp Instant Deployer, in a few quick steps.
Step 1:
Create your desired smart contract in solidity and save it in a .sol file. For this tutorial’s purpose, let’s use a simple contract, which demonstrates the basics of a contract, including storing and retrieving data:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleStorage {
uint256 private storedData;
// Event that is emitted when the data is updated
event DataStored(uint256 data);
// Function to store data
function set(uint256 data) public {
storedData = data;
emit DataStored(data); // Emit an event when data is stored
}
// Function to retrieve stored data
function get() public view returns (uint256) {
return storedData;
}
}
Step 2:
Navigate to Kalp Instant Deployer and Click on +Deploy New button, if you haven’t deployed the smart contract yet. (Detailed reference here).
Step 3:
After filling up the details, we must now be able to see that our smart contract has been deployed successfully.
(For this tutorial, we have named our smart contract as TutorialSmartContract).
With everything now set, it’s time to generate the endpoints from our smart contracts.
Using the Kalp API Gateway to Generate Endpoints
- On the left sidebar, click on the API Gateway.
- Once you click on it, you can see all of your deployed smart contracts, with relevant details like Smart Contract ID, Category, Status, Network, the Blockchain it’s been deployed on, etc.
- Scroll towards the right, and you can see the section named, “Action”. Under this column, click on Generate Endpoints.
- Once you click on Generate Endpoints, you’ll get the alert stating that you have successfully and the button would change to “Re-Generate Endpoints”.
This confirms now that the endpoints for our smart contracts have now been generated.
- To check the endpoints, click on the ID of your desired smart contract.
- Here, you can now see that the endpoints are now accessible. With other details, like the Method, Function Name, Route etc. You can also find the Smart Contract Address mentioned above as well.
- To explore the Route Details, you can click on the Check Params button. After clicking on it, you’ll see a pop-up where you can check the Params and the API Auth Key.
Conclusion
Congratulations! You just generated API Endpoints from your smart contracts using Kalp’s API Gateway. Kalp’s API Gateway simplifies the process of generating and managing API endpoints. By following these steps, you can efficiently set up a secure, scalable, and performant API infrastructure. With features like request validation, rate limiting, and built-in security, Kalp’s API Gateway offers developers all the tools they need to create powerful and robust APIs.
In the next tutorial, we will be interacting with the API Endpoints generated and check if they’re working with the help of Postman. Until then, stay tuned.
Whether you’re working with microservices or looking to unify multiple backend systems, Kalp’s API Gateway is a great choice for building modern, scalable APIs.
Check out our official documentation here to continue exploring what more Kalp Studio can do. If you have any queries, join our Discord server and let’s continue the discussion there.