Skip to main content

Cosmos Chains

Unix Shell

Getting Started

A Unix shell can be used to directly query smart contracts deployed on any Cosmos chain. The GET request takes in:

  • LCD_ENDPOINT - LCD endpoint for the chain we are querying
  • CONTRACT_ADDRESS - Smart contract address that we are querying
  • HEX_ENCODED_JSON - Hex encoded json string for our query

_1
curl --location --request GET "{LCD_ENDPOINT}/wasm/contract/{CONTRACT_ADDRESS}/smart/{HEX_ENCODED_JSON}?encoding=hex"

Step 1

This example uses the Terra 2 LCD endpoint and the Assembly contract address associated with pisco-1 testnet.


_1
curl --location --request GET "https://pisco-lcd.terra.dev/wasm/contract/terra195m6n5xq4rkjy47fn5y3s08tfmj3ryknj55jqvgq2y55zul9myzsgy06hk/smart/{HEX_ENCODED_JSON}?encoding=hex"

Step 2

To fill the HEX_ENCODED_JSON variable, we first need to create the JSON containing our query. This example queries the Assembly contract's configuration.


_3
{
_3
"config": {}
_3
}

Step 3

Once you have your JSON object, you can encode your query using a Hex encoder.

The result gets inserted into our GET message.


_1
curl --location --request GET "https://pisco-lcd.terra.dev/wasm/contract/terra195m6n5xq4rkjy47fn5y3s08tfmj3ryknj55jqvgq2y55zul9myzsgy06hk/smart/7B0D0A2020202022636F6E666967223A207B7D0D0A7D?encoding=hex"

Step 4

Executing the query returns the current block height as well as an encoded JSON string containing our query response.


_6
{
_6
"height": "3394568",
_6
"result": {
_6
"smart": "eyJ4YXN0cm9fdG9rZW5fYWRkciI6InRlcnJhMWN0enRoa2MwbnpzZXBwcXRxbHdxOW1qd3k5Z3E4aHQyNTM0cnRjajN5cGxlcm0wNnNubXFmYzV1Y3IiLCJ2eGFzdHJvX3Rva2VuX2FkZHIiOm51bGwsImliY19jb250cm9sbGVyIjoidGVycmExOGthdzQ4dmFsNWQ5Y3k3OXhsMGs3a3EzeDZ5MDc3djBocTlnd2h3cDdjbmF3bjJtanIycWR3YTJ3MiIsImJ1aWxkZXJfdW5sb2NrX2FkZHIiOiJ0ZXJyYTF6cWZ2M2h5dG4zOGs2MGpoZnF2YWphMGo1Z3Z5cnBqZ2NzZHh0OHo2NWZnbmEzaHk5OTlzeHh0N2VnIiwicHJvcG9zYWxfdm90aW5nX3BlcmlvZCI6MjAwLCJwcm9wb3NhbF9lZmZlY3RpdmVfZGVsYXkiOjUwLCJwcm9wb3NhbF9leHBpcmF0aW9uX3BlcmlvZCI6NDAwLCJwcm9wb3NhbF9yZXF1aXJlZF9kZXBvc2l0IjoiMTAwMCIsInByb3Bvc2FsX3JlcXVpcmVkX3F1b3J1bSI6IjAuMDAxIiwicHJvcG9zYWxfcmVxdWlyZWRfdGhyZXNob2xkIjoiMC41MSIsIndoaXRlbGlzdGVkX2xpbmtzIjpbImh0dHBzOi8vZm9ydW0uYXN0cm9wb3J0LmZpLyIsImh0dHA6Ly9mb3J1bS5hc3Ryb3BvcnQuZmkvIiwiaHR0cHM6Ly9hc3Ryb3BvcnQuZmkvIiwiaHR0cDovL2FzdHJvcG9ydC5maS8iXX0="
_6
}
_6
}

Step 5

To decode the response, we use a Base64 decoder and input our raw query response.

The result is our final query response.


_18
{
_18
"xastro_token_addr": "terra1ctzthkc0nzseppqtqlwq9mjwy9gq8ht2534rtcj3yplerm06snmqfc5ucr",
_18
"vxastro_token_addr": null,
_18
"ibc_controller": "terra18kaw48val5d9cy79xl0k7kq3x6y077v0hq9gwhwp7cnawn2mjr2qdwa2w2",
_18
"builder_unlock_addr": "terra1zqfv3hytn38k60jhfqvaja0j5gvyrpjgcsdxt8z65fgna3hy999sxxt7eg",
_18
"proposal_voting_period": 200,
_18
"proposal_effective_delay": 50,
_18
"proposal_expiration_period": 400,
_18
"proposal_required_deposit": "1000", // testnet deposit amount
_18
"proposal_required_quorum": "0.001",
_18
"proposal_required_threshold": "0.51",
_18
"whitelisted_links": [
_18
"https://forum.astroport.fi/",
_18
"http://forum.astroport.fi/",
_18
"https://astroport.fi/",
_18
"http://astroport.fi/"
_18
]
_18
}

Getting Started

A Unix shell can be used to directly query smart contracts deployed on any Cosmos chain. The GET request takes in:

  • LCD_ENDPOINT - LCD endpoint for the chain we are querying
  • CONTRACT_ADDRESS - Smart contract address that we are querying
  • HEX_ENCODED_JSON - Hex encoded json string for our query

Step 1

This example uses the Terra 2 LCD endpoint and the Assembly contract address associated with pisco-1 testnet.

Step 2

To fill the HEX_ENCODED_JSON variable, we first need to create the JSON containing our query. This example queries the Assembly contract's configuration.

Step 3

Once you have your JSON object, you can encode your query using a Hex encoder.

The result gets inserted into our GET message.

Step 4

Executing the query returns the current block height as well as an encoded JSON string containing our query response.

Step 5

To decode the response, we use a Base64 decoder and input our raw query response.

The result is our final query response.


_1
curl --location --request GET "{LCD_ENDPOINT}/wasm/contract/{CONTRACT_ADDRESS}/smart/{HEX_ENCODED_JSON}?encoding=hex"