NullNet L2 // Chain ID: 448000
↗ Open Fullscreen Remix
Embedded Remix Workspace (Solidity v0.8.20 / EVM Paris)
Remix IDE // Pre-configured for Paris EVM
Starter Smart Contract Templates
Copy any contract source code below and paste it directly into Remix above to compile & deploy onto NullNet.
1. Standard Managed ERC-20
Mintable, Burnable & Ownable
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract CustomManagedToken is ERC20, ERC20Burnable, Ownable {
constructor(
string memory name,
string memory symbol,
uint256 initialSupply
) ERC20(name, symbol) Ownable(msg.sender) {
_mint(msg.sender, initialSupply * (10 ** decimals()));
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}
2. Token Presale Vault
Fundraising & Native LUN Exchange
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
contract TokenPresaleVault is Ownable, ReentrancyGuard {
IERC20 public immutable token;
uint256 public ratePerLun;
uint256 public totalRaised;
bool public saleActive = true;
event TokensPurchased(address indexed buyer, uint256 lunPaid, uint256 tokensReceived);
constructor(address tokenAddress, uint256 _rate) Ownable(msg.sender) {
token = IERC20(tokenAddress);
ratePerLun = _rate;
}
receive() external payable nonReentrant {
require(saleActive, "Presale is not active");
uint256 tokens = msg.value * ratePerLun;
require(token.balanceOf(address(this)) >= tokens, "Insufficient vault token balance");
totalRaised += msg.value;
require(token.transfer(msg.sender, tokens), "Token transfer failed");
emit TokensPurchased(msg.sender, msg.value, tokens);
}
function toggleSale() external onlyOwner {
saleActive = !saleActive;
}
}
3. Liquidity Locker
Time-locked LP Token Vault
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract LiquidityLocker is Ownable {
struct LockInfo {
address token;
uint256 amount;
uint256 unlockTime;
address beneficiary;
}
mapping(uint256 => LockInfo) public locks;
uint256 public lockCount;
event Locked(uint256 indexed lockId, address token, uint256 amount, uint256 unlockTime);
event Withdrawn(uint256 indexed lockId, address beneficiary, uint256 amount);
constructor() Ownable(msg.sender) {}
function lockTokens(address token, uint256 amount, uint256 durationDays) external {
require(amount > 0, "Cannot lock zero tokens");
uint256 unlockTime = block.timestamp + (durationDays * 1 days);
require(IERC20(token).transferFrom(msg.sender, address(this), amount), "Transfer failed");
locks[lockCount] = LockInfo({
token: token,
amount: amount,
unlockTime: unlockTime,
beneficiary: msg.sender
});
emit Locked(lockCount, token, amount, unlockTime);
lockCount++;
}
function withdrawLock(uint256 lockId) external {
LockInfo memory lInfo = locks[lockId];
require(msg.sender == lInfo.beneficiary, "Not authorized beneficiary");
require(block.timestamp >= lInfo.unlockTime, "Tokens are still time-locked");
require(lInfo.amount > 0, "Already withdrawn");
locks[lockId].amount = 0;
require(IERC20(lInfo.token).transfer(lInfo.beneficiary, lInfo.amount), "Transfer failed");
emit Withdrawn(lockId, lInfo.beneficiary, lInfo.amount);
}
}
4. Airdrop Distributor
Merkle Verified Batch Token Drops
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
contract AirdropDistributor is Ownable {
IERC20 public immutable token;
bytes32 public merkleRoot;
mapping(address => bool) public hasClaimed;
event Claimed(address indexed account, uint256 amount);
constructor(address tokenAddress, bytes32 _merkleRoot) Ownable(msg.sender) {
token = IERC20(tokenAddress);
merkleRoot = _merkleRoot;
}
function claim(uint256 amount, bytes32[] calldata merkleProof) external {
require(!hasClaimed[msg.sender], "Drop already claimed by address");
bytes32 node = keccak256(abi.encodePacked(msg.sender, amount));
require(MerkleProof.verify(merkleProof, merkleRoot, node), "Invalid Merkle proof");
hasClaimed[msg.sender] = true;
require(token.transfer(msg.sender, amount), "Transfer failed");
emit Claimed(msg.sender, amount);
}
function updateMerkleRoot(bytes32 _newRoot) external onlyOwner {
merkleRoot = _newRoot;
}
}