1
0
Fork 0
forked from lthn/blockchain
blockchain/utils/sdk/client/go/docs/BlockUtilsSdkClientGo.md
Snider 88d4357628
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages. 

### Highlights

* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00

8.6 KiB
Generated

\BlockUtilsSdkClientGo

All URIs are relative to http://127.0.0.1:36943

Method HTTP request Description
CreateBlockTemplate Post /block/template Create a block template for mining
GetBlock Get /block/{identifier} Get a block by its hash or height (ID)
GetBlocks Get /block Get one or more blocks, with optional pagination.
GetHeight Get /block/height Get the current blockchain height
SubmitBlock Post /block/submit Submit a new block to the network

CreateBlockTemplate

BlockTemplateModel CreateBlockTemplate(ctx).BlockTemplateRequestModel(blockTemplateRequestModel).Execute()

Create a block template for mining

Example

package main

import (
	"context"
	"fmt"
	"os"
	openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)

func main() {
	blockTemplateRequestModel := *openapiclient.NewBlockTemplateRequestModel() // BlockTemplateRequestModel | 

	configuration := openapiclient.NewConfiguration()
	apiClient := openapiclient.NewAPIClient(configuration)
	resp, r, err := apiClient.BlockUtilsSdkClientGo.CreateBlockTemplate(context.Background()).BlockTemplateRequestModel(blockTemplateRequestModel).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.CreateBlockTemplate``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `CreateBlockTemplate`: BlockTemplateModel
	fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.CreateBlockTemplate`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiCreateBlockTemplateRequest struct via the builder pattern

Name Type Description Notes
blockTemplateRequestModel BlockTemplateRequestModel

Return type

BlockTemplateModel

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetBlock

BlockDetailsModel GetBlock(ctx, identifier).Execute()

Get a block by its hash or height (ID)

Example

package main

import (
	"context"
	"fmt"
	"os"
	openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)

func main() {
	identifier := "identifier_example" // string | The hash (hex string) or height (integer) of the block to retrieve.

	configuration := openapiclient.NewConfiguration()
	apiClient := openapiclient.NewAPIClient(configuration)
	resp, r, err := apiClient.BlockUtilsSdkClientGo.GetBlock(context.Background(), identifier).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.GetBlock``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `GetBlock`: BlockDetailsModel
	fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.GetBlock`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
identifier string The hash (hex string) or height (integer) of the block to retrieve.

Other Parameters

Other parameters are passed through a pointer to a apiGetBlockRequest struct via the builder pattern

Name Type Description Notes

Return type

BlockDetailsModel

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetBlocks

[]BlockDetailsModel GetBlocks(ctx).Execute()

Get one or more blocks, with optional pagination.

Example

package main

import (
	"context"
	"fmt"
	"os"
	openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)

func main() {

	configuration := openapiclient.NewConfiguration()
	apiClient := openapiclient.NewAPIClient(configuration)
	resp, r, err := apiClient.BlockUtilsSdkClientGo.GetBlocks(context.Background()).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.GetBlocks``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `GetBlocks`: []BlockDetailsModel
	fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.GetBlocks`: %v\n", resp)
}

Path Parameters

This endpoint does not need any parameter.

Other Parameters

Other parameters are passed through a pointer to a apiGetBlocksRequest struct via the builder pattern

Return type

[]BlockDetailsModel

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetHeight

HeightModel GetHeight(ctx).Execute()

Get the current blockchain height

Example

package main

import (
	"context"
	"fmt"
	"os"
	openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)

func main() {

	configuration := openapiclient.NewConfiguration()
	apiClient := openapiclient.NewAPIClient(configuration)
	resp, r, err := apiClient.BlockUtilsSdkClientGo.GetHeight(context.Background()).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.GetHeight``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `GetHeight`: HeightModel
	fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.GetHeight`: %v\n", resp)
}

Path Parameters

This endpoint does not need any parameter.

Other Parameters

Other parameters are passed through a pointer to a apiGetHeightRequest struct via the builder pattern

Return type

HeightModel

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

SubmitBlock

SubmitBlockResponseModel SubmitBlock(ctx).SubmitBlockRequestModel(submitBlockRequestModel).Execute()

Submit a new block to the network

Example

package main

import (
	"context"
	"fmt"
	"os"
	openapiclient "github.com/letheanVPN/blockchain/utils/sdk/client/go"
)

func main() {
	submitBlockRequestModel := *openapiclient.NewSubmitBlockRequestModel() // SubmitBlockRequestModel | 

	configuration := openapiclient.NewConfiguration()
	apiClient := openapiclient.NewAPIClient(configuration)
	resp, r, err := apiClient.BlockUtilsSdkClientGo.SubmitBlock(context.Background()).SubmitBlockRequestModel(submitBlockRequestModel).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `BlockUtilsSdkClientGo.SubmitBlock``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `SubmitBlock`: SubmitBlockResponseModel
	fmt.Fprintf(os.Stdout, "Response from `BlockUtilsSdkClientGo.SubmitBlock`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiSubmitBlockRequest struct via the builder pattern

Name Type Description Notes
submitBlockRequestModel SubmitBlockRequestModel

Return type

SubmitBlockResponseModel

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]