# Initialize the Blockchain
In this chapter you create the basic blockchain module for the interchain exchange app. You scaffold the blockchain, the module, the transaction, the IBC packets and messages. In the later chapters you integrate more code into each of the transaction handlers.
# Install Starport
This tutorial uses Starport (opens new window) v0.16.2 The Starport tool is the easiest way to build a blockchain.
/usr/local/bin, run the following command:
You can also use Starport v0.16.2 in a browser-based IDE (opens new window), but this tutorial assumes you are using a local Starport installation. For more installation options, see install Starport (opens new window).
# Create the Blockchain
Scaffold a new blockchain called
A new directory named interchange is created. This directory contains a working blockchain app. Create a new IBC module next.
# Create the Module
Scaffold a module inside your blockchain named
ibcdex with IBC capabilities.
The ibcdex module contains the logic for creating and maintaining order books and routing them through IBC to the second blockchain.
# Create the Transaction Types
To scaffold two types with create, read, update, and delete (CRUD) actions use the Starport
The following commands create
buyOrderBook types that are indexed with an index in the store (like key-value stores).
The values are:
amountDenomrepresents which token will be sold and in which quantity
priceDenomthe token selling price
--module ibcdex flag specifies that the type should be scaffolded in the
# Create the IBC Packets
Create three packets for IBC:
- an order book pair
- a sell order
- a buy order
--ack flag defines field names and types of the acknowledgment returned after the packet has been received by the target chain. Value of
--ack is a comma-separated (no spaces) list of names with optional types appended after a colon.
# Cancel messages
Cancelling orders is done locally in the network, there is no packet to send.
message command to create a message to cancel a sell or buy order.
--desc flag lets you define a description of the CLI command that is used to broadcast a transaction with the message.
# Trace the Denom
The token denoms must have the same behavior as described in the
- An external token received from a chain has a unique
denom, reffered to as
- When a token is sent to a blockchain and then sent back and received, the chain can resolve the voucher and convert it back to the original token denomination.
Voucher tokens are represented as hashes, therefore you must store which original denomination is related to a voucher, you can do this with an indexed type.
voucher you store: the source port ID, source channel ID and the original denom
# Create the Configuration
Add two config files
venus.yml to test two blockchain networks with specific token for each.
Add the config files in the
The native denoms for Mars are
mcx, also known as
marscoin, and for Venus
vcx, also known as
mars.yml file with your content:
venus.yml file with your content:
Implement the code for the order book in the next chapter.