> 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/4.-understanding-smart-contract-storage-simple-storage/interacting-with-storage-variables.md).

# Interacting with Storage Variables

#### Interacting with the Contract

1. **Setup MetaMask:**

   Ensure MetaMask is configured for the Arbitrum network. Detailed instructions are available in the [Arbitrum documentation](https://docs.arbitrum.io/).
2. **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.
3. **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 setValue(uint256 new_value) external",
       "function getValue() view returns (uint256)",
       "function mulValue(uint256 multiplier) external",
       "function addValue(uint256 increment) external",
       "function increment() external"
   ];

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

   async function setValue(newValue) {
       const tx = await contract.setValue(newValue);
       await tx.wait();
       console.log("Value set to:", newValue);
   }

   async function getValue() {
       const value = await contract.getValue();
       console.log("Current value is:", value.toString());
   }

   async function mulValue(multiplier) {
       const tx = await contract.mulValue(multiplier);
       await tx.wait();
       console.log("Value multiplied by:", multiplier);
   }

   async function addValue(increment) {
       const tx = await contract.addValue(increment);
       await tx.wait();
       console.log("Value incremented by:", increment);
   }

   async function increment() {
       const tx = await contract.increment();
       await tx.wait();
       console.log("Value incremented by 1");
   }

   async function main() {
       await setValue(42);
       await getValue();
       await mulValue(2);
       await getValue();
       await addValue(10);
       await getValue();
       await increment();
       await getValue();
   }

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

This script connects to the Arbitrum network, interacts with your deployed contract, sets a new value, multiplies it, increments it, and retrieves the current value from the contract.
