-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79fbf5f
commit 553f687
Showing
29 changed files
with
1,939 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#Detect all examples targets | ||
FILE(GLOB EXAMPLE_SOURCES "*_example.c") | ||
MESSAGE(STATUS "Example sources: ${EXAMPLE_SOURCES}") | ||
FILE (GLOB_RECURSE PROVIDERS_HEADER_FILES providers/*.h include/*.inl) | ||
FILE (GLOB_RECURSE PROVIDERS_SOURCE_FILES providers/*.c) | ||
|
||
FIND_PACKAGE(CURL REQUIRED) | ||
|
||
FOREACH(EXAMPLE_SOURCE ${EXAMPLE_SOURCES}) | ||
GET_FILENAME_COMPONENT(EXAMPLE_TARGET_NAME ${EXAMPLE_SOURCE} NAME_WE) # Extracts the filename without extension | ||
|
||
# Define executable target for the example | ||
ADD_EXECUTABLE(${EXAMPLE_TARGET_NAME} ${EXAMPLE_SOURCE} ${PROVIDERS_SOURCE_FILES}) | ||
MESSAGE(STATUS "Example source: ${EXAMPLE_TARGET_NAME}") | ||
|
||
# Include directories | ||
TARGET_INCLUDE_DIRECTORIES(${EXAMPLE_TARGET_NAME} PRIVATE ${CARDANO_C_INCLUDE_DIR}) | ||
TARGET_INCLUDE_DIRECTORIES(${EXAMPLE_TARGET_NAME} PRIVATE ${PROVIDERS_HEADER_FILES}) | ||
TARGET_LINK_LIBRARIES(${EXAMPLE_TARGET_NAME} PRIVATE cardano-c ${CURL_LIBRARIES}) | ||
ENDFOREACH() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "providers/provider_factory.h" | ||
#include <cardano/cardano.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int | ||
main() | ||
{ | ||
const char* api_key = "preprodeMB9jfka6qXsluxEhPLhKczRdaC5QKab"; | ||
printf("libcardano-c %s\n", cardano_get_lib_version()); | ||
|
||
cardano_provider_t* provider = NULL; | ||
|
||
cardano_error_t result = create_blockfrost_provider(CARDANO_NETWORK_MAGIC_PREPROD, api_key, strlen(api_key), &provider); | ||
|
||
if (result != CARDANO_SUCCESS) | ||
{ | ||
printf("Failed to create blockfrost provider: %s\n", cardano_provider_get_last_error(provider)); | ||
return 1; | ||
} | ||
|
||
printf("Provider name: %s\n", cardano_provider_get_name(provider)); | ||
|
||
cardano_protocol_parameters_t* parameters = NULL; | ||
|
||
result = cardano_provider_get_parameters(provider, ¶meters); | ||
|
||
if (result != CARDANO_SUCCESS) | ||
{ | ||
printf("Failed to get protocol parameters:\n%s: %s\n", cardano_error_to_string(result), cardano_provider_get_last_error(provider)); | ||
return 1; | ||
} | ||
|
||
printf("Protocol parameters:\n"); | ||
printf(" - ADA per utxo byte: %zu\n", cardano_protocol_parameters_get_ada_per_utxo_byte(parameters)); | ||
|
||
cardano_protocol_parameters_unref(¶meters); | ||
cardano_provider_unref(&provider); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.