Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
working over blockchain

Abhishek Chauhan ac12644

🔥
working over blockchain
View GitHub Profile
View AllNfts.js
import React, { useEffect, useState } from 'react';
import Box from '@mui/material/Box';
import { useTheme } from '@mui/material/styles';
import Main from 'layouts/Main';
import Container from 'components/Container';
import Contact from 'components/Contact';
import PortfolioGrid from 'components/PortfolioGrid';
import axios from 'axios';
View Whitelist.sol
pragma solidity ^0.4.23;
import "./CrowdSale.sol";
import "./ownership/Ownable.sol";
/**
* @title WhitelistedCrowdsale
* @dev Crowdsale in which only whitelisted users can contribute.
*/
contract WhitelistedCrowdsale is Crowdsale, Ownable {
mapping(address => bool) public whitelist;
View CrowdSale.sol
function _preValidatePurchase(address _investor, uint256 _weiAmount)
internal
{
require(_investor != address(0));
require(_weiAmount != 0);
}
function _postValidatePurchase(address _investor, uint256 _weiAmount)
internal
{
View AdditionalFeatues.sol
pragma solidity ^0.4.23;
import "./math/SafeMath.sol";
import "./CrowdSale.sol";
contract AdditionalFeatures is Crowdsale {
uint256 public openingTime;
uint256 public closingTime;
uint256 public cap;
/**
* @dev Reverts if not in crowdsale time range.
View CrowdSale.sol
pragma solidity ^0.4.23;
import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol";
import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/ERC20.sol";
contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
View CrowdSale.sol
// Event declaration
event TokenPurchase(
address indexed purchaser,
address indexed investor,
uint256 value,
uint256 amount
);
// Event emit
emit TokenPurchase(msg.sender, _investor, msg.value, tokens);
View CrowdSale.sol
function buyTokens(address _investor) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_investor, weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
// Calculate the token amount
uint256 tokens = _calculateToken(weiAmount);
View CrowdSale.sol
constructor(
uint256 _rate,
address _wallet,
ERC20 _token
) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
View CrowdSale.sol
function calculateToken(uint256 _weiAmount) public view returns (uint256) {
return _weiAmount.mul(rate);
}
View CrowdSale.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract CrowdSale {
// The token sold through the ICO
ERC20 public token;
}