Skip to main content

Integration

HaloTrade smart contracts can be used externally and integrated onto your app with no overhead. In this section we will show all the available methods exposed by the core contacts.

If you want to see the contracts reference instead, you can go to the Contracts section where a full breakdown of the core contracts is explained in detail or you could check out the Github Repo.

All contracts are deployed in all Aura networks (Mainnet, Euphoria and Serenity). You can find the available deployment addresses and code IDs in the Contracts section as well.

API Integration

The API Intergration follows the structure of the CoinGecko Integration API Standards. The API endpoint details necessary for integrating cryptocurrency exchanges, total/circulating supply, and the NFT Marketplace on CoinGecko.

No.EndpointURI
1/pairshttps://api.halotrade.zone/api/cgk/pairs
2/tickershttps://api.halotrade.zone/api/cgk/tickers

Contracts Integration

On-chain interaction with the contracts can be easily done with the use of CosmJS, and it can also be done with any other preferred method for building and signing the transactions or queries and interacting directly with the LCD (Light Client Daemon). In this section we will show you how to interact with all the available methods of the deployed contracts with clear examples.

tip

A list of public nodes exposing LCDs, RPCs and gRPCs can be found on the official Aura Network Documentation. Do not use in production environments.

Requirements

To follow the interaction examples shown for the smart contracts you must have the following requirements installed:

The Aura LCD client exposes all the methods you will need to successfully integrate Aura onto your project without any extra work as it behaves as a REST server. You can explore the reference documentation for more details.

The general structure of a transaction is shown below. The transaction parameters in JSON form would be the value of "msg" in this example.

TxStructure
{
"body": {
"messages": [
{
"@type": "/cosmwasm.wasm.v1.MsgExecuteContract",
"sender": "aura1...",
"contract": "aura1...",
"msg": {
// the JSON encoded send arguments of your transaction
},
"funds": [] // funds to include [optional]
}
],
"memo": "",
"timeout_height": "0",
"extension_options": [],
"non_critical_extension_options": []
},
"auth_info": {
"signer_infos": [],
"fee": {
"amount": [
{
"denom": "uaura",
"amount": "200"
}
],
"gas_limit": "200000",
"payer": "",
"granter": ""
}
},
"signatures": []
}

To craft a transaction, you would need to populate the fields of the transaction in question (the content within "msg") and then proceed to having the transaction signed. So, a fully crafted transaction before signing would look like this:

ProvideLiquidity
{
"body": {
"messages": [
{
"@type": "/cosmwasm.wasm.v1.MsgExecuteContract",
"sender": "aura1...",
"contract": "aura1...",
"msg": {
"provide_liquidity": {
"assets": [
{
"info": {
"token": {
"contract_addr": "aura..."
}
},
"amount": 10000000000
},
{
"info": {
"native_token": {
"denom": "uaura"
}
},
"amount": 500000000
}
],
"slippage_tolerance": 5,
"receiver": "aura..."
} },
"funds": [] // funds to include [optional]
}
],
"memo": "",
"timeout_height": "0",
"extension_options": [],
"non_critical_extension_options": []
},
"auth_info": {
"signer_infos": [],
"fee": {
"amount": [
{
"denom": "uaura",
"amount": "200"
}
],
"gas_limit": "200000",
"payer": "",
"granter": ""
}
},
"signatures": []
}

To send wasm execute transactions to the LCD you must send the fully encoded and signed tx bytes and mode as the request body shown below to the Cosmos BroadcastTx endpoint on the LCD client.

{
"tx_bytes": "string",
"mode": "BROADCAST_MODE_UNSPECIFIED"
}

To query contracts, you can just send your query to the Wasm SmartContractState.

As for querying transactions, you can use the Cosmos GetTxsEvent endpoint on the same LCD client or you can also use Horoscope which can be easier to integrate on some cases and is as reliable as the LCD client itself.

info

For a full reference on the available methods, you can go to the Contracts section.

Factory

CosmJS

To interact with the Factorycontract using JS, you can see the following examples for the available methods.

const fs = require('fs/promises');
const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm-stargate");
const { DirectSecp256k1HdWallet } = require("@cosmjs/proto-signing");
const { GasPrice } = require("@cosmjs/stargate");

// config chain
const RPCEndpoint = "https://rpc..aura.network";
const prefix = "aura";
const denom = "uaura";

// ***************************
// SETUP INFORMATION FOR USERS
// ***************************
// connect deployer wallet to chain and get admin account
const deployerWallet = await DirectSecp256k1HdWallet.fromMnemonic(
(await readFile("./sample.mnemonic.key")).toString(),
{
prefix: prefix,
}
);
// config gas price
const gasPrice = GasPrice.fromString(`0.025${denom}`);
const deployerClient = await SigningCosmWasmClient.connectWithSigner(RPCEndpoint, deployerWallet, {gasPrice});
const deployerAccount = (await deployerWallet.getAccounts())[0];

// ********************
// INSTANTIATE CONTRACT
// ********************
// prepare instantiate message
const haloFactoryInstantiateMsg = {
"pair_code_id": pair_code_id,
"token_code_id": token_code_id,
}

// Execute instantiate contract
await deployerClient.instantiate(
deployerAccount.address,
Number(contract_code_id), // the code id of halo factory contract
haloFactoryInstantiateMsg,
"instantiation halo_factory contract",
"auto",
);

// print out transaction's info
console.log("TransactionHash: ", instantiateResponse.transactionHash);
console.log("ContractAddress: ", instantiateResponse.contractAddress);
console.log("GasWanted / GasUsed: ", instantiateResponse.gasUsed, " / ", instantiateResponse.gasWanted);

LCD Client

To use the available methods exposed by the Factory contract you can use this as reference:

{
"body": {
"messages": [
{
"@type": "/cosmwasm.wasm.v1.MsgInstantiateContract",
"sender": "aura1...",
"admin": "",
"code_id": "000",
"label": "factory",
"msg": {
{
"pair_code_id": 123,
"token_code_id": 123
}
},
"funds": [
{
"denom": "uaura",
"amount": "4000"
}
]
}
],
"memo": "",
"timeout_height": "0",
"extension_options": [],
"non_critical_extension_options": []
},
"auth_info": {
"signer_infos": [],
"fee": {
"amount": [
{
"denom": "uaura",
"amount": "200"
}
],
"gas_limit": "200000",
"payer": "",
"granter": ""
}
},
"signatures": []
}

Router

CosmJS

To interact with the Routercontract using JS, you can see the following examples for the available methods.

const fs = require('fs/promises');
const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm-stargate");
const { DirectSecp256k1HdWallet } = require("@cosmjs/proto-signing");
const { GasPrice } = require("@cosmjs/stargate");

// config chain
const RPCEndpoint = "https://rpc..aura.network";
const prefix = "aura";
const denom = "uaura";

// you must provide the address of the contract you want to execute here
const factoryContractAddress = "aura100000000000000000000000000000000000000000000000HaloFactory";

// ***************************
// SETUP INFORMATION FOR USERS
// ***************************
// connect deployer wallet to chain and get admin account
const deployerWallet = await DirectSecp256k1HdWallet.fromMnemonic(
(await readFile("./sample.mnemonic.key")).toString(),
{
prefix: prefix,
}
);
// config gas price
const gasPrice = GasPrice.fromString(`0.025${denom}`);
const deployerClient = await SigningCosmWasmClient.connectWithSigner(RPCEndpoint, deployerWallet, {gasPrice});
const deployerAccount = (await deployerWallet.getAccounts())[0];

// ********************
// INSTANTIATE CONTRACT
// ********************
// prepare instantiate message
const haloRouterInstantiateMsg = {
"halo_factory": factoryContractAddress,
}

// Execute instantiate contract
await deployerClient.instantiate(
deployerAccount.address,
Number(contract_code_id), // the code id of halo router contract
haloRouterInstantiateMsg,
"instantiation halo_router contract",
"auto",
);

// print out transaction's info
console.log("TransactionHash: ", instantiateResponse.transactionHash);
console.log("ContractAddress: ", instantiateResponse.contractAddress);
console.log("GasWanted / GasUsed: ", instantiateResponse.gasUsed, " / ", instantiateResponse.gasWanted);

LCD Client

To use the available methods exposed by the Router contract you can use this as reference:

{
"body": {
"messages": [
{
"@type": "/cosmwasm.wasm.v1.MsgInstantiateContract",
"sender": "aura1...",
"admin": "",
"code_id": "000",
"label": "factory",
"msg": {
"halo_factory": "aura1...", // The address of the factory contract
},
"funds": [
{
"denom": "uaura",
"amount": "4000"
}
]
}
],
"memo": "",
"timeout_height": "0",
"extension_options": [],
"non_critical_extension_options": []
},
"auth_info": {
"signer_infos": [],
"fee": {
"amount": [
{
"denom": "uaura",
"amount": "200"
}
],
"gas_limit": "200000",
"payer": "",
"granter": ""
}
},
"signatures": []
}

Pair

CosmJS

To interact with the Paircontract using JS, you can see the following examples for the available methods.

const fs = require('fs/promises');
const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm-stargate");
const { DirectSecp256k1HdWallet } = require("@cosmjs/proto-signing");
const { GasPrice } = require("@cosmjs/stargate");

// config chain
const RPCEndpoint = "https://rpc..aura.network";
const prefix = "aura";
const denom = "uaura";

// ***************************
// SETUP INFORMATION FOR USERS
// ***************************
// connect deployer wallet to chain and get admin account
const deployerWallet = await DirectSecp256k1HdWallet.fromMnemonic(
(await readFile("./sample.mnemonic.key")).toString(),
{
prefix: prefix,
}
);
// config gas price
const gasPrice = GasPrice.fromString(`0.025${denom}`);
const deployerClient = await SigningCosmWasmClient.connectWithSigner(RPCEndpoint, deployerWallet, {gasPrice});
const deployerAccount = (await deployerWallet.getAccounts())[0];

// ********************
// INSTANTIATE CONTRACT
// ********************
// prepare instantiate message
const haloPairInstantiateMsg = {
"asset_infos": [
{
"token": {
"contract_addr": "aura..."
}
},
{
"native_token": {
"denom": "uaura"
}
}
],
"token_code_id": 123,
"asset_decimals": [ 6, 6 ],
"requirements": {
"whitelist": [
"aura...",
"aura..."
],
"first_asset_minimum": 10000,
"second_asset_minimum": 20000
},
"commission_rate": "0.003",
"lp_token_info": {
"lp_token_name": "AURA_HALO_LP",
"lp_token_symbol": "AURA_HALO_LP",
},
}

// Execute instantiate contract
await deployerClient.instantiate(
deployerAccount.address,
Number(contract_code_id), // the code id of halo pair contract
haloFactoryInstantiateMsg,
"instantiation halo_pair contract",
"auto",
);

// print out transaction's info
console.log("TransactionHash: ", instantiateResponse.transactionHash);
console.log("ContractAddress: ", instantiateResponse.contractAddress);
console.log("GasWanted / GasUsed: ", instantiateResponse.gasUsed, " / ", instantiateResponse.gasWanted);

LCD Client

To use the available methods exposed by the Pair contract you can use this as reference:

{
"body": {
"messages": [
{
"@type": "/cosmwasm.wasm.v1.MsgInstantiateContract",
"sender": "aura1...",
"admin": "",
"code_id": "000",
"label": "factory",
"msg": {
"asset_infos": [
{
"token": {
"contract_addr": "aura..."
}
},
{
"native_token": {
"denom": "uaura"
}
}
],
"token_code_id": 123,
"asset_decimals": [ 6, 6 ],
"requirements": {
"whitelist": [
"aura...",
"aura..."
],
"first_asset_minimum": 10000,
"second_asset_minimum": 20000
},
"commission_rate": "0.003",
"lp_token_info": {
"lp_token_name": "AURA_HALO_LP",
"lp_token_symbol": "AURA_HALO_LP",
},
},
"funds": [
{
"denom": "uaura",
"amount": "4000"
}
]
}
],
"memo": "",
"timeout_height": "0",
"extension_options": [],
"non_critical_extension_options": []
},
"auth_info": {
"signer_infos": [],
"fee": {
"amount": [
{
"denom": "uaura",
"amount": "200"
}
],
"gas_limit": "200000",
"payer": "",
"granter": ""
}
},
"signatures": []
}

Where:

  • asset_infos is the list of assets in the pair (The pair can be token<->native, token-token or native-native).
  • token_code_id is the source code id of halo-token contract.
  • asset_decimals is the list of decimals of assets in the pair.
  • requirements is the whitelist wallet address list and requirements for providing liquidity for the first time.
  • commission_rate is the commission rate of the pair.
  • lp_token_info is the information of the LP token.