Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



23 Commits

Repository files navigation

ICONation logo



Quick start

#include "sdk/sdk.h"

using namespace ICONation::SDK;
using namespace ICONation::SDK::Blockchain;

int main (int argc, char **argv)
    // Create SDK-RPC client
    Client client ("");

    // Generate a new ICX wallet
    Wallet wallet = client.wallet_create();

    // Get your balance
    ICX::Loop balance = client.get_balance (wallet.get_address());

    // Get information about the latest block
    Block block = client.get_last_block();

    // Get information about the previous block
    Block previousBlock = client.get_block_by_height (block.height() - 1);

    // Get genesis block (block height = 0)
    GenesisBlock genesis = client.get_genesis_block();

    // Get total ICX supply amount
    ICX::Loop supply = client.get_total_supply();

    // Get the step price from the governance SCORE
    ICX::Loop stepPrice = client.get_step_price();

    // Transfer 5 ICX to hx0000000000000000000000000000000000000000 with stepLimit = 1000000 steps
    Transaction::Hash txhash = client.wallet_send_icx (
        wallet, "hx0000000000000000000000000000000000000000", 5 * ICX::TO_LOOP, 1000000);

    // Get transaction result of the last transaction
    TransactionResult result = client.get_transaction_result (txhash);

    // Call a Read-Only SCORE method with no param : 
    // Get the step price from the governance SCORE
    client.call_score_readonly (GOVERNANCE_SCORE_ADDRESS, "getStepPrice", {});

    // Call a Read-Only SCORE method with a param : 
    // Get the governance SCORE status
    client.call_score_readonly (GOVERNANCE_SCORE_ADDRESS, "getScoreStatus", {
        {"address", GOVERNANCE_SCORE_ADDRESS.to_string()}

    // Call a SCORE method that writes a transaction, with a step limit = 1000000 steps 
    client.wallet_call_score (wallet, "cx1352acdaadf247ed66baa915f6f66a1aa5ca5e9c", 
        "sign_up", {
            {"_child_address", "hx37b0ae56424d50f791500530c094903f3604f988"},
            {"_is_leader", "0x1"}
        }, 1000000

    // Deploy a SCORE using a zipfile, no params, step limit = 15 ICX 
    const ICX::Loop ICX_TO_STEP = ICX::TO_LOOP / client.get_step_price();
    std::vector <unsigned char> zipbytes = load_score_from_zipfile();
    Transaction::Hash hash = client.wallet_deploy (
        wallet, "cx0000000000000000000000000000000000000000",
        "application/zip", zipbytes, {}, 15 * ICX_TO_STEP

    // Check if a SCORE address hosts an IRC2 Token
    if (client.irc2_token_compliant ("cxf9148db4f8ec78823a50cb06c4fed83660af38d0")) {
        // Get MECA token information
        IRC2 mca = client.get_irc2_token ("cxf9148db4f8ec78823a50cb06c4fed83660af38d0");
        std::cout << "MCA total supply : " << mca.totalSupply() << std::endl;

    return 0;



Install build tools
$ sudo apt install make cmake git dh-autoconf
Build GTest
$ sudo apt install libgtest-dev
$ cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make
$ sudo cp *.a /usr/lib
Install libcurl
$ sudo apt install libcurl4-openssl-dev
Build mpir
$ sudo apt install yasm texinfo
$ git clone git:// mpir && cd mpir
$ ./ && ./configure --enable-cxx && make && sudo make install
$ sudo ln -s /usr/local/lib/* /usr/lib/ && sudo ln -s /usr/local/lib/* /usr/lib/
Build ICON SDK C++
$ # In the root directory
$ mkdir -p build && cd build
$ cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" -DCMAKE_ARCHITECTURE=x64 ../
$ make -j4
$ # Optionally, you can run the tests
$ cd ../release/x64/ && ./SDK_Tests


// Returns the last block information.
Blockchain::Block get_last_block (void);

// Returns the first block (genesis) information
Blockchain::GenesisBlock get_genesis_block (void);

// Returns block information by block height
Blockchain::Block get_block_by_height (const Blockchain::Block::Height &height);

// Returns block information by block hash
Blockchain::Block get_block_by_hash (const Blockchain::Block::Hash &hash);

// Returns the ICX balance of the given EOA or SCORE
Blockchain::ICX::Loop get_balance (const Blockchain::Address &address);

// Returns SCORE's external API list
nlohmann::json get_score_api (const Blockchain::Address &address);

// Calls SCORE's external function
// Does not make state transition (i.e., read-only).
nlohmann::json call_score_readonly (
    const Blockchain::Address &score, 
    const std::string &method, 
    const nlohmann::json &params = {}

// Returns total ICX coin supply that has been issued
Blockchain::ICX::Loop get_total_supply (void);

// Returns the transaction result requested by transaction hash
Blockchain::TransactionResult get_transaction_result (const Blockchain::Transaction::Hash &hash);

// Returns the transaction information requested by transaction hash
Blockchain::Transaction get_transaction_by_hash (const Blockchain::Transaction::Hash &hash);

// Transfer designated amount of ICX coins from a wallet to 'to' address
Blockchain::Transaction::Hash wallet_send_icx (
    const Blockchain::Wallet &wallet, 
    const Blockchain::Address &to, 
    const Blockchain::ICX::Loop &value,
    const Blockchain::ICX::Step &stepLimit,
    const int &nonce = 0

// Invoke a function of the SCORE in the 'score' address
Blockchain::Transaction::Hash wallet_call_score (
    const Blockchain::Wallet &wallet, 
    const Blockchain::Address &score,
    const std::string &method, const nlohmann::json &callParams,
    const Blockchain::ICX::Step &stepLimit, 
    const int &nonce = 0

// Install a new SCORE
Blockchain::Transaction::Hash wallet_deploy (
    const Blockchain::Wallet &wallet, 
    const Blockchain::Address &score,
    const std::string &contentType, 
    const std::vector<unsigned char> &content, 
    const nlohmann::json &callParams,
    const Blockchain::ICX::Step &stepLimit, 
    const int &nonce = 0

// IRC2 Token
// Check if the SCORE is compliant to IRC2 standards
bool irc2_token_compliant (const Blockchain::Address &score);
// Get information about an IRC2 token from a SCORE address
Blockchain::IRC2 get_irc2_token (const Blockchain::Address &score);

// Generate a new wallet
Blockchain::Wallet wallet_create (void);

// Load a wallet from a private key
Blockchain::Wallet wallet_load (const std::vector<unsigned char> &privateKey);
Blockchain::Wallet wallet_load (void *privateKeyBytes); // must be 32 bytes

// Load from keystore + password
Blockchain::Wallet wallet_load (
    const std::experimental::filesystem::path &keystore, 
    const std::string &password

// Get governance step price
Blockchain::ICX::Loop get_step_price (void);


No releases published


No packages published