Providers

Instantiate the Vertices library and configure the provider.

Create

/// Initialize Vertices SDK
/// \param config Pass the configuration such as providers and user-defined event handler
/// \return
ret_code_t
vertices_new(vertex_t *config);

Parameters

  • config pointer to config.

typedef struct
{
    provider_info_t *provider;
    ret_code_t (*vertices_evt_handler)(vtc_evt_t *evt);
} vertex_t;

typedef struct
{
    char *url;
    short port;
    char *header;
    const char *cert_pem;
} provider_info_t;

Here is an example of configuration for a node (algod) running locally on my machine. Comments give a configuration with Algoexplorer's API.

static provider_info_t providers =
    {
        .url = (char *) "localhost", // or "https://api.testnet.algoexplorer.io"
        .port = 8080, // 0
        .header = (char *) "X-Algo-API-Token:<api-token>" // ""
        .cert_pem = algoexplorer_root_cert_pem_start
    };
static vertex_t m_vertex = {
    .provider = &providers,
    .vertices_evt_handler = vertices_evt_handler
};

Return codes

  • VTC_SUCCESS on success

  • VTC_ERROR_INTERNAL if HTTP client cannot be initialized

Health

ret_code_t
vertices_ping(void);

Return codes

  • VTC_SUCCESS when API can be reached

  • VTC_HTTP_ERROR when an error occurs

Version

ret_code_t
vertices_version(provider_version_t *version);

Parameters

Pointer to provider_version_t structure that will be filled by the function.

Return codes

  • VTC_SUCCESS when version has been filled with node info

  • VTC_ERROR_OFFLINE when node cannot be reached to get info. Version could still be filled with information from a previous call.

Last updated