LikeCoin
WebsiteDiscord GitHubSupport Us
English
English
  • Decentralize Publishing
  • Liker Land FAQ
  • 📕DePub
    • Decentralized Publishing
    • Liker Land Affiliation Program
      • Stripe Connect Payout Account Status
    • FAQ: Listing ebooks
    • List ebook
      • List PDF
    • Manage ebooks
      • Manage Book Collection
      • Latest Books
      • Bulk create QR codes and Short URLs
      • NFT Authz Grants
      • ebooks Replenishment
      • Modify ebook
      • Burn ebook
    • Purchase ebooks
      • Gift an ebook
      • Read ebooks
      • Import ebook to ereaders
        • Import ebook to Kobo
      • Other ebook Platforms
        • Terminus Press
        • Dung Foo Kei
        • BookForest
    • Register on Liker Land
      • Resetting password
      • Securing your Liker ID
      • Manage logged in devices
      • Edit Avatar and Name
      • Export Wallet Seed Words
      • What is Authcore?
    • Liker Land features
      • My Bookshelf
      • Notifications
      • Follow Creators
      • NFT Details
    • Transfer NFT
      • Batch send NFT to supporters
    • NFT Tools
    • Writing NFT FAQ
    • Publish Writing NFT
      • Email/Social
      • Keplr
      • Cosmostation
      • Cosmostation app
      • Matters
      • Liker.Social
      • illustBuy
      • Publish NFT with ISCN ID
    • Collect Writing NFT
      • Collect Writing NFT by LIKE on desktop
      • Collect Writing NFT by LIKE on mobile
      • One-Click Collect All Writing NFT
      • NFT Widget
      • Dynamic Pricing
      • NFT Marketplace
    • ISCN
      • What is the relationship between ISCN and IPFS?
      • What's the point of decentralization to the content ecosystem?
      • What type of content is supported by ISCN?
      • How to register an ISCN?
        • Email/Social
        • Keplr
        • Cosmostation
        • Cosmostation app
        • Matters
      • Register ISCN in batch
      • ISCN Browser
  • 🧭General Guides
    • On the News
      • Interviews and Features
      • Activities and Events
      • Mentions
      • Awards and Press Release
      • Recommendations
    • Community
      • #Community Call
      • #open-a-ticket
      • #faucet-testnet
      • #translate-wallet-prefix
      • LikeCoin Discord wallet
      • LIKE this message
    • Faucet
    • Wallet
      • LIKE pay
      • Keplr Browser Extension Wallet
        • Install Keplr and create a new wallet
          • Creating a new Keplr wallet via setting up a new recovery phrase
        • Keplr: Deposit and Send LikeCoin
        • Keplr + dao.like.co: Deposit, send, delegate, governance
        • Import wallet into Keplr
      • Keplr Mobile Wallet
        • How to install Keplr Mobile
        • Keplr Mobile: Deposit and Send LikeCoin
        • Import wallet into Keplr Mobile
      • Cosmostation Browser Extension Wallet
        • How to install Cosmostation Browser Extension
        • Cosmostation: Deposit and Send LikeCoin
        • Cosmostation + dao.like.co: Deposit, send, delegate, governance
        • Import wallet into Cosmostation
      • Cosmostation Mobile Wallet
        • How to install Cosmostation app
        • Cosmostation app: Deposit and Send LikeCoin
        • Import wallet into Cosmostation app
      • Leap Browser Extension Wallet
        • How to install Leap Browser Extension
        • Leap: Deposit and Send LikeCoin
        • Import wallet into Leap
      • Multisig
      • Wallet Address
      • Block Explorer
        • dao.like.co
        • Ping.pub
        • ATOMScan
      • Transaction Fee
      • New LikeCoin address prefix "like" - FAQ
      • Migrating from ERC-20
        • Upgrade LikeCoin ERC-20 to LikeCoin chain
        • LikeCoin Migration FAQ
    • Trade
      • Buy LikeCoin
      • Trade in Osmosis
      • Registering on DigiFinex
      • Trade in DigiFinex
      • Trade in MyEthShop
      • OTC
    • Liquidity
      • Osmosis
    • Stake
      • Delegation of LikeCoin
        • Delegate on desktop
        • Delegate on mobile
      • Undelegation of LikeCoin
        • Undelegate on desktop
        • Undelegate on mobile
      • Redelegation of LikeCoin
        • Redelegate on desktop
        • Redelegate on mobile
      • Where comes the LikeCoin rewards?
    • Governance
      • Community Call
      • LikeCoin chain
      • Liquid Democracy
      • Proposal Deposit
      • Direct Voting
        • Vote on desktop
        • Vote on mobile
      • Validator
        • Community Delegation
        • Validator Report
      • Proposals
    • DApp
      • LikeCoin app
        • Download LikeCoin app
        • Like - Reinventing the Like
        • Super Like - Tweeting to the Space
      • Liker ID
        • Register a Liker ID with Keplr
        • Connecting to my social account
      • Civic Liker
        • How to be a Civic Liker
        • Civic Liker Settings
        • FAQ
        • Creators Fund
        • Rationale and benefits
        • ​Civic Liker Web3 Report
      • Web3Press
      • LikeCoin button
        • Matters
        • Self-Host
          • ghost
          • Hexo
          • Hugo
          • Jekyll
          • mdBook
          • October CMS
          • Others
        • Blogging Platforms
          • inmediahk.net
          • illustBuy
          • Tipga
          • Blink
          • Blogspot
          • SteemCN
          • Wix / Weebly
          • Write.as
      • Content Creator Tools
        • Rewards
        • Monthly Achievement
        • Creators Fund Report
        • Reward Release Time
        • Cannot get reward?
      • Liker.Social
      • depub.space
        • Share tweet from From LikeCoin Discord to depub.space
        • Avatar for depub.space
      • Glossary
    • Branding
      • Design Materials
  • 🔬Developer Guide
    • Developer Introduction
    • LikeCoin chain API
      • Cosmos concepts
      • RPC/LCD API
        • ISCN API
        • NFT API
      • Setup local test node
      • Sample
        • Javascript
        • CosmJS (Recommended)
          • Keplr
          • ISCN
    • LikeCoin API
      • Calling API
      • Authetication
      • Reference
    • LikeCoin button
      • Widget & Iframe
      • Javascript CDN
      • Javascript SDK
    • LIKE pay
      • Web Widget
        • Reference
        • Webhook
    • ISCN
      • Specification
      • Chain API
      • JavaScript
        • iscn-js
        • iscn-message-types
      • Web Widget
        • ISCN Widget
          • ISCN Widget Reference
        • ISCN x Arweave Widget
          • ISCN-AR Widget Reference
      • Batch upload tool
      • ISCN Badge
      • ISCN IPFS plugin
    • LikeCoin NFT
      • LikeCoin NFT Module Spec
      • Metadata best practice
      • Writing NFT Spec
      • NFT Book Spec
      • NFT Portal
        • NFT Portal Reference
      • API Reference
    • likecoin-js
    • Ecosystem Statistics Badge
    • Raise Proposal
  • 👥Validator Guide
    • Technical Introduction
    • LikeCoin chain node
      • Setup a node (mainnet / public testnet)
        • Node Security
        • Setup on docker (Deprecated)
        • Setup on cloud platforms
        • Syncing from genesis
      • Node configuration
      • Command line interface
        • Useful commands
    • Become a validator
    • ChungKing++ Upgrade
    • Previous upgrades
      • ChungKing+ Upgrade
      • ChungKing Upgrade
      • StarFerry Upgrade
      • LaiChiKok Upgrade
      • FoTan Upgrade
        • Overview
        • Software Changes Overview
        • For other full node operators
        • Miscellaneous
    • Legacy endpoints
Powered by GitBook
On this page
  • Key and Address
  • Nodes and Endpoints
  • Chain ID
  • Account
  • Coins
  • Gas and Fees
  • Signature
Export as PDF
  1. Developer Guide
  2. LikeCoin chain API

Cosmos concepts

Concepts before accessing LikeCoin chain

PreviousLikeCoin chain APINextRPC/LCD API

Last updated 1 year ago

Key and Address

A private key is a 32 bytes (256 bits) binary.

The public key is derived from the private key according to secp256k1, in 33-bytes compressed format.

The Cosmos address is derived by the follows: address = ripemd160(sha256(pubKey)), encoded by bech32 with cosmos as prefix.

See for an example in JavaScript.

Nodes and Endpoints

To use the RPC APIs, we need a a lite client endpoint, which communicates with full nodes and verify the data from full nodes cryptographically (e.g. verifying Merkle proof).

For the FoTan mainnet:

Lite client endpoint: https://mainnet-node.like.co
Chain ID: likecoin-mainnet-2

Users can also run a full node and a lite client.

To setup a full node, please follow the instruction from this document:

(TODO: genesis URL and seed node)

Since the FoTan upgraed, the RESTful API is built into the liked command. You may modify .liked/config/app.toml for enabling the RESTful API if needed.

is an example Docker Compose config file for running the Taipei network full node and lite client. This hosts an RPC API endpoint on port 1317.\

Chain ID

Chain ID defines which chain / network you are operating on, to prevent replaying transactions on other networks.

Account

Each address corresponds to an account, which will have an account number and a sequence number.

Account Number

Account number is the account's number.

It is required in transactions, and could be queried from the /auth/accounts/{address} API.

Sequence

Sequence is the number of transactions the account has sent.

It is required in transactions to prevent transaction replays, similar to the concept of nonce in Ethereum.

It could be queried from the /auth/accounts/{address} API.

Coins

In Cosmos SDK, coins are represented as an object with 2 fields: amount and denom.

amount is the number of coins, while denom is the identifier of the coins.

In LikeCoin Chain, we only have one denom, which is nanolike. 1 LikeCoin = 1000000000nanolike.

When used in short forms (e.g. CLI parameters), the format of coins is ${amount}${denom}, e.g. 1000000000nanolike.

Gas and Fees

In Cosmos SDK, there is a concept called gas, which is similar to the concept of gas in Ethereum.

Each transaction must specify the maximum amount of gas it may consume.

If the transaction consumed more gas than provided during execution, it will fail.

Different from Ethereum, transactions specify their transaction fee directly, instead of specifying the gas price.

Nodes calculates the gas price by gas_price = fee / gas, and may reject transactions with gas price lower than their expectation.

We currently recommend validators to set the gas price to 10000.0nanolike as per proposal 74. For a typical coin sending transaction, it consumes about 44000 gas, which means the transaction fee is 0.044 LikeCoin.

Since the fee is specified in the transaction, it will not be refunded even if the actual gas consumption is less than the provided one.

Signature

The signing process is the standard secp256k1 signing.

The output bytes are organized in 64 bytes, which are the r and s values, 256 bites each, concatenated.

The signature is represented as object in transactions, which includes the public key and the signature bytes.

Example:

    {
        "signature": "yXcQvLVEHZMIzZijEgmcL5S7orusBURZoRjWuG1IpoItt5DhY8P9TUaxx31huxV200l6GcEbUlB/Y7jONuf3Bw==",
        "account_number": "21",
        "sequence": "0",
        "pub_key": {
            "type": "tendermint/PubKeySecp256k1",
            "value": "A0ZGrlBHMWtCMNAIbIrOxofwCxzZ0dxjT2yzWKwKmo//"
        }
    }

Sign Bytes

The sign bytes are the input to the secp256k1 signing algorithm.

Sign bytes are obtained by the following process:

  1. construct a standard transaction as follows:

{
  "fee": {
    "amount": [
      {
        "denom": "nanolike",
        "amount": "44000000"
      }
    ],
    "gas": "44000"
  },
  "msgs": [msgs...],
  "chain_id": "likechain-testnet-taipei-1",
  "account_number": "21",
  "sequence": "0",
  "memo": "",
}

Where msgs are the msg objects of the transactions. For a typical Send transaction, it will look like this:

{
  "fee": {
    "amount": [
      {
        "denom": "nanolike",
        "amount": "44000000"
      }
    ],
    "gas": "44000"
  },
  "msgs": [
    {
      "type": "cosmos-sdk/MsgSend",
      "value": {
        "from_address": "cosmos1mnyn7x24xj6vraxeeq56dfkxa009tvhgknhm04",
        "to_address": "cosmos1ca0zlqxjqv5gek5qxm602umtkmu88564hpyws4",
        "amount": [
          {
            "denom": "nanolike",
            "amount": "123456789"
          }
        ]
      }
    }
  ],
  "chain_id": "likechain-testnet-taipei-1",
  "account_number": "21",
  "sequence": "0",
  "memo": "",
}

Note that all numbers (e.g. amount, sequence, account_number) are encoded as string in the sign bytes.

  1. remove all fields with null value.

  2. reorganize the JSON message to remove all indents and newline formattings, and sort the fields by alphanumeric order.

The sign bytes of the example above after processing will look like this:

{"account_number":"21","chain_id":"likechain-testnet-taipei-1","fee":{"amount":[{"amount":"44000000","denom":"nanolike"}],"gas":"44000"},"memo":"","msgs":[{"type":"cosmos-sdk/MsgSend","value":{"amount":[{"amount":"123456789","denom":"nanolike"}],"from_address":"cosmos1mnyn7x24xj6vraxeeq56dfkxa009tvhgknhm04","to_address":"cosmos1ca0zlqxjqv5gek5qxm602umtkmu88564hpyws4"}}],"sequence":"0"}

🔬
here
https://github.com/likecoin/likecoin-chain/wiki/Setup-LikeCoin-chain-mainnet-node
Here