🧪 Banter Blockchain implements both a custom ERC20 token (BanterCoin) and a decentralized chat system that can be used by web3 applications, built with Scaffold-ETH 2 toolkit.
⚙️ Built using NextJS, RainbowKit, Hardhat, Wagmi, Viem, and Typescript.
- ERC20 compliant token implementation
- Initial supply of 1,000,000 BANT tokens
- Built with OpenZeppelin Contracts v5.0.0
- Secure and auditable token transfers
- Decentralized chat functionality through smart contracts
ChatListcontract for managing user conversationsChatcontract for handling individual chat instances- Features:
- One-to-one messaging
- Message history stored on-chain
- Participant verification
- Event-based message tracking
- Standard ERC20 implementation with fixed initial supply
- Built-in decimals support
- Transfer and approval functionality
- Main registry for all chat instances
- Manages chat creation and lookup
- Maintains user-to-chat mappings
- Prevents duplicate chats between the same users
- Individual chat instance
- Message sending functionality
- Participant verification
- Event emission for message tracking
Before you begin, you need to install the following tools:
- Node (>= v20.18.3)
- Yarn (v1 or v2+)
- Git
To get started with Banter Blockchain using Scaffold-ETH 2, follow the steps below:
- Clone this repository and install dependencies:
git clone https://github.com/yourusername/banter-blockchain.git
cd banter-blockchain
yarn install- Run a local network in the first terminal:
yarn chainThis command starts a local Ethereum network using Hardhat. The network runs on your local machine and can be used for testing and development.
- On a second terminal, deploy the contracts:
yarn deployThis command deploys the BanterCoin and ChatList contracts to the local network. The contracts are located in packages/hardhat/contracts and can be modified to suit your needs.
- On a third terminal, start your NextJS app:
yarn startVisit your app on: http://localhost:3000. You can interact with your smart contracts using the Debug Contracts page.
If you need to expose your local blockchain to the internet (for mobile testing, third-party integration, etc.), you can use ngrok:
- Install ngrok if you haven't already:
# Using npm
npm install -g ngrok
# Using Homebrew on macOS
brew install ngrok- Expose your local blockchain (running on port 8545):
ngrok http 8545-
Ngrok will provide you with a forwarding URL like
https://a1b2c3d4.ngrok.io -
Use this URL in your application:
- For HTTP RPC:
https://a1b2c3d4.ngrok.io - For WebSocket RPC:
wss://a1b2c3d4.ngrok.io
- For HTTP RPC:
-
Update your configuration to use these URLs where needed:
- For frontend applications, update your RPC provider URL
- For wallets or external tools, use the HTTPS URL as the custom RPC endpoint
Note: Ngrok URLs change each time you restart the service unless you have a paid ngrok account. For persistent URLs, consider upgrading to a paid plan.
Run the test suite to ensure all contracts are functioning correctly:
yarn testThe test suite includes tests for all three contracts:
- BanterCoin token functionality
- Chat messaging capabilities
- ChatList management features
To deploy to a testnet or mainnet:
-
Set up your environment variables:
- Create or modify the
.envfile in thepackages/hardhatdirectory - Add your private key and API keys for the desired network
- Create or modify the
-
Deploy to your chosen network:
yarn deploy --network <network-name>Available networks include: sepolia, arbitrum, optimism, polygon, base, etc. (See packages/hardhat/hardhat.config.ts for all options)
- After deployment, the contracts will be automatically verified on the respective block explorers if configured correctly.
Once deployed, you can interact with the contracts through the Scaffold-ETH 2 UI or programmatically:
- Check your token balance
- Transfer tokens to other addresses
- Approve spending by other contracts
- Create new chat instances with other users
- View your list of active chats
- Access individual chat details
- Send messages to your chat partner
- View message history through emitted events
- Contract security contact: [email protected]
- Built with OpenZeppelin Contracts for battle-tested security
- Follows Solidity best practices and patterns
- Comprehensive test coverage
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.