# Deploying and Testing Your Token

### Step 3: Interacting with the Contract

#### Setting Up MetaMask

1. **Install MetaMask**: Install the MetaMask browser extension from [metamask.io](https://metamask.io).
2. **Configure MetaMask for Arbitrum**:
   * Click on the network dropdown in MetaMask and select "Custom RPC".
   * Enter the following details:
     * Network Name: Arbitrum Sepolia Testnet
     * New RPC URL: `https://sepolia-rollup.arbitrum.io/rpc`
     * Chain ID: `421613` (for Sepolia)
     * Symbol: ETH
     * Block Explorer URL: `https://explorer.arbitrum.io`
   * Save the network configuration.

#### Acquiring Testnet ETH

1. **Visit a Sepolia Faucet**: Use one of the following links to get Sepolia ETH for testing:
   * [BwareLabs Sepolia Faucet](https://bwarelabs.com/faucets/arbitrum-sepolia)
   * [QuickNode Sepolia Faucet](https://faucet.quicknode.com/arbitrum/sepolia)
   * [Sepolia Faucet](https://sepoliafaucet.com)
2. **Enter your MetaMask wallet address**: Click "Claim" to receive Sepolia ETH.

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

**Create a `script.js` file with the following content:**

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

const provider = new ethers.providers.JsonRpcProvider("https://sepolia-rollup.arbitrum.io/rpc");
const privateKey = "<YOUR_PRIVATE_KEY>"; // Replace with your private key
const wallet = new ethers.Wallet(privateKey, provider);

const abi = [
    "function name() view returns (string)",
    "function symbol() view returns (string)",
    "function decimals() view returns (uint8)",
    "function totalSupply() view returns (uint256)",
    "function balanceOf(address account) view returns (uint256)",
    "function transfer(address recipient, uint256 amount) returns (bool)",
    "function transferFrom(address sender, address recipient, uint256 amount) returns (bool)",
    "function approve(address spender, uint256 amount) returns (bool)",
    "function allowance(address owner, address spender) view returns (uint256)"
];

const contractAddress = "<YOUR_CONTRACT_ADDRESS>"; // Replace with your contract address

const erc20 = new ethers.Contract(contractAddress, abi, wallet);

async function main() {
    const name = await erc20.name();
    console.log("Token Name:", name);

    const symbol = await erc20.symbol();
    console.log("Token Symbol:", symbol);

    const decimals = await erc20.decimals();
    console.log("Token Decimals:", decimals);

    const totalSupply = await erc20.totalSupply();
    console.log("Total Supply:", totalSupply.toString());

    const balance = await erc20.balanceOf(wallet.address);
    console.log("Balance:", balance.toString());

    const recipient = "<RECIPIENT_ADDRESS>"; // Replace with a recipient address
    const amount = ethers.utils.parseUnits("10", decimals); // Sending 10 tokens
    const tx = await erc20.transfer(recipient, amount);
    await tx.wait();
    console.log("Transfer successful!");
}

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

**Run the script:**

```sh
node script.js
```

This script connects to your deployed ERC-20 contract, retrieves token information, checks balances, and performs a token transfer.

### Conclusion

You have successfully created and deployed an ERC-20 token contract using Rust and Arbitrum Stylus. You also learned how to interact with your contract using Ethers.js. This example demonstrates the power and flexibility of combining Rust with blockchain development on the Arbitrum network. Happy coding!


---

# 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://stylus-1.gitbook.io/stylusguide/5.-creating-your-own-token-token-contract/deploying-and-testing-your-token.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.
