Awesome Miner C# Script API

This page describes the .NET interfaces provided by Awesome Miner to be used in the C# scripts.

Example usage

All interfaces are accessed from the Context object (of type IContextProvider). The Context object exposes public properties for each of the public interfaces. To access the IMinerProvider interface in IContextProvider, simply access the property by Context.Miner.

The example below shows the following scenario:

  1. Call the GetByName method of the IMinerProvider interface to get an object representing the miner with name "AntMiner".
  2. Call the GetByName method of the IPoolProvider interface to get an object representing the pool with name "Bitcoin Pool".
  3. Call the Prioritize method of the IPoolProvider interface to prioritize (switch to) the "Bitcoin Pool" for the miner "AntMiner".
    IMinerBase miner = Context.Miner.GetByName("AntMiner");
    ISinglePool btcPool = Context.Pool.GetByName("Bitcoin Pool");
    Context.Pool.Prioritize(miner, btcPool);

Code examples

API Documentation

IContextProvider

    public interface IContextProvider
    {
        //
        // Summary:
        //     Get access to features provided by the interface IMinerProvider. 
        //
        IMinerProvider Miner { get; }
        //
        // Summary:
        //     Get access to features provided by the interface IMinerStatProvider. 
        //
        IMinerStatProvider MinerStat { get; }
        //
        // Summary:
        //     Get access to features provided by the interface ICoinStatProvider. 
        //
        ICoinStatProvider CoinStat { get; }
        //
        // Summary:
        //     Get access to features provided by the interface INotificationProvider. 
        //
        INotificationProvider Notification { get; }
        //
        // Summary:
        //     Get access to features provided by the interface IOnlineServiceProvider. 
        //
        IOnlineServiceProvider OnlineService { get; }
        //
        // Summary:
        //     Get access to features provided by the interface IPoolProvider. 
        //
        IPoolProvider Pool { get; }
        //
        // Summary:
        //     Get access to features provided by the interface ISystemProvider. 
        //
        ISystemProvider System { get; }
        //
        // Summary:
        //     Get access to features provided by the interface IWebDownloadProvider. 
        //
        IWebDownloadProvider WebDownload { get; }
    }

IMinerProvider

    public interface IMinerProvider
    {
        //
        // Summary:
        //     Get a list of all miners. 
        //
        List<IMinerBase> GetAll();
        //
        // Summary:
        //     Get a list of all Managed Miners matching the specified host. 
        //
        List<IMinerBase> GetAllForHost(IHost host);
        //
        // Summary:
        //     Get specific miner by name. 
        //
        // Parameters:
        //   name:
        //     Name of the miner.
        //
        IMinerBase GetByName(string name);
        //
        // Summary:
        //     Restart the specified miner. 
        //
        // Parameters:
        //   miner:
        //     The miner to restart.
        //
        void Restart(IMinerBase miner);
        //
        // Summary:
        //     Starts the specified miner. 
        //
        // Parameters:
        //   miner:
        //     The miner to start.
        //
        void Start(IMinerBase miner);
        //
        // Summary:
        //     Starts the specified miner and make specified Pool the one with highest priority. 
        //
        // Parameters:
        //   miner:
        //     The miner to start.
        //
        //   topPriorityPoolId:
        //     Pool Id to prioritize, overriding Pool Group defined priorities
        //
        void StartAndPrioritize(IMinerBase miner, int topPriorityPoolId);
        //
        // Summary:
        //     Stops the specified miner. 
        //
        // Parameters:
        //   miner:
        //     The miner to stop.
        //
        void Stop(IMinerBase miner);
        //
        // Summary:
        //     Send API command to the specified miner. 
        //
        // Parameters:
        //   miner:
        //     The miner to send command to.
        //
        //   command:
        //     The API command to execute.
        //
        void ApiCommand(IMinerBase miner, string command, string parameters);
        //
        // Summary:
        //     Get Antminer S7/S9 frequency 
        //
        // Parameters:
        //   miner:
        //     The miner to get frequency for.
        //
        int AntminerGetFrequency(IMinerBase miner);
        //
        // Summary:
        //     Use SSH to modify Antminer S7/S9 frequency. The mining process will be restarted after the operation. Use on your own risk and expense. 
        //
        // Parameters:
        //   miner:
        //     The miner to send command to.
        //
        //   sshUsername:
        //     SSH username, by default: root
        //
        //   sshPassword:
        //     SSH password, by default: admin
        //
        //   frequency:
        //     Frequency in MHz
        //
        bool AntminerSetFrequency(IMinerBase miner, string sshUsername, string sshPassword, int frequency);
    }

IMinerStatProvider

    public interface IMinerStatProvider
    {
        //
        // Summary:
        //     Gets the 'Accepted' value. 
        //
        // Parameters:
        //   miner:
        //     The miner to return statistics from.
        //
        //   secondsAgo:
        //     Number of seconds ago. Specify 0 for current value.
        //
        double GetAccepted(IMinerBase miner, int secondsAgo = 0);
        //
        // Summary:
        //     Gets the 'Accepted' value in percent. 
        //
        // Parameters:
        //   miner:
        //     The miner to return statistics from.
        //
        //   secondsAgo:
        //     Number of seconds ago. Specify 0 for current value.
        //
        double GetAcceptedPercent(IMinerBase miner, int secondsAgo = 0);
        //
        // Summary:
        //     Gets the 'Hardware Error' percent. 
        //
        // Parameters:
        //   miner:
        //     The miner to return statistics from.
        //
        //   secondsAgo:
        //     Number of seconds ago. Specify 0 for current value.
        //
        double GetHwErrorPercent(IMinerBase miner, int secondsAgo = 0);
        //
        // Summary:
        //     Gets the 5 second average number of kilo hash per seconds. 
        //
        // Parameters:
        //   miner:
        //     The miner to return statistics from.
        //
        //   secondsAgo:
        //     Number of seconds ago. Specify 0 for current value.
        //
        double GetKHash5s(IMinerBase miner, int secondsAgo = 0);
        //
        // Summary:
        //     Gets the average number of kilo hash per seconds. 
        //
        // Parameters:
        //   miner:
        //     The miner to return statistics from.
        //
        //   secondsAgo:
        //     Number of seconds ago. Specify 0 for current value.
        //
        double GetKHashAvg(IMinerBase miner, int secondsAgo = 0);
        //
        // Summary:
        //     Gets the 'Network Difficulty'. 
        //
        // Parameters:
        //   miner:
        //     The miner to return statistics from.
        //
        double GetNetworkDiff(IMinerBase miner);
        //
        // Summary:
        //     Gets the 'Rejected' value in percent. 
        //
        // Parameters:
        //   miner:
        //     The miner to return statistics from.
        //
        //   secondsAgo:
        //     Number of seconds ago. Specify 0 for current value.
        //
        double GetRejectedPercent(IMinerBase miner, int secondsAgo = 0);
        //
        // Summary:
        //     Result of Summary API command. 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        dynamic Summary(IMinerBase miner);
        //
        // Summary:
        //     Result of Pools API command. 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        dynamic Pools(IMinerBase miner);
        //
        // Summary:
        //     Result of Devs API command. 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        dynamic Devices(IMinerBase miner);
        //
        // Summary:
        //     Result of Config API command. 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        dynamic Config(IMinerBase miner);
        //
        // Summary:
        //     Result of Notify API command. 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        dynamic Notify(IMinerBase miner);
    }

ICoinStatProvider

    public interface ICoinStatProvider
    {
        //
        // Summary:
        //     Set custom coin statistics and profitability properties 
        //
        // Parameters:
        //   coinShortName:
        //     The shortname of the coin (example: BTC)
        //
        //   difficulty:
        //     Network difficulty
        //
        //   reward:
        //     Block reward
        //
        //   valueBtc:
        //     Value of each coin, expressed in Bitcoin
        //
        void SetProperties(string coinShortName, double difficulty, double reward, double valueBtc);
    }

IDeviceProvider

    public interface IDeviceProvider
    {
        //
        // Summary:
        //     Set GPU Core Clock (MHz) 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        //   valueMhz:
        //     Value in MHz.
        //
        void GpuClock(IMinerBase miner, string deviceIds, int valueMhz);
        //
        // Summary:
        //     Set GPU Memory Clock (MHz) 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        //   valueMhz:
        //     Value in MHz.
        //
        void GpuMemClock(IMinerBase miner, string deviceIds, int valueMhz);
        //
        // Summary:
        //     Set GPU Fan Speed (%) 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        //   valueMhz:
        //     Speed in percent.
        //
        void GpuFanPercent(IMinerBase miner, string deviceIds, int valuePercent);
        //
        // Summary:
        //     Set GPU Intensity 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        //   valueMhz:
        //     Intensity value.
        //
        void GpuIntensity(IMinerBase miner, string deviceIds, int value);
        //
        // Summary:
        //     Enable GPU 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        void GpuEnable(IMinerBase miner, string deviceIds);
        //
        // Summary:
        //     Disable GPU 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        void GpuDisable(IMinerBase miner, string deviceIds);
        //
        // Summary:
        //     Reset GPU 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        void GpuReset(IMinerBase miner, string deviceIds);
        //
        // Summary:
        //     Enable FPGA 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        void FpgaEnable(IMinerBase miner, string deviceIds);
        //
        // Summary:
        //     Disable FPGA 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        void FpgaDisable(IMinerBase miner, string deviceIds);
        //
        // Summary:
        //     Enable ASIC 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        void AsicEnable(IMinerBase miner, string deviceIds);
        //
        // Summary:
        //     Disable ASIC 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   deviceIds:
        //     A comma separated list of Device ID, or null/empty for all devices.
        //
        void AsicDisable(IMinerBase miner, string deviceIds);
    }

INotificationProvider

    public interface INotificationProvider
    {
        //
        // Summary:
        //     Adds an information notification message. 
        //
        // Parameters:
        //   source:
        //     The source of the notification message.
        //
        //   description:
        //     The full description.
        //
        //   notifyOnce:
        //     If set, the notification will only be added once for the specific combination of source and miner.
        //
        //   miner:
        //     Specify if the notification applies to a specific miner (optional).
        //
        void AddInformation(string source, string description, bool notifyOnce, IMinerBase miner = null);
        //
        // Summary:
        //     Adds a warning notification message. 
        //
        // Parameters:
        //   source:
        //     The source of the notification message.
        //
        //   description:
        //     The full description.
        //
        //   notifyOnce:
        //     If set, the notification will only be added once for the specific combination of source and miner.
        //
        //   miner:
        //     Specify if the notification applies to a specific miner (optional).
        //
        void AddWarning(string source, string description, bool notifyOnce, IMinerBase miner = null);
    }

IOnlineServiceEntry

    public interface IOnlineServiceEntry
    {
        //
        // Summary:
        //     Get number of Bitcoin per MH/s per day. 
        //
        double BtcPerMhsPerDay { get; }
        //
        // Summary:
        //     Get number of Bitcoin per normalized MH/s per day. (Scrypt = 1, ScryptAN = 0.47, ...) 
        //
        double BtcPerNormalizedMhsPerDay { get; }
    }

IOnlineServiceProvider

    // GetEntry(OnlineServiceType serviceType, int port) was for TradeMyBit coin and shold be removed from here and the profit switching script
    public interface IOnlineServiceProvider
    {
        //
        // Summary:
        //     Get an entry about a specific statistical item from an Online Service provider. 
        //
        // Parameters:
        //   serviceType:
        //     The type of the service (OnlineServiceType.NiceHash, OnlineServiceType.Zpool).
        //
        //   algorithm:
        //     Get algorithm to get statistics for (CoinAlgorithm.Scrypt, CoinAlgorithm.ScryptAN, CoinAlgorithm.ScryptJane, CoinAlgorithm.SHA256, CoinAlgorithm.SHA3, CoinAlgorithm.X11, CoinAlgorithm.X13, CoinAlgorithm.X15, CoinAlgorithm.Nist5)
        //
        IOnlineServiceEntry GetEntry(OnlineServiceType serviceType, CoinAlgorithm algorithm);
        //
        // Summary:
        //     Get an entry about a specific statistical item from an Online Service single-coin provider. 
        //
        // Parameters:
        //   serviceType:
        //     The type of the service.
        //
        //   port:
        //     The port number of the single-coin pool
        //
        IOnlineServiceEntry GetEntry(OnlineServiceType serviceType, int port);
        //
        // Summary:
        //     Check if the specified URL is a known and supported service. 
        //
        // Parameters:
        //   url:
        //     The pool URL
        //
        bool GetKnownSingleCoinPool(string url, out OnlineServiceType serviceType, out CoinAlgorithm algorithm, out int port);
        //
        // Summary:
        //     Download the latest statistics from the service provider. 
        //
        // Parameters:
        //   serviceType:
        //     The type of the service (OnlineServiceType.NiceHash, OnlineServiceType.Zpool)
        //
        void UpdateStatistics(OnlineServiceType serviceType);
        //
        // Summary:
        //     Download the latest statistics from all service providers. 
        //
        void UpdateStatisticsAll();
        //
        // Summary:
        //     Get the profitability factor for the specified service provider. 
        //
        // Parameters:
        //   serviceType:
        //     The type of the service (OnlineServiceType.NiceHash, OnlineServiceType.Zpool)
        //
        double GetEffectiveServiceFactor(OnlineServiceType provider);
    }

IPoolProvider

    public interface IPoolProvider
    {
        //
        // Summary:
        //     Change to specified Group Pool. 
        //
        // Parameters:
        //   miner:
        //     The miner to change pool for.
        //
        //   pool:
        //     The Group Pool to change to.
        //
        void ChangeGroup(IMinerBase miner, IGroupPool pool);
        //
        // Summary:
        //     Change to specified Pool. 
        //
        // Parameters:
        //   miner:
        //     The miner to change pool for.
        //
        //   pool:
        //     The Pool to change to.
        //
        void ChangeSingle(IMinerBase miner, ISinglePool pool);
        //
        // Summary:
        //     Compares if two pools are identical. 
        //
        // Parameters:
        //   pool1:
        //     The first pool to compare.
        //
        //   pool2:
        //     The second pool to compare.
        //
        bool Compare(ISinglePool pool1, ISinglePool pool2);
        //
        // Summary:
        //     Gets the active pool for the specified miner. 
        //
        // Parameters:
        //   miner:
        //     The miner to get pool for.
        //
        ISinglePool GetActive(IMinerBase miner);
        //
        // Summary:
        //     Get Pool object by name. 
        //
        // Parameters:
        //   name:
        //     The name of the pool.
        //
        ISinglePool GetByName(string name);
        //
        // Summary:
        //     Prioritizes the specified pool. 
        //
        // Parameters:
        //   miner:
        //     The miner the change pool prioritize for.
        //
        //   pool:
        //     The pool to prioritize. The pool must have been added to the miner before calling this method.
        //
        void Prioritize(IMinerBase miner, ISinglePool pool);
        //
        // Summary:
        //     Get current revenue in BTC per 1 MH/s per day. 
        //
        // Parameters:
        //   pool:
        //     The pool.
        //
        //   normalizedHashrate:
        //     Use algorithm normalized factor, to compare hash rates between different algorithms.
        //
        double GetPoolRevenuePerDay(ISinglePool pool, bool normalizedHashrate);
        //
        // Summary:
        //     Get current algorithm normalized factor, to compare hash rates between different algorithms. Scrypt = 1.0. 
        //
        // Parameters:
        //   algorithm:
        //     The algorithm.
        //
        double GetAlgorithmNormalizedFactor(CoinAlgorithm algorithm);
        //
        // Summary:
        //     Get algorithm for specified pool. 
        //
        // Parameters:
        //   pool:
        //     The pool.
        //
        CoinAlgorithm GetPoolAlgorithm(ISinglePool pool);
        //
        // Summary:
        //     Get list of all active pools for the specified miner. 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   requireSpecifiedCoin:
        //     If set, the result will only contain pools where a specific coin is configured.
        //
        //   includeDeadPools:
        //     If set, the result will contain both Enabled and Dead pools
        //
        //   includeDisabledPools:
        //     If set, the result will contain both Enabled and Disabled pools
        //
        List<ISinglePool> GetActivePoolList(IMinerBase miner, bool requireSpecifiedCoin, bool includeDeadPools, bool includeDisabledPools);
        //
        // Summary:
        //     Get list of all configured pools for the specified Managed Miner. 
        //
        // Parameters:
        //   miner:
        //     The managed miner.
        //
        List<ISinglePool> GetStaticPoolList(IMinerBase miner);
        //
        // Summary:
        //     Set pool priority order 
        //
        // Parameters:
        //   miner:
        //     The miner.
        //
        //   poolList:
        //     List of pools to prioritize. First in list will get highest priority
        //
        void SetPriority(IMinerBase miner, List<ISinglePool> poolList);
    }

IScriptProvider

    public interface IScriptProvider
    {
        //
        // Summary:
        //     Get a previously saved object by name. 
        //
        // Parameters:
        //   contextName:
        //     All scripts using the same contextName can access the same objects.
        //
        //   name:
        //     A unique name identifying the object to load
        //
        object LoadObject(string contextName, string name);
        //
        // Summary:
        //     Save an object that can loaded at a later time, for example the next time the script is running. The value will be persistent as long as Awesome Miner is running 
        //
        // Parameters:
        //   contextName:
        //     All scripts using the same contextName can access the same objects.
        //
        //   name:
        //     A unique name identifying the object to save
        //
        //   value:
        //     The object to save
        //
        void SaveObject(string contextName, string name, object value);
    }

ISystemProvider

    public interface ISystemProvider
    {
        //
        // Summary:
        //     Reboots the computer running the specified Managed Miner. 
        //
        // Parameters:
        //   miner:
        //     The Managed Miner
        //
        void Reboot(IMinerBase miner);
        //
        // Summary:
        //     Executes the list of commands over SSH 
        //
        // Parameters:
        //   miner:
        //     The Miner with SSH enabled
        //
        void RunSsh(IMinerBase miner, string username, string password, string[] commands);
        //
        // Summary:
        //     Write message to log file 
        //
        // Parameters:
        //   msg:
        //     The message to write
        //
        void LogMessage(string msg);
        //
        // Summary:
        //     Write message to log file (if Detailed log level enabled) 
        //
        // Parameters:
        //   msg:
        //     The message to write
        //
        void LogDetailed(string msg);
    }

IWebDownloadProvider

    public interface IWebDownloadProvider
    {
        //
        // Summary:
        //     Download the content specified by the URL and return as a value of type double. 
        //
        // Parameters:
        //   url:
        //     URL to download content from.
        //
        double GetDouble(string url);
        //
        // Summary:
        //     Download the content specified by the URL and return as a JSON object. 
        //
        // Parameters:
        //   url:
        //     URL to download content from.
        //
        JObject GetJson(string url);
        //
        // Summary:
        //     Download the content specified by the URL and return as a string 
        //
        // Parameters:
        //   url:
        //     URL to download content from
        //
        string GetString(string url);
    }

IMinerBase

    public interface IMinerBase
    {
        //
        // Summary:
        //     Gets the ID of the miner 
        //
        int ID { get; set; }
        //
        // Summary:
        //     Returns true if the miner is running 
        //
        bool IsRunningState { get; }
        //
        // Summary:
        //     Returns true if the pool is enabled and alive 
        //
        bool IsPoolAlive(ISinglePool pool);
        //
        // Summary:
        //     Gets the Description of the miner 
        //
        string GetDescription();
        //
        // Summary:
        //     Gets pool statis information 
        //
        IPoolStatus GetPoolStatus(ISinglePool pool);
        //
        // Summary:
        //     Returns false if the miner is CcMiner or Claymore's Ethereum miner. 
        //
        bool IsClassic { get; }
    }

ISinglePool

    public interface ISinglePool
    {
        //
        // Summary:
        //     Gets the ID of the pool 
        //
        int ID { get; set; }
        //
        // Summary:
        //     Gets the Description of the pool 
        //
        string GetDescription();
        //
        // Summary:
        //     Gets the pool URL 
        //
        string GetUrl();
        //
        // Summary:
        //     Key defines IMinerBase.ID, value is the Pool ID according to Cgminer 
        //
        Dictionary<int, int> PoolRuntimeIds { get; }
    }

IGroupPool

    public interface IGroupPool
    {
        //
        // Summary:
        //     Gets the ID of the pool 
        //
        int ID { get; set; }
        //
        // Summary:
        //     Gets the Description of the pool 
        //
        string GetDescription();
        //
        // Summary:
        //     Key defines IMinerBase.ID, value is the Pool ID according to Cgminer 
        //
        Dictionary<int, int> PoolRuntimeIds { get; }
    }

IPoolStatus

    public interface IPoolStatus
    {
        bool IsEnabled();
        bool IsDead();
        int GetPriority();
    }

OnlineServiceType

    public enum OnlineServiceType
    {
        None = 0,
        Betarigs = 1, // No longer active
        TradeMyBit = 2, // No longer active
        NiceHash = 4,
        MiningRigRentals = 8,
        WafflePool = 16, // No longer active
        WestHash = 32, // No longer active
        LtcRabbit = 64, 
        LeaseRig = 128, // No longer active
        TradeMyBitSinglePool = 256, // No longer active
        Yaamp = 512, // No longer active
        Hamsterpool = 1024, // No longer active
        WePayBtc = 1024 * 2, // No longer active
        Zpool = 1024 * 4,
        All = NiceHash + MiningRigRentals + WafflePool + WestHash + Yaamp + Hamsterpool + WePayBtc + Zpool
    }


Back to help section