Home Coins Terra (LUNA) Terra Smart Contract Kickstart. Introduction | by Daniel Hwang | Terra Money...

Terra Smart Contract Kickstart. Introduction | by Daniel Hwang | Terra Money | Sep, 2020


Terra, whose protocol enables the issuance of stablecoins pegged to various world currencies is built on the Cosmos SDK and is compatible with CosmWasm. In Terra’s next mainnet upgrade, CosmWasm will be integrated through the new WASM module, and users will be able to write their own smart contracts that leverage the Terra blockchain’s powerful primitives for building the next generation of financial dApps.

In this post, we will go over the new Contracts section in Terra Station, where users can upload, query, and interact with smart contracts. But before we jump into the new Smart Contract feature, let’s first take a look at what Terra Station is.

The Market page also displays more detailed information about Luna’s exchange rate history. You can adjust the time settings from 1 minute to a day to get the desired price chart view. The page also allows you to check the exchange rate of the various Terra stablecoins to Luna.

At the bottom of the page, you can select and enter the amount of tokens to swap, and the system will automatically calculate the estimated return value based on the current exchange rate.

Terra Station provides users a friendly alternative to the command line interface, allowing users to work with smart contracts through a graphical interface.

On Terra, there is a distinction between uploading a smart contract’s code and instantiating (creating) a contract. Unlike in Ethereum or other smart contract platforms, these two steps are considered separate. Uploading a smart contract’s code saves it onto the blockchain and returns a code ID, which can be used to create multiple smart contracts. This promotes efficient code reuse and increases confidence as only a small set of vetted and audited archetypal contracts are needed for a majority of use cases. For instance, people can easily issue their own tokens by referring to an existing code ID for a CW20 (ERC20 analog) rather than writing their own implementation.

Users can upload their own smart contract code by clicking on the [Upload] button located in the top-right corner in the “Contracts” menu of Terra Station.

In order to upload code, you will need to provide several pieces of required information. The most important is the compiled WASM bytecode that contains the smart contract logic. You can also add additional information such as the name and description, as well as a URL address linking to a public GitHub repository containing the smart contract source code. This metadata will be recorded alongside the contract code and will allow other users to know what your smart contract does and how to use it. After the Smart Contract has successfully uploaded, you will receive a code ID corresponding to the newly registered code.

The “Coins” input field allows the user to provide the contract with its initial funds. This is optional, and is only necessary if the funds are required by the smart contract to power its operations. You will be able to send from your present balance any tokens desired, including Luna and all Terra stablecoins.

Interact

A HandleMsg is a JSON message that the smart contract parses and routes to its appropriate logic and allows the user to specify which function as well as which arguments to execute. Like the InitMsg, the HandleMsg has an expected format and schema specified by the smart contract’s code. Please refer to the specific smart contract’s relevant documentation and source code for understanding how to properly create a HandleMsg that corresponds to that smart contract’s desired operation.

Once you are done filling out the necessary inputs, Terra Station will format the interaction request into a MsgExecuteContract and generate a transaction for you to sign and broadcast.

Query

To get a better picture about Smart Contracts on Terra, please visit the official Terra Docs, where you’ll find a more in-depth developer guide with all the necessary information on getting started writing smart contracts for Terra.

In order to access LocalTerra from Terra Station, you must first setup LocalTerra using the guidelines in the LocalTerra Github repository.

You can configure Terra Station to use LocalTerra by clicking on the bottom-left corner of the application. LocalTerra comes with 10 pre-configured accounts with balances, which you can switch between easily via a dropdown menu that appears next to your username when LocalTerra is selected.

By default, following TCP socket ports will be bound. Please make sure that other applications are not using them, as it may interfere with the usage of LocalTerra.

Terrad RPC: 26657 (i.e. terracli <cmd> —node tcp://localhost:26657)
FCD: 3060 (http://localhost:3060/swagger/)
LCD: 1316

In order to access LocalTerra from Terra Station, you must first setup LocalTerra using the guidelines in the LocalTerra Github repository.

You can configure Terra Station to use LocalTerra by clicking on the bottom-left corner of the application. LocalTerra comes with 10 pre-configured accounts with balances, which you can switch between easily via a dropdown menu that appears next to your username when LocalTerra is selected.

By default, following TCP socket ports will be bound. Please make sure that other applications are not using them, as it may interfere with the usage of LocalTerra.

Terrad RPC: 26657 (i.e. terracli <cmd> —node tcp://localhost:26657)
FCD: 3060 (http://localhost:3060/swagger/)
LCD: 1316






Read the original article here

- Advertisement -
Mr Bitcointe
Mr Bitcointehttps://www.bitcointe.com/
“Fact You Need To Know About Cryptocurrency - The first Bitcoin purchase was for pizza.” ― Mohsin Jameel
474FansLike
76FollowersFollow
4,567FollowersFollow
5,261FollowersFollow
1,553FollowersFollow
2,230SubscribersSubscribe
USD - United States Dollar
EUR
1.19
GBP
1.30
CHF
1.11
NOK
0.11
JPY
0.01
CAD
0.76
AUD
0.71

Most Popular

bitcoin
Bitcoin (BTC) $ 13,243.76
ethereum
Ethereum (ETH) $ 414.67
ripple
XRP (XRP) $ 0.255892
tether
Tether (USDT) $ 0.999184
bitcoin-cash
Bitcoin Cash (BCH) $ 273.46
bitcoin-cash-sv
Bitcoin SV (BSV) $ 174.43
litecoin
Litecoin (LTC) $ 58.46
eos
EOS (EOS) $ 2.65
binancecoin
Binance Coin (BNB) $ 30.83
okb
OKB (OKB) $ 4.57
tezos
Tezos (XTZ) $ 2.22
leo-token
LEO Token (LEO) $ 1.24
cardano
Cardano (ADA) $ 0.108463
monero
Monero (XMR) $ 129.23
stellar
Stellar (XLM) $ 0.085197
chainlink
Chainlink (LINK) $ 12.72
huobi-token
Huobi Token (HT) $ 4.48
tron
TRON (TRX) $ 0.027179
usd-coin
USD Coin (USDC) $ 0.998402
dash
Dash (DASH) $ 73.39
neo
NEO (NEO) $ 18.38
iota
IOTA (MIOTA) $ 0.285683
nem
NEM (XEM) $ 0.105182
zcash
Zcash (ZEC) $ 64.23
maker
Maker (MKR) $ 597.52
paxos-standard
Paxos Standard (PAX) $ 0.997296
ethereum-classic
Ethereum Classic (ETC) $ 5.52
vechain
VeChain (VET) $ 0.012367
true-usd
TrueUSD (TUSD) $ 0.999327
ftx-token
FTX Token (FTT) $ 3.94
kucoin-shares
KuCoin Shares (KCS) $ 0.901397
waves
Waves (WAVES) $ 3.45