Carbon

Carbon is a cross-chain protocol that acts as a building block for DeFi.https://carbon.network/

Properties

boltX.tradehub.isBoltX

Note: Non-BoltX providers may also set this property to true.

  • true if the Tradehub provider belongs to Bolt-X

boltX.tradehub.isConnected

  • true if the provider can process RPC requests

  • In other words, true if there is an active communication between the extension and the Tradehub provider

boltX.tradehub.selectedAddress

  • The current Tradehub address that the BoltX wallet is on.

boltX.tradehub.network

  • The network type that the user is currently connected to

    • 'mainnet' | 'testnet' | 'devnet' | 'localhost'

boltX.tradehub.state

  • The state of the wallet provider

interface BaseProviderState {
  accounts: null | string[];
  isConnected: boolean;
  isUnlocked: boolean;
}

boltX.tradehub.TradehubEndpoints

  • The array of supported Tradehub public endpoints path for boltX.tradehub.request

Methods

boltX.tradehub.connect()

Requests user permission to connect the Zilliqa provider to the extension and requests user's Zilliqa address

  • Returns boolean indicating whether the wallet is connected

boltX.tradehub.sendTx({ type, value })

Submits a tx request for the given raw message onto the chain. Calls popup to get user's confirmation on the transaction.

This method is only for private endpoints and are messages that requires signing.

@see https://docs.switcheo.org/#/?id=private-endpoints

The switcheo documentation is currently outdated. For more details on the types of private endpoints and the required parameters, see tradehub's modules folder

  • Params:

    • type: The message type (e.g. order/MsgCreateOrder)

    • value: The message details

  • Returns the transaction response (TxResponse)

  • Throws an error when user rejects or transaction broadcast/signing failed

// tradehub-api-js/src/lib/tradehub/utils
interface TxResponse {
  height: string;
  txhash: string;
  raw_log: string;

  gas_wanted: string;
  gas_used: string;

  // only if tx succeeds
  logs: TxLog[];

  // only if tx fails
  code?: number;
  error?: string;
  codespace?: string;
}

boltX.tradehub.request({ path, params })

Submits an API request to the specified path, with the given params.

As these are public endpoints, user authentication is not required since the provider does not provide any additional user information or signing capability

@see https://docs.switcheo.org/#/?id=public-endpoints

The switcheo documentation is currently outdated. For more details on the types of public endpoints path and the required params, see tradehub's rest endpoints and the APIClient

  • Params:

    • type: the path to make a request to

    • value: object map for query parameters

  • Returns the transaction response (TxResponse)

Example usage:

const fees = await tradehub.request({ 
    path: '/get_txns_fees' 
})
// GET request to ${baseUrl}/get_txns_fees

const accounts = await tradehub.request({ 
    path: '/auth/accounts/swth1qfakeaddress' 
})
// GET request to ${baseUrl}/auth/accounts/swth1qfakeaddress

const tx = await tradehub.request({ 
    path: '/get_transaction', 
    queryParams: { hash: 12345 }
})
// GET request to ${baseUrl}/get_transaction?hash=12345

Events

The boltX.tradehubobject inherits the eventEmitter methods and emits the following events.

connected

  • Emitted when wallet is connected to Bolt-X extension

disconnected

  • Emitted when loses connection with Bolt-X extension

accountsChanged

  • Emits the new defaultAccount when account change is detected

networkChanged

  • Emits the new network type ('mainnet' | 'testnet' | 'devnet' | 'localhost') when network change is detected

Last updated