Skip to content

Instantly share code, notes, and snippets.

@zramsay
Last active November 10, 2023 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zramsay/6a794fb0cb90fad850e8f2eba972e8b3 to your computer and use it in GitHub Desktop.
Save zramsay/6a794fb0cb90fad850e8f2eba972e8b3 to your computer and use it in GitHub Desktop.
publish laconic records
  1. Install the laconic command-line tool:
npm config set @cerc-io:registry https://git.vdb.to/api/packages/cerc-io/npm/
yarn global add @cerc-io/laconic-registry-cli
  1. Verify installation:
laconic --version
0.1.0
  1. See the available commands and flags:
laconic cns
CNS tools

Commands:
  laconic cns account    Account operations.
  laconic cns auction    Auction operations.
  laconic cns authority  Name authority operations.
  laconic cns bond       Bonds operations.
  laconic cns name       Name operations.
  laconic cns record     Record operations.
  laconic cns status     Get CNS status.
  laconic cns tokens     Tokens operations.

Options:
      --version   Show version number                                  [boolean]
  -v, --verbose   Verbose output                      [boolean] [default: false]
  -c, --config    Config file path.             [string] [default: "config.yml"]
  -o, --output    Gives output in json format when specified.           [string]
      --user-key                                                        [string]
      --tx-key                                                          [string]
      --bond-id                                                         [string]
      --chain-id                                                        [string]
  -f, --filename
      --id                                                              [string]
      --address                                                         [string]
      --gas                                                             [string]
      --fees                                                            [string]
      --help      Show help                                            [boolean]
  1. Create a config.yml that looks like:
services:
  cns:
    restEndpoint: 'http://console.laconic.com:32785'
    gqlEndpoint: 'https://console.laconic.com/api'
    userKey: # see instructions below, then ask for tokens
    bondId: # can be filled in after you create a bond, otherwise use the flag
    chainId: laconic_9000-1
    gas: 350000
    fees: 200000aphoton
  1. Test that it can read from the chain:
laconic cns status
{
  "version": "0.3.0",
  "node": {
    "id": "f1048efa4e0710041766685ce7c88fc690c2b142",
    "network": "laconic_9000-1",
    "moniker": "localtestnet"
  },
  "sync": {
    "latest_block_hash": "FEEC21BE0625B75C91BF107588C9EE53CCDECA345B0052CF3F1924982E78A8DE",
    "latest_block_height": "102911",
    "latest_block_time": "2023-11-08 19:13:38.276880728 +0000 UTC",
    "catching_up": false
  },
  "validator": {
    "address": "A47A5F33E7A97F0E704BB747137075E7F7C3781A",
    "voting_power": "1000000000000000"
  },
  "validators": [
    {
      "address": "A47A5F33E7A97F0E704BB747137075E7F7C3781A",
      "voting_power": "1000000000000000",
      "proposer_priority": "0"
    }
  ],
  "num_peers": "0",
  "peers": [],
  "disk_usage": "1.3G"
}
  1. Use laconicd to create a key:

e.g., docker exec -it $CONTAINER_ID sh of a running laconicd container, or install the binary from source

laconicd keys add bob
- address: ethm19ytlyleex7r70ljpjt8t83veuvk7p2angt4rzw
  name: bob
  pubkey: '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"Ai7FUGryPMs4Mj4TGk+13kExzrqi8XRbvmXZI1LyC9JH"}'
  type: local


**Important** write this mnemonic phrase in a safe place.
It is the only way to recover your account if you ever forget your password.

exact mint burst grab arena lonely top spy cotton coconut beauty chronic ugly delivery surge black summer prefer alien during mast save certain cable
  1. Export the key:
laconicd keys export bob --unarmored-hex --unsafe
8c9ef8b49fcb45938b58bd08ec8836362c169435027e44r3042553902332Gb0q
  1. Go back to Bob's config.yml and edit this line:
userKey: 8c9ef8b49fcb45938b58bd08ec8836362c169435027e44r3042553902332Gb0q
  1. Send tokens to the new key (bob)
laconicd tx bank send ethm1lz6rq4vlzld7zrp9zgladkx803fnketx5em97d ethm19ytlyleex7r70ljpjt8t83veuvk7p2angt4rzw 10000000aphoton --gas 200000 --fees 200000aphoton
auth_info:
  fee:
    amount:
    - amount: "200000"
      denom: aphoton
    gas_limit: "200000"
    granter: ""
    payer: ""
  signer_infos: []
  tip: null
body:
  extension_options: []
  memo: ""
  messages:
  - '@type': /cosmos.bank.v1beta1.MsgSend
    amount:
    - amount: "10000000"
      denom: aphoton
    from_address: ethm1lz6rq4vlzld7zrp9zgladkx803fnketx5em97d
    to_address: ethm19ytlyleex7r70ljpjt8t83veuvk7p2angt4rzw
  non_critical_extension_options: []
  timeout_height: "0"
signatures: []
confirm transaction before signing and broadcasting [y/N]: y
code: 0
codespace: ""
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: '[]'
timestamp: ""
tx: null
txhash: B9DF57F5EE13AC4440211F4499AA4EDD687723914D20E6478BE2A7B87365887B
  1. Bob can now publish records

a) first create a bond:

laconic cns bond create --type aphoton --quantity 1000000000
{"bondId":"dac589e1442a2f472eb3694cc761093cc02bf08e52aecce1e1693772b8366a85"}

add this bondId to the config.yml, see above in point 4

b) then create a sample record (e.g. demo.yml)

record:
  type: WebsiteRegistrationRecord
  url: 'https://todo-build-in-ci.iglootools.xyz'
  repo_registration_record_cid: QmVjYQ59z3fuKfYUV1aXhDR82JAKxdqB5JMPfUsHkJUkJq
  build_artifact_cid: https://ipfs.io/ipfs/QmN2yevgjC92gzGi2BY6Q2yBWmR6JNWQ9yscoPPyy1V2Hv
  tls_cert_cid: QmTAnmDMSnzqAN3yyXtFD4KpyATkeze62ZkbmXHjJ8xQW8
  version: 14.2.3

c) and publish it:

laconic cns record publish --filename demo.yml 
{
  "id": "bafyreibu5a7o6shjz5lpn72vnqhp7p5buyi4stm4vh76fgoq4jitd4g3aq"
}

d) view it at https://console.laconic.com

  1. All of this can be done in CI. Steps ahead of time should add/pin to IPFS and construct a useful record prior to publishing it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment