Providers
Instantiate the Vertices library and configure the provider.

Create

1
/// Initialize Vertices SDK
2
/// \param config Pass the configuration such as providers and user-defined event handler
3
/// \return
4
ret_code_t
5
vertices_new(vertex_t *config);
Copied!

Parameters

    config pointer to config.
1
typedef struct
2
{
3
provider_info_t *provider;
4
ret_code_t (*vertices_evt_handler)(vtc_evt_t *evt);
5
} vertex_t;
6
​
7
typedef struct
8
{
9
char *url;
10
short port;
11
char *header;
12
const char *cert_pem;
13
} provider_info_t;
Copied!
Here is an example of configuration for a node (algod) running locally on my machine. Comments give a configuration with Algoexplorer's API.
1
static provider_info_t providers =
2
{
3
.url = (char *) "localhost", // or "https://api.testnet.algoexplorer.io"
4
.port = 8080, // 0
5
.header = (char *) "X-Algo-API-Token:<api-token>" // ""
6
.cert_pem = algoexplorer_root_cert_pem_start
7
};
Copied!
1
static vertex_t m_vertex = {
2
.provider = &providers,
3
.vertices_evt_handler = vertices_evt_handler
4
};
Copied!

Return codes

    VTC_SUCCESS on success
    VTC_ERROR_INTERNAL if HTTP client cannot be initialized

Health

1
ret_code_t
2
vertices_ping(void);
Copied!

Return codes

    VTC_SUCCESS when API can be reached
    VTC_HTTP_ERROR when an error occurs

Version

1
ret_code_t
2
vertices_version(provider_version_t *version);
Copied!

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 modified 4mo ago