> For the complete documentation index, see [llms.txt](https://stylus-1.gitbook.io/stylusguide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stylus-1.gitbook.io/stylusguide/3.-your-first-smart-contract-hello-world/deploying-and-testing-your-contract.md).

# Deploying and Testing Your Contract

####

### Step 4: Deploying the Contract

#### Check the Contract

Ensure the contract meets all requirements:

```sh
cargo stylus check --endpoint https://sepolia-rollup.arbitrum.io/rpc
```

#### Deploy the Contract

Ensure you have a valid private key saved in a file (e.g., `private_key.txt`). The file should contain only the private key without any extra characters or spaces.

Deploy the contract using the following command:

```sh
cargo stylus deploy --private-key-path=/path/to/private_key.txt --endpoint https://sepolia-rollup.arbitrum.io/rpc
```

### Step 5: Interacting with the Contract

#### Setup MetaMask

Configure MetaMask for the Arbitrum network following these [instructions](https://support.arbitrum.io/hc/en-us/articles/4408040006931-How-To-Connect-MetaMask-To-Arbitrum).

#### Acquire Testnet ETH

Use faucets like [BwareLabs](https://bwarelabs.com/faucets/arbitrum-sepolia) or [QuickNode](https://faucet.quicknode.com/arbitrum/sepolia) to get Sepolia ETH for testing.

#### Interacting with the Contract using Ethers.js

```javascript
const { ethers } = require("ethers");

const provider = new ethers.providers.JsonRpcProvider("https://sepolia-rollup.arbitrum.io/rpc");
const contractAddress = "<YOUR_CONTRACT_ADDRESS>";

const abi = [
    "function get_greeting() view returns (string)"
];

const privateKey = "<YOUR_PRIVATE_KEY>";
const wallet = new ethers.Wallet(privateKey, provider);
const contract = new ethers.Contract(contractAddress, abi, wallet);

async function main() {
    const greeting = await contract.get_greeting();
    console.log("Greeting from contract:", greeting);
}

main().catch(console.error);
```

By following these steps, you can set up your development environment, create and deploy a simple hello contract, and interact with it using Ethers.js.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://stylus-1.gitbook.io/stylusguide/3.-your-first-smart-contract-hello-world/deploying-and-testing-your-contract.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.
