Simple Discord Bot that allows token faucet. It uses the Kevin Novak's Typescript Discord Bot Template. I've made it a template and gave it some functionalities so you can add it in your own server :)
If you need support by my side don't hesitate in DMing me via Discord: Chiin#4895
The Discord bot accepts a command that looks like this:
/faucet <network> <token> <address>
and then disburse a predefined amount of funds (specific to that token on that network) to the address sent.
Currently, the following networks are supported by default:
- Ethereum Goerli (ETH & LINK)
- Polygon Mumbai (MATIC & LINK)
Anyways, it is possible to add any token of any network (EVM) by using the following interface:
interface Networks {
[network: string]: {
chainId: number;
tokens: {
[token: string]: {
amount: number; // @notice that this amount is measured in ETH
address?: string;
isNativeToken?: boolean;
};
};
blockExplorer: string;
};
}
- People can request tokens via the
/faucet <network> <token> <address>
command. - Embeds usage for better UI :).
- Validations with warning/error messages.
- Cooldown for requesting tokens (based on Discord User ID).
- Easy to add/remove networks and tokens.
- Written with TypeScript.
- Uses the discord.js framework.
- Written with ESM for future compatibility with packages.
- Easy setup with Docker Compose.
- Copy example config files.
- Navigate to the
config
folder of this project. - Copy the
config.example.json
asconfig.json
.
- Navigate to the
- Obtain a bot token.
- You'll need to create a new bot in your Discord Developer Portal.
- See here for detailed instructions.
- At the end you should have a bot token.
- You'll need to create a new bot in your Discord Developer Portal.
- Modify the config file.
- Open the
config/config.json
file. - You'll need to edit the following values:
client.id
- Your discord bot's user ID.client.token
- Your discord bot's token.privateKey
- The private key of the account that will be sending funds. Please be careful with the PK that you use, by my side, I've always done the tests with accounts that have funds only in testnetsnetworks.{network}.nodeUri
- The URI to the node providers. You can find them in Chainlistdatabase
- All fields in this object are for the database connection. Note: You can create a local database by runningdocker-compose up -d
thanks to thedocker-compose.yml
file
- Open the
- Start the bot.
- Run
docker-compose build
followed bydocker-compose up
and let the faucet send funds to your community :).
- Run
"networks": {
"GOERLI": {
"chainId": 5,
"tokens": {
"ETH": {
"amount": 0.001,
"isNativeToken": true
}
},
"blockExplorer": "https://goerli.etherscan.io/tx/",
"nodeUri": "<node-uri>"
},
We have to add a new property in the tokens
object with the name of our token, and add a amount
and address
field. For example, for adding the LINK token, we should do it this way:
"networks": {
"GOERLI": {
"chainId": 5,
"tokens": {
"ETH": {
"amount": 0.001,
"isNativeToken": true
},
"LINK": {
"amount": 0.1,
"address": "0x326C977E6efc84E512bB9C30f76E30c160eD06FB"
}
},
"blockExplorer": "https://goerli.etherscan.io/tx/",
"nodeUri": "<node-uri>"
},
After making this change, run npm run update:faucet
to update the commands
We have to add a new property in the networks
object with the name of the network and add the fields: chainId
, blockExplorer
& nodeUri
. For adding the mumbai network with the LINK token, we should do it this way:
"GOERLI": {
"chainId": 5,
"tokens": {
"ETH": {
"amount": 0.001,
"isNativeToken": true
},
"LINK": {
"amount": 0.1,
"address": "0x326C977E6efc84E512bB9C30f76E30c160eD06FB"
}
},
"blockExplorer": "https://goerli.etherscan.io/tx/",
"nodeUri": "<node-uri>"
},
"MUMBAI": {
"chainId": 80001,
"tokens": {
"LINK": {
"amount": 0.1,
"address": "0x326C977E6efc84E512bB9C30f76E30c160eD06FB"
}
},
"blockExplorer": "https://mumbai.polygonscan.com/tx/",
"nodeUri": "<node-uri>"
}
After making this change, run npm run update:faucet
to update the commands