> For the complete documentation index, see [llms.txt](https://tharwa.gitbook.io/tharwa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tharwa.gitbook.io/tharwa/technical-architecture/smart-contract-addresses.md).

# Smart Contract Addresses

This page provides verified contract addresses and practical integration examples for all Tharwa protocol deployments. Each contract is explained with its purpose, key functions, and real-world usage patterns.

## **Ethereum Mainnet**

All core Tharwa contracts are deployed and operational on Ethereum Mainnet:

| Contract          | Address                                      | Etherscan                                                                       | Purpose                    |
| ----------------- | -------------------------------------------- | ------------------------------------------------------------------------------- | -------------------------- |
| **thUSD**         | `0x76972F054aB43829064d31fF5f3AcC5Fabe57FE8` | [View](https://etherscan.io/address/0x76972F054aB43829064d31fF5f3AcC5Fabe57FE8) | RWA-backed stablecoin      |
| **sthUSD**        | `0xf7Af0A8079F12F19533B0DF69ce7ee6718b0C46f` | [View](https://etherscan.io/address/0xf7Af0A8079F12F19533B0DF69ce7ee6718b0C46f) | Yield-bearing staked thUSD |
| **thBonds**       | `0xAc02FF90bC709A134cD4Ad0b50BaB8be9e0f504e` | [View](https://etherscan.io/address/0xAc02FF90bC709A134cD4Ad0b50BaB8be9e0f504e) | Fixed-term bond vaults     |
| **TRWA**          | `0x7b10d50b5885bE4c7985A88408265c109bd1EeC8` | [View](https://etherscan.io/address/0x7b10d50b5885bE4c7985A88408265c109bd1EeC8) | Governance token           |
| **thUSDSwap**     | `0x7b930eaD88e7DAD023af9eaDb5D2AC817096c2Bc` | [View](https://etherscan.io/address/0x7b930eaD88e7DAD023af9eaDb5D2AC817096c2Bc) | thUSD/USDC stableswap      |
| **thUSD/USDC LP** | `0xF88dE5987a4a114Fab1Fe98E681f83216F4b6E76` | [View](https://etherscan.io/address/0xF88dE5987a4a114Fab1Fe98E681f83216F4b6E76) | Liquidity pool token       |

### **Network Details**

* **Chain ID**: 1
* **RPC**: `https://mainnet.infura.io/v3/YOUR_KEY`
* **Block Explorer**: [Etherscan](https://etherscan.io)

***

## **Sepolia Testnet**

Development and testing environment for Tharwa protocol:

| Contract      | Address                                      | Etherscan                                                                               | Purpose              |
| ------------- | -------------------------------------------- | --------------------------------------------------------------------------------------- | -------------------- |
| **thUSD**     | `0xBDa089250C2bd31db65C99a99D4862d6BAC4446A` | [View](https://sepolia.etherscan.io/address/0xBDa089250C2bd31db65C99a99D4862d6BAC4446A) | Testnet stablecoin   |
| **sthUSD**    | `0xBDa089250C2bd31db65C99a99D4862d6BAC4446A` | [View](https://sepolia.etherscan.io/address/0xBDa089250C2bd31db65C99a99D4862d6BAC4446A) | Testnet staked thUSD |
| **thBonds**   | `0x716430d4321d05a82bdF8e59AFA96026f0c7ca06` | [View](https://sepolia.etherscan.io/address/0x716430d4321d05a82bdF8e59AFA96026f0c7ca06) | Testnet bonds        |
| **thUSDSwap** | `0xdc2cf4bec47e2192a04d88986b3f781f6721b7fe` | [View](https://sepolia.etherscan.io/address/0xdc2cf4bec47e2192a04d88986b3f781f6721b7fe) | Testnet stableswap   |
| **MockDAI**   | `0x5574a42Bed488430Fe9F2B901dfB2B98AC2Cf939` | [View](https://sepolia.etherscan.io/address/0x5574a42Bed488430Fe9F2B901dfB2B98AC2Cf939) | Test token           |

### **Network Details**

* **Chain ID**: 11155111
* **RPC**: `https://sepolia.infura.io/v3/YOUR_KEY`
* **Block Explorer**: [Sepolia Etherscan](https://sepolia.etherscan.io)
* **Faucet**: [Sepolia Faucet](https://sepoliafaucet.com)

***

## **Contract Verification**

All contracts are verified on Etherscan with:

* ✅ **Source code published**
* ✅ **Constructor arguments verified**
* ✅ **Proxy implementation verified** (where applicable)
* ✅ **ABI available for integration**

### **Verification Status**

| Contract  | Mainnet    | Sepolia    | Compiler        |
| --------- | ---------- | ---------- | --------------- |
| thUSD     | ✅ Verified | ✅ Verified | Solidity 0.8.24 |
| sthUSD    | ✅ Verified | ✅ Verified | Solidity 0.8.24 |
| thBonds   | ✅ Verified | ✅ Verified | Solidity 0.8.24 |
| TRWA      | ✅ Verified | ✅ Verified | Solidity 0.8.24 |
| thUSDSwap | ✅ Verified | ✅ Verified | Solidity 0.8.24 |

***

## **Integration Examples: Real-World Usage**

### **Basic Integration: Checking User Balances**

Most integrations start with reading user balances across Tharwa's ecosystem:

{% tabs %}
{% tab title="Web3.js" %}

```javascript
const Web3 = require('web3');
const web3 = new Web3('https://mainnet.infura.io/v3/YOUR_KEY');

// Contract instances
const thUSD = new web3.eth.Contract(thUSDABI, '0x76972F054aB43829064d31fF5f3AcC5Fabe57FE8');
const sthUSD = new web3.eth.Contract(sthUSDABI, '0xf7Af0A8079F12F19533B0DF69ce7ee6718b0C46f');

// Get user's complete Tharwa position
async function getUserPosition(userAddress) {
    const [thUSDBalance, sthUSDShares, sthUSDValue] = await Promise.all([
        thUSD.methods.balanceOf(userAddress).call(),
        sthUSD.methods.balanceOf(userAddress).call(),
        sthUSD.methods.convertToAssets(await sthUSD.methods.balanceOf(userAddress).call()).call()
    ]);
    
    return {
        thUSD: thUSDBalance,
        sthUSDShares: sthUSDShares,
        sthUSDValue: sthUSDValue,
        totalValue: BigInt(thUSDBalance) + BigInt(sthUSDValue)
    };
}
```

{% endtab %}

{% tab title="Ethers.js" %}

```javascript
const { ethers } = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/YOUR_KEY');

// Contract instances
const thUSD = new ethers.Contract('0x76972F054aB43829064d31fF5f3AcC5Fabe57FE8', thUSDABI, provider);
const sthUSD = new ethers.Contract('0xf7Af0A8079F12F19533B0DF69ce7ee6718b0C46f', sthUSDABI, provider);

// Get current sthUSD exchange rate
async function getExchangeRate() {
    const totalAssets = await sthUSD.totalAssets();
    const totalSupply = await sthUSD.totalSupply();
    
    // Rate = assets per share (in 18 decimals)
    return totalAssets.mul(ethers.utils.parseEther('1')).div(totalSupply);
}
```

{% endtab %}
{% endtabs %}

### **Advanced Integration: Complete Tharwa Interaction**

Here's how to build a complete integration that handles the full Tharwa ecosystem:

{% tabs %}
{% tab title="Stake thUSD → sthUSD" %}

```javascript
// Complete staking flow with error handling
async function stakeThUSD(amount, userAddress, signer) {
    try {
        // 1. Check user's thUSD balance
        const balance = await thUSD.balanceOf(userAddress);
        if (balance.lt(amount)) throw new Error('Insufficient thUSD balance');
        
        // 2. Check allowance
        const allowance = await thUSD.allowance(userAddress, sthUSD.address);
        if (allowance.lt(amount)) {
            // Approve sthUSD to spend thUSD
            const approveTx = await thUSD.connect(signer).approve(sthUSD.address, amount);
            await approveTx.wait();
        }
        
        // 3. Preview the deposit to show user expected shares
        const expectedShares = await sthUSD.previewDeposit(amount);
        console.log(`You will receive ${ethers.utils.formatEther(expectedShares)} sthUSD shares`);
        
        // 4. Execute the stake
        const stakeTx = await sthUSD.connect(signer).deposit(amount, userAddress);
        const receipt = await stakeTx.wait();
        
        // 5. Confirm success
        const newBalance = await sthUSD.balanceOf(userAddress);
        console.log(`Staking successful! New sthUSD balance: ${ethers.utils.formatEther(newBalance)}`);
        
        return receipt;
    } catch (error) {
        console.error('Staking failed:', error.message);
        throw error;
    }
}
```

{% endtab %}

{% tab title="Purchase Tharwa Bonds" %}

```javascript
// Complete bond purchase with metadata
async function purchaseBond(duration, faceAmount, userAddress, signer) {
    try {
        // 1. Get bond configuration
        const config = await thBonds.bondConfigs(duration);
        const purchasePrice = faceAmount.mul(config.price).div(ethers.utils.parseEther('1'));
        
        // 2. Check if purchase is possible
        if (config.paused) throw new Error('Bond type is paused');
        if (config.issued.add(faceAmount).gt(config.cap)) throw new Error('Would exceed bond cap');
        
        // 3. Check user balance and approve
        const balance = await thUSD.balanceOf(userAddress);
        if (balance.lt(purchasePrice)) throw new Error('Insufficient thUSD for purchase');
        
        const allowance = await thUSD.allowance(userAddress, thBonds.address);
        if (allowance.lt(purchasePrice)) {
            const approveTx = await thUSD.connect(signer).approve(thBonds.address, purchasePrice);
            await approveTx.wait();
        }
        
        // 4. Calculate expected maturity
        const durationSeconds = duration === 0 ? 90*24*60*60 : duration === 1 ? 180*24*60*60 : 360*24*60*60;
        const maturityTime = Math.floor((Date.now() + durationSeconds * 1000) / (24*60*60*1000)) * 24*60*60;
        
        console.log(`Bond will mature on: ${new Date(maturityTime * 1000).toISOString()}`);
        console.log(`You pay: ${ethers.utils.formatEther(purchasePrice)} thUSD`);
        console.log(`You receive at maturity: ${ethers.utils.formatEther(faceAmount)} thUSD`);
        
        // 5. Purchase the bond
        const purchaseTx = await thBonds.connect(signer).purchaseBond(duration, faceAmount, userAddress);
        const receipt = await purchaseTx.wait();
        
        return { receipt, tokenId: maturityTime };
    } catch (error) {
        console.error('Bond purchase failed:', error.message);
        throw error;
    }
}
```

{% endtab %}
{% endtabs %}

***

## **Future Deployments**

### **Planned Networks**

* **Arbitrum**: TBA
* **Polygon**: TBA
* **Base**: TBA
* **Optimism**: TBA

All future deployments will use LayerZero's OFT standard for seamless cross-chain functionality.

***

{% hint style="warning" %}
**Important Notes**

* Always verify contract addresses from official sources
* Test integrations on Sepolia before mainnet deployment
* Use latest ABI from verified Etherscan contracts
* Monitor for contract upgrades and announcements
  {% endhint %}

{% hint style="info" %}
**Developer Resources**

* **GitHub**: [Contract Source Code](https://github.com/tharwa-finance/contracts-v0)
* **Discord**: [Developer Support](https://discord.gg/gn9htPaF9v)
* **dApp**: [app.tharwa.finance](https://app.tharwa.finance)
  {% endhint %}
