Categorygithub.com/alephium/go-sdk
repositorypackage
0.0.0-20230918123631-1e1c26825bb0
Repository: https://github.com/alephium/go-sdk.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Go API client for alephium

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 2.5.6
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import alephium "github.com/alephium/go-sdk"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), alephium.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), alephium.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), alephium.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), alephium.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to http://..

ClassMethodHTTP requestDescription
AddressesApiGetAddressesAddressBalanceGet /addresses/{address}/balanceGet the balance of an address
AddressesApiGetAddressesAddressGroupGet /addresses/{address}/groupGet the group of an address
AddressesApiGetAddressesAddressUtxosGet /addresses/{address}/utxosGet the UTXOs of an address
BlockflowApiGetBlockflowBlocksGet /blockflow/blocksList blocks on the given time interval
BlockflowApiGetBlockflowBlocksBlockHashGet /blockflow/blocks/{block_hash}Get a block with hash
BlockflowApiGetBlockflowBlocksWithEventsGet /blockflow/blocks-with-eventsList blocks with events on the given time interval
BlockflowApiGetBlockflowBlocksWithEventsBlockHashGet /blockflow/blocks-with-events/{block_hash}Get a block and events with hash
BlockflowApiGetBlockflowChainInfoGet /blockflow/chain-infoGet infos about the chain from the given groups
BlockflowApiGetBlockflowHashesGet /blockflow/hashesGet all block's hashes at given height for given groups
BlockflowApiGetBlockflowHeadersBlockHashGet /blockflow/headers/{block_hash}Get block header
BlockflowApiGetBlockflowIsBlockInMainChainGet /blockflow/is-block-in-main-chainCheck if the block is in main chain
ContractsApiGetContractsAddressStateGet /contracts/{address}/stateGet contract state
ContractsApiPostContractsCallContractPost /contracts/call-contractCall contract
ContractsApiPostContractsCompileContractPost /contracts/compile-contractCompile a smart contract
ContractsApiPostContractsCompileProjectPost /contracts/compile-projectCompile a project
ContractsApiPostContractsCompileScriptPost /contracts/compile-scriptCompile a script
ContractsApiPostContractsMulticallContractPost /contracts/multicall-contractMultiple call contract
ContractsApiPostContractsTestContractPost /contracts/test-contractTest contract
ContractsApiPostContractsUnsignedTxDeployContractPost /contracts/unsigned-tx/deploy-contractBuild an unsigned contract
ContractsApiPostContractsUnsignedTxExecuteScriptPost /contracts/unsigned-tx/execute-scriptBuild an unsigned script
EventsApiGetEventsBlockHashBlockhashGet /events/block-hash/{blockHash}Get contract events for a block
EventsApiGetEventsContractContractaddressGet /events/contract/{contractAddress}Get events for a contract within a counter range
EventsApiGetEventsContractContractaddressCurrentCountGet /events/contract/{contractAddress}/current-countGet current value of the events counter for a contract
EventsApiGetEventsTxIdTxidGet /events/tx-id/{txId}Get contract events for a transaction
InfosApiGetInfosChainParamsGet /infos/chain-paramsGet key params about your blockchain
InfosApiGetInfosCurrentDifficultyGet /infos/current-difficultyGet the average difficulty of the latest blocks from all shards
InfosApiGetInfosCurrentHashrateGet /infos/current-hashrateGet average hashrate from `now - timespan(millis)` to `now`
InfosApiGetInfosDiscoveredNeighborsGet /infos/discovered-neighborsGet discovered neighbors
InfosApiGetInfosHistoryHashrateGet /infos/history-hashrateGet history average hashrate on the given time interval
InfosApiGetInfosInterCliquePeerInfoGet /infos/inter-clique-peer-infoGet infos about the inter cliques
InfosApiGetInfosMisbehaviorsGet /infos/misbehaviorsGet the misbehaviors of peers
InfosApiGetInfosNodeGet /infos/nodeGet info about that node
InfosApiGetInfosSelfCliqueGet /infos/self-cliqueGet info about your own clique
InfosApiGetInfosUnreachableGet /infos/unreachableGet the unreachable brokers
InfosApiGetInfosVersionGet /infos/versionGet version about that node
InfosApiPostInfosDiscoveryPost /infos/discoverySet brokers to be unreachable/reachable
InfosApiPostInfosMisbehaviorsPost /infos/misbehaviorsBan/Unban given peers
MempoolApiDeleteMempoolTransactionsDelete /mempool/transactionsRemove all transactions from mempool
MempoolApiGetMempoolTransactionsGet /mempool/transactionsList mempool transactions
MempoolApiPutMempoolTransactionsRebroadcastPut /mempool/transactions/rebroadcastRebroadcase a mempool transaction to the network
MempoolApiPutMempoolTransactionsValidatePut /mempool/transactions/validateValidate all mempool transactions and remove invalid ones
MinersApiGetMinersAddressesGet /miners/addressesList miner's addresses
MinersApiGetWalletsWalletNameMinerAddressesGet /wallets/{wallet_name}/miner-addressesList all miner addresses per group
MinersApiPostMinersCpuMiningPost /miners/cpu-miningExecute an action on CPU miner. !!! for test only !!!
MinersApiPostMinersCpuMiningMineOneBlockPost /miners/cpu-mining/mine-one-blockMine a block on CPU miner. !!! for test only !!!
MinersApiPostWalletsWalletNameDeriveNextMinerAddressesPost /wallets/{wallet_name}/derive-next-miner-addressesDerive your next miner addresses for each group
MinersApiPutMinersAddressesPut /miners/addressesUpdate miner's addresses, but better to use user.conf instead
MultiSignatureApiPostMultisigAddressPost /multisig/addressCreate the multisig address and unlock script
MultiSignatureApiPostMultisigBuildPost /multisig/buildBuild a multisig unsigned transaction
MultiSignatureApiPostMultisigSubmitPost /multisig/submitSubmit a multi-signed transaction
MultiSignatureApiPostMultisigSweepPost /multisig/sweepSweep all unlocked ALPH and token balances of a multisig address to another address
TransactionsApiGetTransactionsDetailsTxidGet /transactions/details/{txId}Get transaction details
TransactionsApiGetTransactionsStatusGet /transactions/statusGet tx status
TransactionsApiPostTransactionsBuildPost /transactions/buildBuild an unsigned transaction to a number of recipients
TransactionsApiPostTransactionsDecodeUnsignedTxPost /transactions/decode-unsigned-txDecode an unsigned transaction
TransactionsApiPostTransactionsSubmitPost /transactions/submitSubmit a signed transaction
TransactionsApiPostTransactionsSweepAddressBuildPost /transactions/sweep-address/buildBuild unsigned transactions to send all unlocked ALPH and token balances of one address to another address
UtilsApiPostUtilsVerifySignaturePost /utils/verify-signatureVerify the SecP256K1 signature of some data
UtilsApiPutUtilsCheckHashIndexingPut /utils/check-hash-indexingCheck and repair the indexing of block hashes
WalletsApiDeleteWalletsWalletNameDelete /wallets/{wallet_name}Delete your wallet file (can be recovered with your mnemonic)
WalletsApiGetWalletsGet /walletsList available wallets
WalletsApiGetWalletsWalletNameGet /wallets/{wallet_name}Get wallet's status
WalletsApiGetWalletsWalletNameAddressesGet /wallets/{wallet_name}/addressesList all your wallet's addresses
WalletsApiGetWalletsWalletNameAddressesAddressGet /wallets/{wallet_name}/addresses/{address}Get address' info
WalletsApiGetWalletsWalletNameBalancesGet /wallets/{wallet_name}/balancesGet your total balance
WalletsApiPostWalletsPost /walletsCreate a new wallet
WalletsApiPostWalletsWalletNameChangeActiveAddressPost /wallets/{wallet_name}/change-active-addressChoose the active address
WalletsApiPostWalletsWalletNameDeriveNextAddressPost /wallets/{wallet_name}/derive-next-addressDerive your next address
WalletsApiPostWalletsWalletNameLockPost /wallets/{wallet_name}/lockLock your wallet
WalletsApiPostWalletsWalletNameRevealMnemonicPost /wallets/{wallet_name}/reveal-mnemonicReveal your mnemonic. !!! use it with caution !!!
WalletsApiPostWalletsWalletNameSignPost /wallets/{wallet_name}/signSign the given data and return back the signature
WalletsApiPostWalletsWalletNameSweepActiveAddressPost /wallets/{wallet_name}/sweep-active-addressTransfer all unlocked ALPH from the active address to another address
WalletsApiPostWalletsWalletNameSweepAllAddressesPost /wallets/{wallet_name}/sweep-all-addressesTransfer unlocked ALPH from all addresses (including all mining addresses if applicable) to another address
WalletsApiPostWalletsWalletNameTransferPost /wallets/{wallet_name}/transferTransfer ALPH from the active address
WalletsApiPostWalletsWalletNameUnlockPost /wallets/{wallet_name}/unlockUnlock your wallet
WalletsApiPutWalletsPut /walletsRestore a wallet from your mnemonic

Documentation For Models

Documentation For Authorization

Endpoints do not require authorization.

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author