Skip to content

Commit

Permalink
made updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Sir-Deon committed Oct 16, 2023
1 parent 88d7c12 commit e79ab45
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 14 deletions.
47 changes: 47 additions & 0 deletions contracts/Faucet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

import "./interfaces/ZTokenInterface.sol";

contract Faucet is OwnableUpgradeable {
mapping(string => address) public assets;
address public avax;

event AvaxFinished(address _avax, address faucet, uint256 balance);

function init() external initializer {
__Ownable_init();
}


function setAsset(string memory asset, address _address) external onlyOwner {
require(_address != address(0), "address cannot be a zero address");
assets[asset] = _address;
}

function setAvax(address _address) external onlyOwner {
require(_address != address(0), "address cannot be a zero address");
avax = _address;
}

function getAsset(string memory asset, address receiver) external {
if(IERC20Upgradeable(avax).balanceOf(address(this)) > 0.02 ether){
if(IERC20Upgradeable(avax).balanceOf(msg.sender) < 0.02 ether){
IERC20Upgradeable(avax).approve(address(this), 0.02 ether);
bool _success = IERC20Upgradeable(avax).transferFrom(address(this), msg.sender, 0.02 ether);
if(!_success) revert();

}
} else {
emit AvaxFinished(avax, address(this), IERC20Upgradeable(avax).balanceOf(msg.sender));
}
bool success = ZTokenInterface(assets[asset]).mint(receiver, 1000000 ether);
if(!success) revert();
}


}
28 changes: 14 additions & 14 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ module.exports = {
}
},
networks: {
goerli: {
url: `https://eth-goerli.g.alchemy.com/v2/MIaPbNNNaHPp9qf5cDCOEJPVxJ_GwLVY`,
accounts: [
process.env.TESTNET_PRIVATE_KEY,
],
},
// goerli: {
// url: `https://eth-goerli.g.alchemy.com/v2/MIaPbNNNaHPp9qf5cDCOEJPVxJ_GwLVY`,
// accounts: [
// process.env.TESTNET_PRIVATE_KEY,
// ],
// },
fuji: {
url: `https://omniscient-restless-thunder.avalanche-testnet.discover.quiknode.pro/933a2d24cf1a762fd73a569be25bdec21cb60a9f/ext/bc/C/rpc`,
accounts: [
process.env.TESTNET_PRIVATE_KEY,
"72144489af80f0657a7f7df9e1291e0f9f19f84596e88f80888ab8fa5641993f"
],
chainId: 43113,
},
mainnet: {
url: `https://red-neat-putty.avalanche-mainnet.quiknode.pro/d54c9d0935c483e2f8e70b7a756d882e45cd9e3f/ext/bc/C/rpc/`,
accounts: [
process.env.MAINNET_PRIVATE_KEY,
],
chainId: 43114
}
// mainnet: {
// url: `https://red-neat-putty.avalanche-mainnet.quiknode.pro/d54c9d0935c483e2f8e70b7a756d882e45cd9e3f/ext/bc/C/rpc/`,
// accounts: [
// process.env.MAINNET_PRIVATE_KEY,
// ],
// chainId: 43114
// }
// etherscan: {
// apiKey: process.env.ETHERSCAN_API_KEY,
// },
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions scripts/deploy_faucet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { ethers, upgrades } = require("hardhat");


async function main() {
const Faucet = await ethers.getContractFactory("Faucet");

const faucet = await Faucet.deploy();

await faucet.deployed();

console.log("Faucet deployed to:", faucet.address);


}

main();

0 comments on commit e79ab45

Please sign in to comment.