🛩ī¸Getting Started With Safeloop

Setting Up SafeLoop

In this section, we'll guide you through the installation process for SafeLoop, ensuring you have the necessary tools and components to seamlessly integrate this decentralized technology into your projects. By following the step-by-step instructions, you'll be on your way to unlocking efficient and secure blockchain data access. Whether you're a developer or a blockchain enthusiast, our installation guide will help you get started with SafeLoop.

Setting Up SafeLoop

Step 1: Register on SafeLoop

First, you need to register on the SafeLoop platform if you haven't already. This will give you access to the necessary credentials for using the SafeLoop SDK in your dApp.

Step 2: Generate Test Keys and Secrets

Once you're registered and logged in, navigate to your developer dashboard. Here, you can generate test keys and secrets that will allow you to interact with the SafeLoop network during your development and testing phase. Keep these credentials safe, as they will be needed to configure the SafeLoop SDK. For complete guide on generating your keys and secret checkout Getting Your API Credentials.

Step 3: Install the SafeLoop SDK

Install the SafeLoop SDK into your dApp by using the Node Package Manager (NPM). Run the following command in your project directory to add the SDK as a dependency:

Yarn

yarn global add @safeloop/sdk

NPM

npm install -g @safeloop/sdk

This will ensure you have the necessary tools to interact with the SafeLoop network.

Step 4: Configure the SDK

In your dApp code, configure the SafeLoop SDK with your generated keys, secrets, and project ID. You can use the init method provided by the SDK to set up the configuration. Here's an example of how to do this:

const { SafeLoopSDK } = require('@safeloop/sdk');

const safeLoopClient = new SafeLoopSDK({
  key: 'YOUR_API_KEY',
  secret: 'YOUR_API_SECRET',
  projectId: 'YOUR_PROJECT_ID',
  rpcEndpoint: 'YOUR_RPC_ENDPOINT',
  contractAddress: 'YOUR_CONTRACT_ADDRESS',
  abi: 'YOUR_ABI', // Replace with your contract's ABI
  manifest: 'YOUR_MANIFEST', //// Replace with your subquery menifest
  network: 'YOUR_NETWORK', // e.g., 'mainnet', 'ropsten', 'bsc', etc.
  networkName: 'YOUR_NETWORK_NAME', // e.g., 'Ethereum', 'Binance Smart Chain', etc.
  networkChainId: YOUR_CHAIN_ID, // e.g., 1 for Ethereum, 56 for BSC, etc.
});

Ensure you replace 'YOUR_API_KEY', 'YOUR_API_SECRET', 'YOUR_PROJECT_ID', 'YOUR_RPC_ENDPOINT', 'YOUR_CONTRACT_ADDRESS', 'YOUR_ABI', 'YOUR_NETWORK', 'YOUR_NETWORK_NAME', and YOUR_CHAIN_ID with your actual credentials and network-specific information. This configuration will allow you to initialize the SafeLoop SDK with all the necessary settings to interact with your chosen blockchain network.

Step 5: Write and Execute GraphQL Queries

With the SafeLoop SDK configured, you can now start writing GraphQL queries to fetch data from the Binance Smart Chain (BSC) or other supported networks. Here's an example of a simple GraphQL query to retrieve data:

graphqlCopy codequery {
  transactions {
    id
    timestamp
    sender
    receiver
    value
  }
}

You can customize your queries to retrieve the specific data you need for your dApp.

Run Queries and Fetch Data

Using the SafeLoop SDK, execute the GraphQL queries in your dApp to fetch the desired blockchain data. The SDK will handle the communication with the SafeLoop network, and you'll receive the data in response.

By following these steps, you'll be able to integrate SafeLoop into your decentralized application and efficiently retrieve blockchain data, helping you overcome the complexities associated with data retrieval on blockchain networks.

Last updated