Smart contract for processing donations in various tokens on Bitkind.org in EVM-compatible networks.
When you make a transaction, please verify:
- The contract address you are interacting with.
- That the site domain is indeed
https://bitkind.org
.
- BNB Chain (BSC): 0x60DaF666f75329b740cDd16D2E71f9F04C97f67b
- Ethereum Mainnet: 0x7c570e77518f02ebecafac8ace0ea263abcb44bd
- Base Mainnet: 0x42075e64Fe7B7C158381627a5bdB04Dccb0E4F0A
To deploy the donation contract, run:
DEPLOYER_PRIVATE_KEY={YOUR_SECRET_KEY} \
npx hardhat ignition deploy ignition/modules/Donation.ts --network {NETWORK}
After the donation smart contract is deployed, save its address to run Hardhat tasks. For example:
npx hardhat vars set DONATION_CONTRACT_ADDRESS {CONTRACT_ADDRESS}
- Set Etherscan API key:
npx hardhat vars set ETHERSCAN_API_KEY
- Run the verify script:
DEPLOYER_PRIVATE_KEY={YOUR_SECRET_KEY} \ npx hardhat ignition verify --network {NETWORK} chain-{CHAIN_ID}
Below are the custom Hardhat tasks for token management and withdrawals.
Adds a new token to the allowed tokens list. After that, users can donate in this token.
DEPLOYER_PRIVATE_KEY={YOUR_SECRET_KEY} \
npx hardhat --network {NETWORK} \
add-token \
--contract {TOKEN_CONTRACT_ADDR} \
--symbol {TOKEN_SYMBOL}
Removes a token from the allowed list. Any donation in this token will be rejected afterward.
DEPLOYER_PRIVATE_KEY={YOUR_SECRET_KEY} \
npx hardhat --network {NETWORK} \
delete-token \
--symbol {TOKEN_SYMBOL}
Transfers tips left by users in Ether to a specified address. Specify the amount in Ether (not Wei). The function automatically converts Ether to Wei internally.
DEPLOYER_PRIVATE_KEY={YOUR_SECRET_KEY} \
npx hardhat --network {NETWORK} \
withdraw-native \
--to {RECEIVER_ADDRESS} \
--amount {AMOUNT_ETHER}
Transfers tips left by users in an ERC20 token to a specified address. Specify the amount in Wei. This function does not perform formatting automatically.
DEPLOYER_PRIVATE_KEY={YOUR_SECRET_KEY} \
npx hardhat --network {NETWORK} \
withdraw-token \
--to {RECEIVER_ADDRESS} \
--amount {AMOUNT_WEI} \
--symbol {TOKEN_SYMBOL}
Below is a quick reference for local development.
-
Run a local node
npx hardhat node --hostname 127.0.0.1
-
Deploy an ERC20 token (for testing)
DEPLOYER_PRIVATE_KEY={YOUR_SECRET_KEY} \ npx hardhat ignition deploy ignition/modules/Token.ts --network {NETWORK}
-
Deploy the donation contract
DEPLOYER_PRIVATE_KEY={YOUR_SECRET_KEY} \ npx hardhat ignition deploy ignition/modules/Donation.ts --network {NETWORK}
-
Register a token on the donation contract
DEPLOYER_PRIVATE_KEY={YOUR_SECRET_KEY} \ npx hardhat --network {NETWORK} add-token \ --contract {TOKEN_ADDRESS} \ --symbol {TOKEN_SYMBOL}
Then simply run:
yarn test
This executes your Hardhat tests. You can also specify a network:
yarn test --network {NETWORK}
Be sure to have the local node running (if testing locally) before you run yarn test.
To compile contracts via Yarn:
yarn hardhat compile
To run coverage (if have a coverage plugin):
yarn hardhat coverage