### Start Cosmopark local environment using Bash Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/quickstart.mdx Launches the full Cosmopark setup with interconnected Neutron and Gaia via Docker Compose, then streams logs. The first run may take several minutes to initialize all components. ```bash # Start the local development environment make start-cosmopark # View logs docker-compose logs -f ``` -------------------------------- ### Clone and Build Neutron repository using Bash Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/quickstart.mdx Clones the Neutron source code, builds the neutrond binary, and verifies the installation. Requires a functional Go and Rust environment. Use this script after installing dependencies to get a working Neutron node. ```bash # Clone the Neutron repository git clone https://github.com/neutron-org/neutron.git cd neutron # Build the neutrond binary make install # Verify installation neutrond version ``` -------------------------------- ### Install Required Dependencies using Bash Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/quickstart.mdx Installs Rust and Go toolchains needed for Neutron development. The script configures the environment, adds the wasm target for Rust, and verifies installations. Adjust the Go version or paths as needed for different operating systems. ```bash # Install Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env rustup default stable rustup target add wasm32-unknown-unknown # Install Go wget https://go.dev/dl/go1.23.1.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.bashrc source ~/.bashrc # Verify installations rustc --version go version ``` -------------------------------- ### Setup Neutron Validator Node in Bash Source: https://context7.com/neutron-org/neutron-docs/llms.txt Configures and starts a Neutron validator node with state sync and oracle integration. Includes steps for binary installation, genesis configuration, peer setup, and validator creation. Requires wget, jq, and systemd. ```Bash #!/bin/bash # Install neutrond binary wget https://github.com/neutron-org/neutron/releases/download/v4.0.0/neutrond-linux-amd64 chmod +x neutrond-linux-amd64 sudo mv neutrond-linux-amd64 /usr/local/bin/neutrond # Initialize node MONIKER="my-validator" CHAIN_ID="neutron-1" neutrond init $MONIKER --chain-id $CHAIN_ID # Download genesis wget -O ~/.neutrond/config/genesis.json https://raw.githubusercontent.com/neutron-org/mainnet-assets/main/neutron-1/genesis.json # Configure seeds and peers SEEDS="e2c07e8e6e808fb36cca0fc580e31216772841df@p2p-kralum.neutron-1.neutron.org:26656" PEERS="# Get from https://docs.neutron.org/resources/peers" sed -i "s/^seeds *=.*/seeds = \"$SEEDS\"/" ~/.neutrond/config/config.toml sed -i "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" ~/.neutrond/config/config.toml # Configure state sync (optional, faster sync) TRUST_HEIGHT=10000000 TRUST_HASH="ABC123..." RPC_SERVERS="https://rpc-kralum.neutron-1.neutron.org:443,https://rpc-lb-kralum.neutron-1.neutron.org:443" sed -i "s/^enable *=.*/enable = true/" ~/.neutrond/config/config.toml sed -i "s/^rpc_servers *=.*/rpc_servers = \"$RPC_SERVERS\"/" ~/.neutrond/config/config.toml sed -i "s/^trust_height *=.*/trust_height = $TRUST_HEIGHT/" ~/.neutrond/config/config.toml sed -i "s/^trust_hash *=.*/trust_hash = \"$TRUST_HASH\"/" ~/.neutrond/config/config.toml # Start node neutrond start # Wait for sync (in another terminal) neutrond status | jq .SyncInfo.catching_up # Wait until returns "false" # Create validator (after node is synced) neutrond tx staking create-validator \ --amount=1000000untrn \ --pubkey=$(neutrond tendermint show-validator) \ --moniker="$MONIKER" \ --chain-id=$CHAIN_ID \ --commission-rate="0.05" \ --commission-max-rate="0.10" \ --commission-max-change-rate="0.01" \ --min-self-delegation="1" \ --gas="auto" \ --gas-adjustment=1.5 \ --gas-prices="0.025untrn" \ --from=my-key \ --yes # Setup Slinky oracle sidecar wget https://github.com/skip-mev/slinky/releases/download/v0.4.0/slinky-linux-amd64 chmod +x slinky-linux-amd64 sudo mv slinky-linux-amd64 /usr/local/bin/slinky # Configure oracle cat > ~/.slinky/config.json < Self { let chain_dir = TempDir::new().unwrap(); let rpc_port = 26657; let grpc_port = 9090; // Initialize chain Command::new("neutrond") .args(&[ "init", "test-node", "--chain-id", "neutron-testing-1", "--home", chain_dir.path().to_str().unwrap(), ]) .output() .expect("Failed to initialize chain"); // Add genesis account Command::new("neutrond") .args(&[ "add-genesis-account", "neutron1...", // Test account address "1000000000untrn", "--home", chain_dir.path().to_str().unwrap(), ]) .output() .expect("Failed to add genesis account"); Self { chain_dir, rpc_port, grpc_port, } } pub fn start(&self) { Command::new("neutrond") .args(&[ "start", "--home", self.chain_dir.path().to_str().unwrap(), "--rpc.laddr", &format!("tcp://0.0.0.0:{}", self.rpc_port), "--grpc.address", &format!("0.0.0.0:{}", self.grpc_port), ]) .spawn() .expect("Failed to start chain"); } } #[test] fn test_full_chain_contract_deployment() { let chain = LocalChain::new(); chain.start(); // Wait for chain to be ready std::thread::sleep(std::time::Duration::from_secs(5)); // Deploy contract using CLI let output = Command::new("neutrond") .args(&[ "tx", "wasm", "store", "artifacts/contract.wasm", "--from", "test-key", "--chain-id", "neutron-testing-1", "--node", &format!("http://localhost:{}", chain.rpc_port), "--yes", ]) .output() .expect("Failed to store contract"); assert!(output.status.success()); } ``` -------------------------------- ### Install Cosmovisor (Go) Source: https://github.com/neutron-org/neutron-docs/blob/main/resources/upgrades/v8.0.0-rc0.mdx This command installs Cosmovisor version 1.5.0 using Go. Cosmovisor is a tool that helps manage daemon upgrades, automating the process of switching binaries when a chain upgrade occurs. Ensure you have Go installed and configured. ```go go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0 ``` -------------------------------- ### Build and Optimize CosmWasm Contract - Bash Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/quickstart.mdx This snippet compiles the CosmWasm contract into a Wasm binary and optimizes it using Docker. It requires Rust and Docker to be installed. The input is the contract source code in the project directory, producing an optimized Wasm file in the artifacts folder. Limitations include Docker availability and potential resource usage for large contracts. ```bash # Compile the contract to Wasm cargo wasm # Optimize the Wasm binary (requires Docker) docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/rust-optimizer:0.12.13 ``` -------------------------------- ### Install SubQuery CLI (NPM) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/tutorials/indexers/subquery.mdx This snippet demonstrates how to install the SubQuery CLI using NPM. This is a necessary step before initializing a new SubQuery project and requires Node.js and NPM installed on your system. ```bash npm install -g @subql/cli ``` -------------------------------- ### Interchain Query Example - Rust Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/quickstart.mdx This Rust snippet demonstrates registering an interchain query (ICQ) to fetch data from another blockchain, such as account balances on Cosmos Hub. It depends on the Neutron SDK and CosmWasm framework. Inputs are the connection ID and query parameters, returning a response with the ICQ message. It assumes a valid connection and may incur fees for queries. ```rust // In your contract's execute function pub fn execute_icq_query( deps: DepsMut, env: Env, connection_id: String, ) -> Result { // Create an ICQ request to query account balance on Cosmos Hub let icq_msg = NeutronMsg::RegisterInterchainQuery { query_type: QueryType::KV { connection_id, keys: vec![Key { path: "bank/balances/cosmos1m9l358xunhhwds0568za49mzhvuxx9uxre5tgh".to_string(), key: Binary::from(b"denom_key"), }], }, transactions_filter: TransactionsFilterType::None, update_period: 10, }; // Return the message in the response Ok(Response::new() .add_message(icq_msg) .add_attribute("action", "register_icq")) } ``` -------------------------------- ### Query Module Parameters Example Response (JSON) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/interchain-queries/reference.mdx An example JSON response for the Params query, illustrating the structure and typical values for module parameters like query submission timeout, deposit, and limits. ```json { "params": { "query_submit_timeout": "1036800", "query_deposit": [ { "denom": "untrn", "amount": "1000000" } ], "tx_query_removal_limit": "10000", "max_kv_query_keys_count": "32", "max_transactions_filters": "32" } } ``` -------------------------------- ### Setup Multi-Chain Test Environment Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/tutorials/integration-tests/chain.mdx Configures a multi-chain testing environment with Neutron and Gaia chains connected via a relayer. Sets up interchain queries between chains and tests cross-chain functionality. Requires relayer configuration and network setup capabilities. ```go type MultiChainTestSuite struct { suite.Suite neutronChain *network.Network gaiaChain *network.Network relayer *relayer.Relayer } func (s *MultiChainTestSuite) SetupSuite() { // Setup Neutron chain neutronCfg := network.DefaultConfig() neutronCfg.NumValidators = 1 s.neutronChain, _ = network.New(s.T(), s.T().TempDir(), neutronCfg) // Setup Gaia chain gaiaCfg := network.DefaultConfig() gaiaCfg.NumValidators = 1 s.gaiaChain, _ = network.New(s.T(), s.T().TempDir(), gaiaCfg) // Setup relayer between chains s.relayer = s.setupRelayer() } func (s *MultiChainTestSuite) TestCrossChainQuery() { // Test ICQ functionality between chains neutronVal := s.neutronChain.Validators[0] gaiaVal := s.gaiaChain.Validators[0] // Register query on Neutron to query Gaia registerMsg := &icqtypes.MsgRegisterInterchainQuery{ ConnectionId: "connection-0", QueryType: "balance", Keys: [][]byte{balanceKey(gaiaVal.Address.String())}, UpdatePeriod: 1, Sender: neutronVal.Address.String(), } _, err := s.neutronChain.SendMsgs(neutronVal, registerMsg) s.Require().NoError(err) // Wait for query to be processed time.Sleep(10 * time.Second) // Verify query results queryClient := icqtypes.NewQueryClient(neutronVal.ClientCtx) resp, err := queryClient.QueryResult(context.Background(), &icqtypes.QueryResultRequest{ QueryId: 1, }) s.Require().NoError(err) s.Require().NotNil(resp.Result) } ``` -------------------------------- ### Install Rust Development Environment Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/sdk.mdx Sets up Rust toolchain and WebAssembly compilation target required for CosmWasm smart contract development on Neutron. The script downloads and installs Rust from the official source and configures it for blockchain development. ```bash # Install Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup default stable rustup target add wasm32-unknown-unknown ``` -------------------------------- ### Install Neutron Docs MCP Server via Git Source: https://github.com/neutron-org/neutron-docs/blob/main/mcp/mcp-server.txt Shell commands to clone the Neutron documentation repository and execute the installation script. Assumes git and bash are available in the environment. The second command changes to the mcp directory before running install-mcp.sh. ```shell git clone https://github.com/clydenewt/docs cd docs/mcp && ./install-mcp.sh ``` -------------------------------- ### Repository Setup Commands Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/sdk/neutron-template.mdx Clones the NeutronTemplate repository and initializes the frontend development environment. Sets up the project structure for both frontend and smart contract development ```bash git clone https://github.com/Deploydon/NeutronTemplate.git cd NeutronTemplate git clone https://github.com/Deploymn/NeutronTemplate.git cd NeutronTemplate git clone https://github.com/Deploymn/NeutronTemplate.git cd NeutronTemplate git clone https://github.com/Deploymn/NeutronTemplate.git cd NeutronTemplate ``` -------------------------------- ### Clone Required Repositories for Cosmopark using Bash Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/quickstart.mdx Sets up a workspace and clones all repositories needed for the Cosmopark multi-chain environment, including Neutron, integration tests, query relayer, and Gaia. Checks out a specific Gaia version. Run this before building Docker images. ```bash # Create a workspace directory mkdir neutron-dev && cd neutron-dev # Clone repositories in the same parent directory git clone -b main https://github.com/neutron-org/neutron.git git clone https://github.com/neutron-org/neutron-integration-tests.git git clone https://github.com/neutron-org/neutron-query-relayer.git git clone https://github.com/cosmos/gaia.git # Checkout specific Gaia version cd gaia git checkout v23.1.1 cd .. ``` -------------------------------- ### Bash: Set up a new CosmWasm project using a template Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/tutorials/introduction_to_cosmwasm.mdx This bash script sets up a new CosmWasm project by cloning a template repository. It uses `cargo-generate` to fetch the template from a specified Git URL and names the new project. After generation, it navigates into the newly created project directory. ```bash cargo generate --git https://github.com/CosmWasm/cw-template.git --name my-first-contract cd my-first-contract ``` -------------------------------- ### Initialize React App with TypeScript Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/tutorials/onboarding/part-3-web-app.mdx This demonstrates setting up a React application with TypeScript using `create-react-app`. It also covers installing Neutron and Cosmos dependencies, and development dependencies. ```bash # Create React app with TypeScript npx create-react-app neutron-counter-app --template typescript cd neutron-counter-app # Install Neutron and Cosmos dependencies npm install @cosmjs/stargate @cosmjs/proto-signing @keplr-wallet/types npm install @neutron-org/neutronjs @chakra-ui/react @emotion/react @emotion/styled framer-motion # Install development dependencies npm install --save-dev @types/node ``` -------------------------------- ### Verify Cosmovisor Version (Shell) Source: https://github.com/neutron-org/neutron-docs/blob/main/resources/upgrades/v6.0.1.mdx This shell command checks the installed Cosmovisor version for correctness. It requires cosmovisor binary in PATH. Inputs are none; outputs are version string (expected v1.5.0); limitations include needing the binary to be installed first. ```shell cosmovisor version ``` -------------------------------- ### Example Proposal JSON for Global Fee Updates Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/globalfee/how-to.mdx An example JSON structure for a proposal to update global fee parameters, including minimum gas prices and bypass message types. This structure is used with the `neutrond tx gov submit-proposal` command. ```json { "title": "Update Global Fee Parameters", "description": "Adjust minimum gas prices and bypass message types", "messages": [ { "@type": "/gaia.globalfee.v1beta1.MsgUpdateParams", "authority": "neutron10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", "params": { "minimum_gas_prices": [ { "denom": "untrn", "amount": "0.025" }, { "denom": "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9", "amount": "0.001" } ], "bypass_min_fee_msg_types": [ "/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient", "/ibc.core.channel.v1.MsgTimeout", "/ibc.core.channel.v1.MsgTimeoutOnClose" ], "max_total_bypass_min_fee_msg_gas_usage": 1000000 } } ], "deposit": "10000000untrn" } ``` -------------------------------- ### Neutron SDK Setup and Build (Bash) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/sdk.mdx Commands for cloning the Neutron SDK repository, running tests, generating schemas, and building for production. Requires Git and Make. ```bash git clone https://github.com/neutron-org/neutron-sdk.git cd neutron-sdk make test make schema make build ``` -------------------------------- ### Multi-step Transaction Pattern Example in JSON Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/gmp/how-to.mdx This JSON example showcases a multi-step transaction pattern, suitable for complex cross-chain operations. It employs Type 2 messaging and includes a payload that defines a sequence of actions, such as 'swap' followed by 'stake'. This allows for orchestrating multiple operations atomically. ```json { "source_chain": "juno-1", "source_address": "juno1...", "payload": "eyJzdGVwcyI6W3siYWN0aW9uIjoic3dhcCJ9LHsiYWN0aW9uIjoic3Rha2UifV19", "type": 2 } ``` ```json { "steps": [ {"action": "swap"}, {"action": "stake"} ] } ``` -------------------------------- ### Cross-Chain Swap Pattern Example in JSON Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/gmp/how-to.mdx This JSON example demonstrates a common cross-chain swap pattern. It utilizes Type 2 messaging, indicating that the transaction involves token coordination. The payload is base64 encoded and decodes into a specific swap instruction, defining the desired output token. ```json { "source_chain": "osmosis-1", "source_address": "osmo1...", "payload": "eyJhY3Rpb24iOiJzd2FwIiwidG9rZW5fb3V0IjoidWF0b20ifQ==", "type": 2 } ``` ```json { "action": "swap", "token_out": "uatom" } ``` -------------------------------- ### Build and Serve App Locally (Bash) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/tutorials/onboarding/part-3-web-app.mdx Commands to build the React application for production and serve the build output locally using the 'serve' package. This is useful for testing the production build before deploying. ```bash # Build the app npm run build # Serve locally to test npx serve -s build ``` -------------------------------- ### Cross-Chain Governance Vote Pattern Example in JSON Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/gmp/how-to.mdx This JSON example illustrates a cross-chain governance vote. It uses Type 1 messaging, suitable for informational actions that don't require direct token transfers. The payload specifies the action as 'vote', along with the proposal ID and the voting option. ```json { "source_chain": "cosmoshub-4", "source_address": "cosmos1...", "payload": "eyJhY3Rpb24iOiJ2b3RlIiwicHJvcG9zYWxfaWQiOjEsIm9wdGlvbiI6InllcyJ9", "type": 1 } ``` ```json { "action": "vote", "proposal_id": 1, "option": "yes" } ``` -------------------------------- ### Build and Run SubQuery Project in Bash Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/tutorials/indexers/subquery.mdx Bash commands to install dependencies, generate types, build the project, and start a local development node for a SubQuery project. ```bash # Install dependencies yarn install # Generate types from your GraphQL schema yarn codegen # Build the project yarn build # Start a local development node yarn start:docker ``` -------------------------------- ### GET /neutronynamicfees/params Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/dynamicfees/how-to.mdx Retrieves the current Dynamic Fees module parameters, including the list of supported assets and their NTRN‑denominated prices. Use this endpoint to view the active fee configuration. ```APIDOC ## GET /neutron/dynamicfees/params ### Description Retrieves the current parameters of the Dynamic Fees module, such as asset prices denominated in NTRN. ### Method GET ### Endpoint /neutron/dynamicfees/params ### Parameters #### Path Parameters *None* #### Query Parameters *None* #### Request Body *None* ### Request Example ```bash curl http://localhost:1317/neutron/dynamicfees/params ``` ### Response #### Success Response (200) - **params** (object) - Module parameters - **ntrn_prices** (array) - List of asset price objects - **denom** (string) - Asset denomination - **amount** (string) - Price amount in NTRN #### Response Example ```yaml params: ntrn_prices: - amount: "0.150000000000000000" denom: uatom - amount: "0.080000000000000000" denom: uosmo ``` ``` -------------------------------- ### Deploy to IPFS (Bash) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/tutorials/onboarding/part-3-web-app.mdx Instructions for deploying the built application to IPFS. This involves installing the IPFS CLI, adding the build folder to IPFS, and pinning the resulting hash for persistence. ```bash # Install IPFS CLI npm install -g ipfs-http-client # Add build folder to IPFS ipfs add -r build/ # Pin the hash for persistence ipfs pin add YOUR_HASH_HERE ``` -------------------------------- ### Send IBC transfer with GMP (CLI) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/gmp/how-to.mdx Example CLI command for sending an IBC transfer with GMP message in the memo field. Specifies channel, recipient, amount, and memo. ```bash neutrond tx ibc-transfer transfer \ transfer \ channel-0 \ neutron1recipient... \ 1000uosmo \ --memo '{"source_chain":"osmosis-1","source_address":"osmo1...","payload":"base64-payload","type":1}' \ --from sender ``` -------------------------------- ### Initialize SubQuery Project (Neutron Starter) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/tutorials/indexers/subquery.mdx This snippet shows how to initialize a new SubQuery project using the Neutron starter template. Requires the SubQuery CLI to be installed. ```bash subql init my-neutron-indexer --starter neutron-starter ``` ```bash cd my-neutron-indexer ``` -------------------------------- ### Build and Deploy Neutron Contract (Bash) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/tutorials/onboarding/part-2-modules-contracts.mdx Provides bash commands to build a Rust-based Neutron smart contract using Cargo and Docker, and then deploy it to a Neutron testnet using the `neutrond` CLI. It includes steps for instantiation with initial parameters. ```bash # Build the enhanced contract cargo wasm docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/rust-optimizer:0.12.13 # Deploy with oracle configuration neutrond tx wasm instantiate CODE_ID \ '{"initial_count":"0","price_threshold":"10.0","oracle_base":"ATOM","oracle_quote":"USD"}' \ --from your-key \ --label "oracle-counter" \ --chain-id neutron-testing-1 \ --gas auto \ --node http://localhost:26657 \ --yes ``` -------------------------------- ### Install Go toolchain (bash) Source: https://github.com/neutron-org/neutron-docs/blob/main/operators/running-a-node.mdx Downloads and extracts Go 1.21 (or higher) and adds the Go binary directory to the user's PATH. Ensures the Go environment is available for building Neutron from source. ```bash # Install Go 1.21 or higher wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz rm go1.21.0.linux-amd64.tar.gz echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.profile source ~/.profile ``` -------------------------------- ### Get Detailed Failure Information Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/contractmanager/how-to.mdx CLI command to retrieve detailed error information beyond the redacted error in state. Requires a node that indexes transactions and has the relevant blocks available. ```bash neutrond query contractmanager failure-details [address] [failure_id] ``` -------------------------------- ### Create Connect configuration file (Method 2) using JSON Source: https://github.com/neutron-org/neutron-docs/blob/main/operators/oracle-setup.mdx Provides a JSON configuration for Connect, specifying port, Prometheus metrics address, and market map provider endpoints. The file should be saved as /usr/local/connect/oracle.json and referenced by the systemd service. ```json {\n \"port\": \"8080\",\n \"metrics\": {\n \"prometheusServerAddress\": \"0.0.0.0:8001\"\n },\n \"providers\": {\n \"marketmap_api\": {\n \"api\": {\n \"endpoints\": [\n {\n \"url\": \"localhost:9090\"\n }\n ]\n }\n }\n }\n} ``` -------------------------------- ### Create Systemd service file for Connect (Method 1) using systemd unit syntax Source: https://github.com/neutron-org/neutron-docs/blob/main/operators/oracle-setup.mdx Defines a systemd unit to manage the Connect price oracle service, specifying user, execution command, restart policy, and resource limits. After creation, reload systemd and enable the service. ```systemd [Unit] Description=Connect Price Oracle Service After=network-online.target [Service] User=$USER ExecStart=/usr/local/bin/connect --host=0.0.0.0 --port=8080 --market-map-endpoint=\"127.0.0.1:9090\" --log-file=\"/var/log/connect/sidecar.log\" Restart=always RestartSec=3 LimitNOFILE=65535 [Install] WantedBy=multi-user.target ``` -------------------------------- ### Monitor Price Changes (TypeScript) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/dynamicfees/how-to.mdx An example using TypeScript to monitor for dynamic fees parameter change events via WebSocket. This function subscribes to transaction events and triggers a local price cache update when parameters change. ```typescript // Monitor for parameter change events async function monitorPriceChanges() { const client = await getWebSocketClient(); client.subscribe({ query: "tm.event='Tx' AND message.action='/neutron.dynamicfees.v1.MsgUpdateParams'" }, (event) => { console.log('Dynamic Fees parameters updated:', event); // Handle price change updateLocalPriceCache(); }); } ``` -------------------------------- ### GET /neutron/ibc-rate-limit/v1beta1/params Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/ibc-rate-limit/how-to.mdx Retrieves the current parameters of the IBC Rate Limit module, specifically the configured contract address for rate limiting decisions. This is the recommended method to check current parameters due to CLI implementation issues. ```APIDOC ## GET /neutron/ibc-rate-limit/v1beta1/params ### Description Retrieves the current parameters of the IBC Rate Limit module, including the configured contract address that handles rate limiting decisions. ### Method GET ### Endpoint /neutron/ibc-rate-limit/v1beta1/params ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl https://rpc.neutron.org/neutron/ibc-rate-limit/v1beta1/params ``` ### Response #### Success Response (200) - **params** (object) - Module parameters object - **contract_address** (string) - The configured CosmWasm contract address for rate limiting decisions #### Response Example ```json { "params": { "contract_address": "neutron1abcdef..." } } ``` ``` -------------------------------- ### Prepare Cosmovisor Directory Structure (Shell) Source: https://github.com/neutron-org/neutron-docs/blob/main/resources/upgrades/v8.0.0-rc0.mdx This snippet sets up the necessary directory structure for Cosmovisor. It copies the current `neutrond` binary (v7.0.0-rc0) to the `genesis/bin` directory and the new `neutrond` binary (v8.0.0-rc0) to the `upgrades/v8.0.0-rc0/bin` directory. This prepares Cosmovisor to manage the upgrade. ```shell mkdir -p $NEUTRON_HOME/cosmovisor/genesis/bin cp $(which neutrond) $NEUTRON_HOME/cosmovisor/genesis/bin mkdir -p $NEUTRON_HOME/cosmovisor/upgrades/v8.0.0-rc0/bin cp $(which neutrond) $NEUTRON_HOME/cosmovisor/upgrades/v8.0.0-rc0/bin ``` -------------------------------- ### CosmWasm Contract Handle Scheduled Execution (Rust) Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/cron/how-to.mdx Example Rust code for a CosmWasm smart contract demonstrating how to handle messages executed by the Neutron Cron module. It includes an `execute` entry point and a specific handler for scheduled tasks. ```rust use cosmwasm_std::{ entry_point, DepsMut, Env, MessageInfo, Response, StdResult, }; #[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> StdResult { match msg { ExecuteMsg::DistributeRewards { amount } => { handle_scheduled_execution(deps, env, info, amount) }, // Other handlers... } } fn handle_scheduled_execution( deps: DepsMut, env: Env, info: MessageInfo, amount: String, ) -> StdResult { // Note: The sender will be the Cron module account // You can optionally validate this if needed // Perform your scheduled task // This could be: // - Updating state // - Distributing rewards // - Triggering other contract calls // - Protocol maintenance tasks Ok(Response::new() .add_attribute("action", "scheduled_task_executed") .add_attribute("sender", info.sender.to_string()) .add_attribute("block_height", env.block.height.to_string()) .add_attribute("amount", amount)) } ``` -------------------------------- ### Create JSON Proposal to Add New Asset Support Source: https://github.com/neutron-org/neutron-docs/blob/main/developers/modules/dynamicfees/how-to.mdx This is another example of the same JSON structure used to propose adding support for a new asset by including its denom and amount in the ntrn_prices array. Governance approval is required to enable fee payments in the new asset. The structure is identical to updating existing prices. ```json { "title": "Add Support for New Asset", "description": "Add JUNO token support to Dynamic Fees module", "messages": [ { "@type": "/neutron.dynamicfees.v1.MsgUpdateParams", "authority": "neutron10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", "params": { "ntrn_prices": [ { "denom": "uatom", "amount": "0.150000000000000000" }, { "denom": "uosmo", "amount": "0.080000000000000000" }, { "denom": "ujuno", "amount": "0.025000000000000000" } ] } } ] } ```