Cosmos
Introducing the Range API: A Developer's Guide
The Range API brings new risk and secure capabilities to the Cosmos ecosystem, such as real-time risk screening and transaction simulations. This technical guide will help you easily integrate it into your application.
Range Team
In the evolving landscape of blockchain technology, ensuring secure and trustworthy transactions is paramount. The Range API provides an invaluable resource for developers looking to enhance the security features of their blockchain applications, especially wallets, multi-sigs, and app developers.
This tutorial will guide you through integrating the Simulations and Risk API into your app, wallet, or backend, highlighting its benefits and providing step-by-step instructions to get started. Currently, both APIs are only available for Osmosis and Neutron. If you need a free API key, contact us at info@range.org.
Overview
The Range API is divided into the Simulation API and the Risk API.
The Simulation API can tell you in real-time what the change in token balances will be before executing (or even signing!) a transaction. This can be incredibly useful to protect your users against phishing sites, poorly configured contracts, slippage, etc. Moreover, since the Simulation API relies on a forked version of the Cosmos nodes, it can also tell you if a transaction will succeed or fail, running not just basic checks but also stateful ones.
The Risk API evaluates the risk associated with blockchain addresses and transactions. It indexes transactions, primarily from Cosmos and Tendermint networks like Osmosis and Neutron. Each address is represented as a node, and transactions between addresses create relationships. The API identifies malicious addresses, such as those involved in hacks or scams, and assigns risk scores based on their proximity to known malicious entities.
The Simulation and Risk API can play a powerful tandem when combined. The main use cases that we and our early launch partners have identified are:
User and wallet security
Transaction screening and KYT (know-your-transaction)
Risk and Compliance
Getting Started
Before diving into integration, familiarize yourself with the API's endpoints and their responses. The Range API Docs provides comprehensive details on interacting with the API, including example requests and responses. For testing, tools like cURL or Postman can simulate API calls and inspect the outputs.
You can test the Simulation API via the same documentation. To make life easier for developers, we’ve also created an easy-to-use frontend that you can access in the Range platform.
To test it out, you can use it in combination with Keplr, pasting the transaction data in JSON format before approving a transaction's signature.
Use Case Highlight: Integrating the Range API into Wallet Extensions
Integrating the Range API into a wallet extension can significantly enhance its security features. Here are some key use cases:
Pre-Transaction Risk Assessment
Implementation Steps:
Capture the sender and receiver addresses when a user initiates a transaction.
Call the Range API endpoint for each address to fetch the risk score.
Display a warning if the risk score exceeds a certain threshold.
Address Verification
Implementation Steps:
Capture the address when added to the contact list.
Query the Range API to obtain the risk score and details.
Inform the user if the address is associated with any malicious activities.
Audit and Compliance
Implementation Steps:
Monitor all transactions processed by the wallet.
Regularly query the Range API to assess the risk of all involved addresses.
Generate reports for compliance and auditing purposes.
API Endpoints and Responses
The Risk-API provides two primary endpoints to assess risks:
1. Risk Score by Address
This endpoint returns the risk score for a specific address, including details about any associated malicious activities. Detailed information can be found in the Get Address Risk Score documentation.
Code Example:
2. Risk Score for a Transaction
This endpoint evaluates the risk for an entire transaction by considering all involved addresses. It provides a comprehensive risk score and details for each address.
More details can be found in the Get Transaction Risk Score documentation.
Code Example:
3. Simulating Transactions with the Simulation API
The Simulation API allows developers to simulate a transaction on supported networks (currently Osmosis and Neutron) to see how the transaction would affect the status of the involved addresses. This can be particularly useful for understanding the potential impacts of a transaction before it is executed.
More details can be found in the Simulate Transaction documentation.
Code Example:
Conclusion
Integrating the Risk API into your wallet extension or blockchain application can significantly enhance its security by providing real-time risk assessments of addresses and transactions. This not only helps in protecting users but also ensures compliance and builds trust in your organization.
To get started, visit the documentation and begin exploring the capabilities of the Range API. With the ability to assess and respond to risks proactively, your application can become a safer place for users to interact with the blockchain. If you need a free API key, contact us at info@range.org.
About Range
Range is the blockchain security and intelligence platform featuring an advanced transaction explorer, real-time security and alerting, cross-chain wallet monitoring, and IR and forensic capabilities. We protect more than $20B in TVL and work with the best organizations in the industry, such as Circle, Solana, dYdX, and Osmosis. Start leveraging Range today with the Range Community platform, or book a demo with us.