> For the complete documentation index, see [llms.txt](https://gothamcash.gitbook.io/bindowscash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gothamcash.gitbook.io/bindowscash/testnet-guide/deploy-test-on-bsc-testnet.md).

# Deploy/test on BSC Testnet

Developers can deploy and interact with the BindowsCash smart contract on Binance Smart Chain (BSC) Testnet to test and integrate before going live on mainnet.

***

#### 🧰 Prerequisites

Before you begin:

* **Node.js** and **npm** installed
* **Hardhat** (or Foundry/Truffle) environment, or Remix IDE
* A funded **BSC Testnet wallet**
* BSC Testnet RPC endpoint
* Contract source code (`GothamMixer01.sol`)

***

#### 📦 Install Dependencies (with Hardhat)

```bash
mkdir bindowscash-testnet && cd bindowscash-testnet
npm init -y
npm install --save-dev hardhat
npx hardhat
```

Choose **"Create a basic sample project"** and then install:

```bash
npm install --save-dev @nomicfoundation/hardhat-toolbox
```

***

#### ⚙️ Configure Hardhat for BSC Testnet

Edit `hardhat.config.js`:

```js
require("@nomicfoundation/hardhat-toolbox");

module.exports = {
  solidity: "0.8.20",
  networks: {
    bsctestnet: {
      url: "https://data-seed-prebsc-1-s1.binance.org:8545/",
      chainId: 97,
      accounts: [process.env.PRIVATE_KEY]  // add your testnet wallet private key
    }
  }
};
```

Create a `.env` file to store your testnet private key (never commit this!):

```
PRIVATE_KEY=your_testnet_private_key_here
```

Install dotenv if needed:

```bash
npm install dotenv
```

Then add `require("dotenv").config();` at the top of `hardhat.config.js`.

***

#### 🛠️ Deploy the Contract

Create a new file: `scripts/deploy.js`:

```js
async function main() {
  const BindowsMixer = await ethers.getContractFactory("BindowsMixer01");
  const mixer = await BindowsMixer.deploy();
  await mixer.deployed();

  console.log("BindowsMixer deployed to:", mixer.address);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
```

Deploy to BSC Testnet:

```bash
npx hardhat run scripts/deploy.js --network bsctestnet
```

***

#### 🧪 Interact with the Contract

Once deployed, you can test:

* `deposit()` using Hardhat scripts or front-end with MetaMask
* `withdraw()` using the corresponding note
* Fee toggling and expiry testing
* Listening for events (`Deposited`, `Withdrawn`, etc.)

Use `cast`, `ethers.js`, or `web3.js` for local testing scripts or write integration code in your dApp frontend.

***

#### 🔍 Useful Links

* BSC Testnet Faucet: <https://testnet.bnbchain.org/faucet-smart>
* BSC Testnet Explorer: [https://testnet.bscscan.com](https://testnet.bscscan.com/)
* Public RPC: `https://data-seed-prebsc-1-s1.binance.org:8545/`
* Smart contracts: [https://github.com/BindowsCash/contracts](https://github.com/GothamCash/contracts)
* User interface (dApp): <https://github.com/BindowsCash/frontend>

***

🛡️ **Reminder**: Always test with dummy notes and avoid using real secrets or wallets during development. Never expose your private key or commit `.env` files.
