# Interacting with Smart Contracts

For interacting with our contracts we first recomend to go to the following sections:

* Read Contracts overview section
* Read [Setting Up Your Environment](/nomos-1/readme/getting-started/setting-up-your-environment.md)
* Read [Deploying Smart Contracts](/nomos-1/readme/getting-started/deploying-smart-contracts.md) (if you are setting up your own contracts).

## Arch3Js

To interact with our smart contracts, we will use Arch3js which is a JavaScript library that makes it easy for developers to build web applications and tools that interact with the Archway network. It acts as a drop-in replacement for the CosmJS client library, extending its functionality and allowing for easier interaction with Archway's reward and fee sub-systems.

To delve deeper into the internal mechanics of arch3.js, refer to the API documentation available at <https://archway-network.github.io/arch3.js>.

### Installation

To install arch3.js, you have the option of using either npm or yarn:

**NPM**

> npm install --save @archwayhq/arch3.js

**Yarn**

> yarn add @archwayhq/arch3.js

### Query

Below is simple example on querying Nomos multisig to get members of multisig:

```
import { ArchwayClient } from '@archwayhq/arch3.js';

const client = await ArchwayClient.connect('https://rpc.constantine.archway.tech');
const contractAddress = "abcdefg";
// Get members
const queryMembers = {  get_members: [] };
const { members } = await client.queryContractSmart(  contractAddress,  queryMembers);
console.log("Members: ", members);
```

### Execution

Below is simple example on execute vote transaction to Nomos multisig:

```
import { SigningArchwayClient } from "@archwayhq/arch3.js";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import "dotenv/config";

const contractAddress = process.env.CONTRACT_ADDR;
const mnemonic = process.env.MNEMONIC;

const network = {
    chainId: "constantine-3",
    endpoint: "https://rpc.constantine.archway.tech",
    prefix: "archway",
};
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: network.prefix, });
const accounts = await wallet.getAccounts();

const tx_client = await SigningArchwayClient.connectWithSigner(
    network.endpoint,
    wallet
);
const txId = "set-this";
const executeMsg = {
    vote_transaction: txId,
    vote: 1,
};

const response = await tx_client.execute(
accounts[0].address,
contractAddress,
executeMsg,
"auto"
);

console.log("Response: ", JSON.stringify(response));
console.log("Transaction Hash: ", response.transactionHash);
```

### Nomos JSON Schema

To find reference on what interactions we can have with the contract, we can see the json schema in contract folder, in that example we can find how the json structure should be for instantiate message, execute message, query, and contract response.

* [Factory Json Schema](https://github.com/chelofinance/documentation/blob/main/contracts/factory/schema/README.md)
* [Multisig Json Schema](https://github.com/chelofinance/documentation/blob/main/contracts/multisig/schema/README.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nomos-docs.gitbook.io/nomos-1/readme/getting-started/interacting-with-smart-contracts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
