cosmostation / cosmosjs

:star: CosmosJS - Cosmos JavaScript Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hi I how can I test this in testnet?

zebpay-peswani opened this issue · comments

I've a testnet address cosmos199uttp2xjt90zl5t2unu289ghmt5yt536u2vkz can you please tell me what will be lcdUrl and chain-id?

Can I generate or derive addresses from a public key (HD wallet) using this library?

Thanks

I personally recommend running the testnet either on the local computer or on a server. Then run rest server (LCD). If you know the rest server url, you could connect.

Deploy your own testnet: https://hub.cosmos.network/master/gaia-tutorials/deploy-testnet.html
Setting up the rest server: https://hub.cosmos.network/master/resources/service-providers.html#setting-up-the-rest-server

Yes, you can generate derive address by HD path. You can modify this line(https://github.com/cosmostation/cosmosjs/blob/v0.6.4/example/cosmoshub.js#L8).
Ex. cosmos.setPath("m/44'/118'/0'/0/0") -> cosmos.setPath("m/44'/118'/0'/0/1")

Hi I did what you said I run a testnet and rest server

but when I query for my address it does not show any result.

curl http://localhost:1317/bank/balances/cosmos199uttp2xjt90zl5t2unu289ghmt5yt536u2vkz
{"height":"3366","result":[]}

here is the latest block

http://localhost:1317/blocks/latest

{
  "block_meta": {
    "block_id": {
      "hash": "2F2C90BF424D558BE0EC3EB494E4190C087A11019F855069278AC1233DCB5D1D",
      "parts": {
        "total": "1",
        "hash": "8003B99CF535F31920674FAF09DDD03B938184926043355E0D1916C65D90D36A"
      }
    },
    "header": {
      "version": {
        "block": "10",
        "app": "0"
      },
      "chain_id": "testing",
      "height": "3330",
      "time": "2020-07-15T17:18:03.579969233Z",
      "num_txs": "0",
      "total_txs": "0",
      "last_block_id": {
        "hash": "0038B9BF3E2F50EE2D2B26866C565DB50A55F3F29C9AA8332208CE12A89D0C6A",
        "parts": {
          "total": "1",
          "hash": "AFDD7BB65EB669DC5623E40C2DD7440A9ACF30D5F0153401EEE049DFED858F8E"
        }
      },
      "last_commit_hash": "E24DEEF97379D7955024F53CAFED08006A6C9DBB5F45065EF64A5A7858518B0E",
      "data_hash": "",
      "validators_hash": "C024FFEF7E84178E7537505209A40210A086B9B804C22D03174DBE0D66C44D61",
      "next_validators_hash": "C024FFEF7E84178E7537505209A40210A086B9B804C22D03174DBE0D66C44D61",
      "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F",
      "app_hash": "11C9E787FBC99D047FC81A18CA717B477CC6EA7373C2F98F5925EBE4CBBA6AC9",
      "last_results_hash": "",
      "evidence_hash": "",
      "proposer_address": "5BE3B6E810BA837AFCF43FD2D8FA72C93B9702ED"
    }
  },
  "block": {
    "header": {
      "version": {
        "block": "10",
        "app": "0"
      },
      "chain_id": "testing",
      "height": "3330",
      "time": "2020-07-15T17:18:03.579969233Z",
      "num_txs": "0",
      "total_txs": "0",
      "last_block_id": {
        "hash": "0038B9BF3E2F50EE2D2B26866C565DB50A55F3F29C9AA8332208CE12A89D0C6A",
        "parts": {
          "total": "1",
          "hash": "AFDD7BB65EB669DC5623E40C2DD7440A9ACF30D5F0153401EEE049DFED858F8E"
        }
      },
      "last_commit_hash": "E24DEEF97379D7955024F53CAFED08006A6C9DBB5F45065EF64A5A7858518B0E",
      "data_hash": "",
      "validators_hash": "C024FFEF7E84178E7537505209A40210A086B9B804C22D03174DBE0D66C44D61",
      "next_validators_hash": "C024FFEF7E84178E7537505209A40210A086B9B804C22D03174DBE0D66C44D61",
      "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F",
      "app_hash": "11C9E787FBC99D047FC81A18CA717B477CC6EA7373C2F98F5925EBE4CBBA6AC9",
      "last_results_hash": "",
      "evidence_hash": "",
      "proposer_address": "5BE3B6E810BA837AFCF43FD2D8FA72C93B9702ED"
    },
    "data": {
      "txs": null
    },
    "evidence": {
      "evidence": null
    },
    "last_commit": {
      "block_id": {
        "hash": "0038B9BF3E2F50EE2D2B26866C565DB50A55F3F29C9AA8332208CE12A89D0C6A",
        "parts": {
          "total": "1",
          "hash": "AFDD7BB65EB669DC5623E40C2DD7440A9ACF30D5F0153401EEE049DFED858F8E"
        }
      },
      "precommits": [
        {
          "type": 2,
          "height": "3329",
          "round": "0",
          "block_id": {
            "hash": "0038B9BF3E2F50EE2D2B26866C565DB50A55F3F29C9AA8332208CE12A89D0C6A",
            "parts": {
              "total": "1",
              "hash": "AFDD7BB65EB669DC5623E40C2DD7440A9ACF30D5F0153401EEE049DFED858F8E"
            }
          },
          "timestamp": "2020-07-15T17:18:03.579969233Z",
          "validator_address": "5BE3B6E810BA837AFCF43FD2D8FA72C93B9702ED",
          "validator_index": "0",
          "signature": "Le8hWAXJEw/TcWTBTbbf+npdvw06sp6e7w2fm1/V5+/rAZ/k1JeWlCgwfZ1EdxoCXr/E8ri2BsYTjuHyGWDxCg=="
        }
      ]
    }
  }
}

is the testnet need to sync?

curl http://localhost:1317/syncing

{"syncing":false}

it shows syncing false