Smart contract api portal
Smart Contract API Portal for zero-config self generated APIs
The smart contract portal middleware
The Smart Contract Portal is a middleware which creates an easy to use api on top of your smart contracts. It can be used with all EVM-compatible chains like Ethereum, Hyperledger Besu, Polygon, Avalanche, etc. You can run it on your own blockchain nodes (both public and permissioned) or on a Load Balancer.
Benefits of using the smart contract portal:
- Simplified Integration: APIs allow developers to interact with complex smart contract functions through familiar interfaces, reducing the need to understand blockchain-specific languages and protocols.
- Data Aggregation: APIs can consolidate data from multiple smart contracts, providing a unified view.
- Improved Performance: GraphQL optimizes data fetching, ensuring that clients retrieve only the necessary data in a single request, reducing network load and improving performance.
- Stack agnostic: Teams are free to choose their own technology stack.
Before you start, make sure you are running an EVM-compatible network (Ethereum, Polygon, Hyperledger Besu, Avalanche, etc.) and have a private key to deploy your smart contracts.
Using the smart contract portal middleware
The Portal middleware provides instant API access to your smart contracts. Key features include:
- Auto-generated REST & GraphQL APIs
- Built-in webhooks for event notifications
- Type-safe contract interactions
- Automatic ABI parsing
Using the portal sdk
For comprehensive API documentation and advanced features, check out the Portal SDK documentation.
Upload an abi
A smart contract ABI (Application Binary Interface) is a standardized way for interacting with smart contracts in the Ethereum blockchain and other compatible systems. It serves as the bridge between human-readable contract code (written in languages like Solidity) and the Ethereum Virtual Machine (EVM), which executes the contract. The ABI specifies the functions that can be called on the contract, including their names, input parameters, and output types.
When deploying a smart contract the ABI file can be found as part of the artificats. See Deploying the Smart Contract. Download the ABI json files and save them on your local filesystem.
When creating a new middleware you'll need to upload at least one ABI.
To update the ABIs of an existing smart contract portal middleware navigate to the middleware, go the details and click on the 'Manage Middleware' button on the top right. Click on the 'Update ABIs' item and a dialog will open. In this dialog upload the ABI file(s) you saved on your local filesystem in the previous step.
Rest
A fully typed REST api with documentation is created out of the Smart Contract ABI, you can discover all its endpoints on the REST tab. To see examples in your technology of choice use the dropdown in the example section on the right.
Graphql
The GraphQL api exposes the same functionality as the REST api, you can discover it on the GraphQL tab.
Webhooks
On the Webhooks tab you can register your own webhook. The portal will send events to this webhook when a transaction is processed.
When sending a message the event will have a signature which allows the receiver to validate if the event has not been tampered with.
The secret to validate the signature can be copied from the details page of your webhook.
Standard Webhooks has built SDKs and useful tools using different programming languages that make it easy to start using webhooks.
An example using Typescript, Elysia and standard webhooks.
Further reading
All operations require appropriate permissions in your workspace.