inabit x Crypto Clearing Services

An example use case of how inabit's API Infrastructure is utilized

Overview

Welcome to the comprehensive guide on leveraging inabit's digital wallet infrastructure. As a digital wallet infrastructure provider, inabit is dedicated to streamlining operations for clearing services like yours. This guide will walk you through the seamless integration and management of your digital wallet operations, ensuring security, efficiency, and scalability.

Prerequisites

Before diving into the setup, ensure you have:

  • Have an API Admin user created for your organization in inabit.

  • Access to the inabit platform (as the Clearer):

    • Have an account ready to be used.

    • Create an inabit "Main" wallet via the platform's UI.

      • This wallet will serve as the funding route for the Clearer.

    • Create an additional inabit wallet and deposit funds for fee:

  • Necessary access permissions setup.

    • Eligible roles - Owner / Admin / API Admin.

🚧 One-time Must-Have Setup:

Please ensure that you complete the Approvals Docker Configuration and execute the API signer Setup as a one-time prerequisite. Once this step is accomplished, you will be able to create your API wallets and addresses as needed.

Additional Reference

We highly advise taking a look at the following guides as you develop your crypto clearing application with inabit:

Technical Architecture: How Transactions Flow?

The architectural diagram depicts the wallet infrastructure utilizing Inabit for clearers (Clearing service providers). The process primarily involves customer actions and the reception of API information. Below is a breakdown of the workflow outlined in the diagram:

Clearer Flow Explained

  • Clearer initiates a request to inabit's API to generate a dedicated deposit address (API wallet) for the customer (step 1 in the flow).

    • inabit also sends a new transaction event webhook to the clearer during this time.

  • The clearer issues a withdrawal from the inabit wallet that contains native assets (for fee payment purposes) and transfers the "gas" to the desired customer API wallet (API wallet F in this case) (step 3)

Now that the flow is clear, let's review the implementation process step by step!

1. Generate API Wallet Addresses for Customers

The clearing service (clearer) develops a logic that on every crypto deposit request their customer makes, a new inabit API wallet and address are created.

The clearer then saves this API walletId to associate it with their customer in the clearer's database.

In order to generate the API wallet address for the customer's deposit, call the following mutation:

Remember to authenticate to call our graphQL API using an access token (bearer) with your API Admin credentials. (If you're not sure how, refer to Authentication)

Don't have an API Admin/API Signer yet? contact us at support@inabit.com to create one!

CreateApiWalletAddress Mutation:

mutation CreateApiWalletAddress($data: ApiWalletCreateAddressInput!) {
  createApiWalletAddress(data: $data) {
    address
    walletId
  }
}

Body (ApiWalletCreateAddressInput object)

NameTypeDescription

blockchainId*

string

ID of the blockchain in inabit

financialAssetId*

string

ID of the financial asset in inabit (can be token/native)

organizationId*

string

ID of the organization in inabit

Example body:

{
  "data": {
    "blockchainId": "clefn78cl00i3lc6rih442mx9",
    "financialAssetId": "clefn78h5012plc6rxbmofnop",
    "organizationId": "clsu8bel7000dlciyfdfbmwcw"
  }
}

Response

{
	"data": {
		"createApiWalletAddress": {
			"address": "0xcc918e16bc528bf58fc250f56898c7d917d33de2",
			"walletId": "cluicfnpb000066015d3narbc"
		}
	}
}

In the mutation's response, you should receive the deposit address for the blockchain and asset you've requested, as well as the inabit API wallet ID for the customer (which you can later save and relate to the specific customer, in order to identify a customer's inabit API wallet).

Reminder - You can always query data and fetch all API wallets & their blockchain address in your organization when needed. Refer to Wallets Info.

2. Customer Transfers Crypto to their Wallet Address

In order to receive a notification that the customer sent funds successfully to their inabit API wallet address, you will need to register to our webhook subscription service and create a subscription for your organization.

Please refer to Webhooks and Notifications 📣 for further information.

3. Clearer Transfers Fees/Gas from their Wallet to Customer's Wallet

Once the clearer (you) receives a successful webhook for a received transaction in the customer's wallet (status update that txn was successful and funds are in the customer's wallet)

The clearer should issue an additional transfer from the wallet intended for fees, to the customer's wallet in order be able to withdraw the customer's deposited funds.

This step is applicable only in cases where the user transfers tokens, native blockchain assets can be transferred if they complete a sufficient amount to pay for the transaction fee.

Take this into consideration when transferring funds from your "fees" wallet.

Let's put this into an actual example:

  • Customer transfers USDT in Ethereum blockchain.

  • Clearer (you) receives transaction webhook that it was completed.

  • Clearer (you) initiates a withdrawal for Ethereum from the fees API wallet to the designated customer wallet, in order to withdraw the funds afterwards. (step 4)

How to Withdraw/Transfer Gas Funds to the Customers Wallet?

CreateWithdrawal Mutation:

mutation CreateWithdrawal($data: WithdrawalCreateInput!) {
  createWithdrawal(data: $data) {
    id
  }
}

Body (WithdrawalCreateInput object)

NameTypeDescription

walletId*

String

Wallet ID

financialAssetId*

String

Asset ID

address*

String

From Address (Source)

amount*

Integer

Transfer amount

blockchainId*

String

Blockchain ID

note

String

Transaction Note

priority

String

Transaction Priority

(Slow, medium, fast, etc.)

Example body:

{
	"data": {
		"wallet": {
			"id": "clol7o576002oaz011mmtnvru"
		},
		"financialAsset": {
			"id": "clefn78gv011olc6rcwtt0wel"
		},
		"address": "0x7582f3483116105e0b7845ac1a0df5eb0c8cd062",
		"amount": 5,
		"blockchain": {
			"id": "clefn78em00mslc6r3lzf3h5a"
		},
		"note": "",
		"priority": "Medium"
	}
}

Response

{
	"data": {
		"createWithdrawal": {
			"id": "clpgvrjb700136g01lr3o0tgv",
		}
	}
}

In the mutation's response, you should receive the withdrawal ID.

🚧 Approval Required

Note that withdrawals will require an approval. In this case, approvals are given automatically according to the logic decided by the clearer (you), through the automatic approvals application (docker).

If you feel like you've missed this step, please check prerequisite once more and refer to our additional reference section at the beginning of the page.

4. Clearer Sends Funds From Customer's Wallet to their "Main" Wallet

Now that the customer's API wallet has enough funds for fee, the final step of the flow would be to send the crypto amount deposited by the customer - to the clearer's (you) "main" wallet. (that we created as a prerequisite.

This step would require an additional withdrawal mutation to be called upon, but this time using the customer's walletId with the financialAssetId of the deposited crypto, and to the destination address in the main wallet.

🚧 Approval Required

Once again, approvals in this step are happening automatically according to the logic decided by the clearer, within the automatic approvals application (docker).

If you feel like you've missed this step, please check prerequisite once more and refer to our additional reference section at the beginning of the page.

Congratulations! 🎉👏

Your clearing service, powered by our infrastructure, is fully operational, functional, and secure!

If you encounter any challenges in the process or need further clarification on any aspect, please don't hesitate to reach out to us at support@inabit.com.

Last updated