Requesting credit action for organization

This example shows how an app can request a transfer / retirement for organization owned credits

This is a continuation of the "Setting up an ICR app" example.

Update the app's permissions

To update the permissions that the app requests access to we go back to the app's dashboard and into the "Permissions" tab

The additional permission we are looking for is the "Inventory - Read and request" permission. Choose that one. You'll be warned that this update will prompt admins of organizations that have your app installed to accept the new permissions before they are made available to your app.

For now save the update permissions. Then go to an organization you've installed your app on. In the "Installations" tab you'll see your app and the state of the permissions.

Review the update request and accept it. Now your app can read and request actions from that organization's inventory.

Reading organization's inventory

Getting the inventory of the organization is simple (docs)

const inv = await axios.get(
          `${env.ICR_API_URL}/organizations/${input.organizationId}/inventory`,
          {
            headers: {
              Authorization: `Bearer ${accessToken.token}`,
            },
          },
        );

Reference for this code here.

Requesting transfer from organization inventory

This requires your app to have the "Inventory - Read and request" permission. If you need test credits see the friendbot.

const inv = await axios.get(
          `${env.ICR_API_URL}/organizations/${input.organizationId}/inventory/requests`,
          {
            headers: {
              Authorization: `Bearer ${accessToken.token}`,
            },
          },
        );

Reference for this code here.

After having called this code the admin of the organization will be able to decide to accept or decline the request.

In this way an app can suggest actions, transfers, retirements for the organization to take based on some off-platform activity. This could, for example, be used by a marketplace that supports self custody of on chain credits (then it would request a transfer to some off ICR platform wallet address) or it could be used by a marketplace that requires the marketplace itself to hold the credits in their own organization inventory. Then the marketplace would request the transfer of these credits to their organization and keep their own internal accounting on who has claims to those credits.

Last updated