Skip to content

Instantly share code, notes, and snippets.

View AyDeveloper's full-sized avatar

AyDeveloper AyDeveloper

View GitHub Profile
@AyDeveloper
AyDeveloper / index.html
Created March 14, 2023 13:16
Implementation a simple static website
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="IPFS-Website With Unstoppable Domain"/>
<meta name="author" content="IPFS-Website With Unstoppable Domain" />
<title>0xpampam.blockchain</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
contract Parent {
function add(uint _a, uint _b) public pure returns (uint) {
return _a + _b;
}
function getBalance() public view returns (uint) {
return address(this).balance;
}
}
contract VariablePacking {
//Example of an unpacked variable
Struct Unpacked {
uint128 a,
uint256 b,
uint128 c
}
contract A {
function foo() virtual public pure returns (string memory) {
return "Foo from A";
}
function boo() public pure returns (string memory) {
return "Boo from A";
}
contract CustomError {
error InsufficientBalance(uint balance, uint withdrawAmount);
function testCustomError(uint _withdrawAmount) public view {
uint bal = address(this).balance;
if (bal < _withdrawAmount) {
revert InsufficientBalance({balance: bal, withdrawAmount: _withdrawAmount});
}
}
pragma solidity ^0.8.0;
contract Donation {
// input your default donor address
address public donor = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
uint constant DONATION_FEE = 2 ether;
modifier onlyDonor() {
require(msg.sender == donor,"Only buyer can call this.");
library arithmetic {
function add(uint _a, uint _b) returns (uint) {
return _a + _b;
}
}
contract C {
using arithmetic for uint;
library arithmetic {
function multiply(uint _a, uint _b) returns (uint) {
return _a * _b;
}
}
contract C {
uint timesUp;
pragma solidity ^0.8.0;
contract DepositEther {
event Deposit(
address indexed _from,
uint indexed _id,
uint _value
);
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.0;
abstract contract HelloWorld {
string public message;
constructor(string memory _message){
message = _message;
}