> 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/ethers.js-guide.md).

# ethers.js Guide

#### **Install ethers.js**

```
npm install ethers
```

#### **Connect to Tajir**

```js
import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider(
  "https://rpc.tajirchain.com"
);
```

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

```js
const balance = await provider.getBalance("0xYourAddress");
console.log(ethers.formatEther(balance));
```

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

```js
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const tx = await signer.sendTransaction({
  to: "0xRecipient",
  value: ethers.parseEther("1")
});

await tx.wait();
console.log("Tx confirmed:", tx.hash);
```

#### **Interact With a Contract**

```js
const contract = new ethers.Contract(
  CONTRACT_ADDRESS,
  ABI,
  signer
);

await contract.myMethod(); 
```

<figure><img src="https://1129061842-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAbtkglQlMKahYwDUwHV1%2Fuploads%2FV4nGAE7KlSQISkOSbq7B%2FE.JSG.png?alt=media&#x26;token=1a488f9f-84dc-4798-9a70-5d48e399b4e4" alt=""><figcaption></figcaption></figure>
