/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { BroadcastKMS } from '../models/BroadcastKMS'; import type { CallCeloReadSmartContractMethod } from '../models/CallCeloReadSmartContractMethod'; import type { CallCeloSmartContractMethod } from '../models/CallCeloSmartContractMethod'; import type { CallCeloSmartContractMethodKMS } from '../models/CallCeloSmartContractMethodKMS'; import type { CeloBlock } from '../models/CeloBlock'; import type { CeloTx } from '../models/CeloTx'; import type { Data } from '../models/Data'; import type { PrivKey } from '../models/PrivKey'; import type { PrivKeyRequest } from '../models/PrivKeyRequest'; import type { SignatureId } from '../models/SignatureId'; import type { TransactionHash } from '../models/TransactionHash'; import type { TransferCeloBlockchain } from '../models/TransferCeloBlockchain'; import type { TransferCeloBlockchainKMS } from '../models/TransferCeloBlockchainKMS'; import type { Wallet } from '../models/Wallet'; import type { CancelablePromise } from '../core/CancelablePromise'; import { request as __request } from '../core/request'; export class CeloService { /** * Generate Celo wallet *

1 credit per API call

*

Tatum supports BIP44 HD wallets. It is very convenient and secure, since it can generate 2^31 addresses from 1 mnemonic phrase. Mnemonic phrase consists of 24 special words in defined order and can restore access to all generated addresses and private keys.
Each address is identified by 3 main values:

Tatum follows BIP44 specification and generates for Celo wallet with derivation path m'/44'/52752'/0'/0. More about BIP44 HD wallets can be found here - https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki. * Generate BIP44 compatible Celo wallet.

* * @param mnemonic Mnemonic to use for generation of extended public and private keys. * @returns Wallet OK * @throws ApiError */ public static celoGenerateWallet( mnemonic?: string, ): CancelablePromise { return __request({ method: 'GET', path: `/v3/celo/wallet`, query: { 'mnemonic': mnemonic, }, errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 403: `Forbidden. The request is authenticated, but it is not possible to required perform operation due to logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Generate Celo account address from Extended public key *

1 credit per API call

*

Generate Celo account deposit address from Extended public key. Deposit address is generated for the specific index - each extended public key can generate * up to 2^31 addresses starting from index 0 until 2^31.

* * @param xpub Extended public key of wallet. * @param index Derivation index of desired address to be generated. * @returns any OK * @throws ApiError */ public static celoGenerateAddress( xpub: string, index: number, ): CancelablePromise<{ /** * Celo address */ address?: string; }> { return __request({ method: 'GET', path: `/v3/celo/address/${xpub}/${index}`, errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Generate Celo private key *

1 credit per API call

*

Generate private key of address from mnemonic for given derivation path index. Private key is generated for the specific index - each mnemonic * can generate up to 2^31 private keys starting from index 0 until 2^31.

* * @param requestBody * @returns PrivKey OK * @throws ApiError */ public static celoGenerateAddressPrivateKey( requestBody: PrivKeyRequest, ): CancelablePromise { return __request({ method: 'POST', path: `/v3/celo/wallet/priv`, body: requestBody, mediaType: 'application/json', errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * @deprecated * Web3 HTTP driver *

2 credits per API call

*

This endpoint is deprecated. Use the HTTP-based JSON RPC driver instead.


*

Use this endpoint URL as a http-based web3 driver to connect directly to the Celo node provided by Tatum. * To learn more about Celo Web3, visit the Celo developer's guide.

* * @param xApiKey Tatum X-API-Key used for authorization. * @param requestBody * @returns any OK * @throws ApiError */ public static celoWeb3Driver( xApiKey: string, requestBody: any, ): CancelablePromise { return __request({ method: 'POST', path: `/v3/celo/web3/${xApiKey}`, body: requestBody, mediaType: 'application/json', errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Get current block number *

1 credit per API call

*

Get Celo current block number. This is the number of the latest block in the blockchain.

* * @returns number OK * @throws ApiError */ public static celoGetCurrentBlock(): CancelablePromise { return __request({ method: 'GET', path: `/v3/celo/block/current`, errors: { 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Get Celo block by hash *

1 credit per API call

*

Get Celo block by block hash or block number.

* * @param hash Block hash or block number * @returns CeloBlock OK * @throws ApiError */ public static celoGetBlock( hash: string, ): CancelablePromise { return __request({ method: 'GET', path: `/v3/celo/block/${hash}`, errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Get Celo Account balance *

1 credit per API call

*

Get Celo account balance in ETH. This method does not prints any balance of the ERC20 or ERC721 tokens on the account.

* * @param address Account address you want to get balance of * @returns any OK * @throws ApiError */ public static celoGetBalance( address: string, ): CancelablePromise<{ /** * Balance of Celo */ celo?: string; /** * Balance of cUSD */ cUsd?: string; /** * Balance of cEUR */ cEur?: string; }> { return __request({ method: 'GET', path: `/v3/celo/account/balance/${address}`, errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Get Celo transactions by address *

1 credit per API call

*

Get Celo transactions by address. This includes incoming and outgoing transactions for the address.

* * @param address Account address you want to get balance of * @param pageSize Max number of items per page is 50. * @param offset Offset to obtain next page of the data. * @param from Transactions from this block onwords will be included. * @param to Transactions up to this block will be included. * @param sort Sorting of the data. ASC - oldest first, DESC - newest first. * @returns CeloTx OK * @throws ApiError */ public static celoGetTransactionByAddress( address: string, pageSize: number, offset?: number, from?: number, to?: number, sort: 'ASC' | 'DESC' = 'DESC', ): CancelablePromise> { return __request({ method: 'GET', path: `/v3/celo/account/transaction/${address}`, query: { 'pageSize': pageSize, 'offset': offset, 'from': from, 'to': to, 'sort': sort, }, errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Get Celo Transaction *

2 credits per API call

*

Get Celo transaction by transaction hash.

* * @param hash Transaction hash * @returns CeloTx OK * @throws ApiError */ public static celoGetTransaction( hash: string, ): CancelablePromise { return __request({ method: 'GET', path: `/v3/celo/transaction/${hash}`, errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 403: `Forbidden. The request is authenticated, but it is not possible to required perform operation due to logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Get count of outgoing Celo transactions *

1 credit per API call

*

Get a number of outgoing Celo transactions for the address. When a transaction is sent, there can be multiple outgoing transactions, * which are not yet processed by the blockchain. To distinguish between them, there is a counter called a nonce, which represents * the order of the transaction in the list of outgoing transactions.

* * @param address address * @returns number OK * @throws ApiError */ public static celoGetTransactionCount( address: string, ): CancelablePromise { return __request({ method: 'GET', path: `/v3/celo/transaction/count/${address}`, errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Send Celo / ERC20 from account to account *

2 credits per API call

*

Send Celo, cUSD or Tatum supported ERC20 token from account to account.

*

Signing a transaction

*

When sending CELO, you are charged a fee for the transaction, and you must sign the transaction with the private key of the blockchain address from which the fee will be deducted.

*

Providing the private key in the API is not a secure way of signing transactions, because the private key can be stolen or exposed. Your private keys should never leave your security perimeter. You should use the private keys only for testing a solution you are building on the testnet of a blockchain.

*

For signing transactions on the mainnet, we strongly recommend that you use the Tatum Key Management System (KMS) and provide the signature ID instead of the private key in the API. Alternatively, you can use the Tatum JavaScript client.

* * @param requestBody * @returns any OK * @throws ApiError */ public static celoBlockchainTransfer( requestBody: (TransferCeloBlockchain | TransferCeloBlockchainKMS), ): CancelablePromise<(TransactionHash | SignatureId)> { return __request({ method: 'POST', path: `/v3/celo/transaction`, body: requestBody, mediaType: 'application/json', errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 403: `Forbidden. The request is authenticated, but it is not possible to required perform operation due to logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Invoke a method in a smart contract on Celo *

2 credits per API call

*

Invoke a method in an existing smart contract on Celo.

*

You can call a read-only or write method.

*
    *
  • For read-only methods, the output of the invoked method is returned.
  • *
  • For write methods, the ID of the associated transaction is returned.
  • *
*

Signing a transaction

*

When invoking a method in a smart contract, you are charged a fee for the transaction, and you must sign the transaction with the private key of the blockchain address from which the fee will be deducted.

*

Providing the private key in the API is not a secure way of signing transactions, because the private key can be stolen or exposed. Your private keys should never leave your security perimeter. You should use the private keys only for testing a solution you are building on the testnet of a blockchain.

*

For signing transactions on the mainnet, we strongly recommend that you use the Tatum Key Management System (KMS) and provide the signature ID instead of the private key in the API. Alternatively, you can use the Tatum JavaScript client.

* * @param requestBody * @returns any OK * @throws ApiError */ public static celoBlockchainSmartContractInvocation( requestBody: (CallCeloReadSmartContractMethod | CallCeloSmartContractMethod | CallCeloSmartContractMethodKMS), ): CancelablePromise<(TransactionHash | SignatureId | Data)> { return __request({ method: 'POST', path: `/v3/celo/smartcontract`, body: requestBody, mediaType: 'application/json', errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 403: `Forbidden. The request is authenticated, but it is not possible to required perform operation due to logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } /** * Broadcast signed Celo transaction *

2 credits per API call

*

Broadcast signed transaction to Celo blockchain. This method is used internally from Tatum KMS or Tatum client libraries. * It is possible to create custom signing mechanism and use this method only for broadcasting data to the blockchian.

* * @param requestBody * @returns TransactionHash OK * @throws ApiError */ public static celoBroadcast( requestBody: BroadcastKMS, ): CancelablePromise { return __request({ method: 'POST', path: `/v3/celo/broadcast`, body: requestBody, mediaType: 'application/json', errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 403: `Forbidden. The request is authenticated, but it is not possible to required perform operation due to logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server during the processing of the request.`, }, }); } }