> For the complete documentation index, see [llms.txt](https://docs.tajirchain.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tajirchain.com/developers/smart-contract-interaction/web3.js-guide.md).

# web3.js Guide

#### **Install web3.js**

```
npm install web3
```

#### **Connect to Tajir**

```js
import Web3 from "web3";

const web3 = new Web3("https://rpc.testnet.tajirchain.com");
```

#### **Read Data: Get Balance**

```js
const balance = await web3.eth.getBalance("0xYourAddress");
console.log(web3.utils.fromWei(balance, "ether"));
```

#### **Write Data: Send Transaction**

```js
const tx = await web3.eth.sendTransaction({
  from: YOUR_ADDRESS,
  to: "0xRecipient",
  value: web3.utils.toWei("1", "ether")
});
```

#### **Interact With Contract**

```js
const contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

const result = await contract.methods.myMethod().call();
```

<figure><img src="/files/P0mH9nII6cWgY5uO7Gq1" alt=""><figcaption></figcaption></figure>
