Adding Balance to a Subnet

This section guides you on how to add balance to subnets in the Workflow Agent Studio.

Required Imports

import SkyMainBrowser from "@decloudlabs/skynet/lib/services/SkyMainBrowser";
import { ethers } from "ethers";
import { SETTLER_CALLTYPE } from "path/to/utils/skynetHelper"; // Import from your project's utils

Subnet Balance Interface

export interface SubnetBalance {
  subnetId: string;
  subnetName: string;
  balance: number; // Balance in USD
  hasBalance: boolean;
}

Helper Functions

Convert Ether to Wei

export const etherToWei = (ether: number, decimal: number): number => {
  if (decimal === 6) {
    return (Math.floor(ether * 1e6));
  }
  return (Math.floor(ether * 1e18));
};

Convert Big Intergers to Bytes

Getting Subnet Balance

To check the current balance of a subnet, use this:

Adding Balance to a Subnet

The main function to add balance to a subnet:

Example Usage

Here's how to use the callSubscribe function:

Adding Balance Before Deployment

Before deploying a workflow, ensure all subnets have sufficient balance:

Last updated