Pragma Solidity Contract

Pragma Solidity ^0.4.8;

Contract PixelsBeach Market {

// You can use this hash to verify the image file containing all the pixelsbeach
string public imageHash = "number here";

address owner;

string public standard = 'PixelsBeach';
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;

uint public nextpixelsbeachIndexToAssign = 0;

bool public allpixelsbeachAssigned = false;
uint public pixelsbeachRemainingToAssign = 0;

//mapping (address => uint) public addressTopixelsbeachIndex;
mapping (uint => address) public pixelsbeachIndexToAddress;

/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;

struct Offer {
    bool isForSale;
    uint pixelsbeachIndex;
    address seller;
    uint minValue;          // in ether
    address onlySellTo;     // specify to sell only to a specific person
}

struct Bid {
    bool hasBid;
    uint pixelsbeachIndex;
    address bidder;
    uint value;
}

// A record of pixelsbeach that are offered for sale at a specific minimum value, and perhaps to a specific person
mapping (uint => Offer) public pixelsbeachOfferedForSale;

// A record of the highest pixelsbeach bid
mapping (uint => Bid) public pixelsbeachBids;

mapping (address => uint) public pendingWithdrawals;

event Assign(address indexed to, uint256 pixelsbeachIndex);
event Transfer(address indexed from, address indexed to, uint256 value);
event pixelsbeachTransfer(address indexed from, address indexed to, uint256 pixelsbeachIndex);
event pixelsbeachOffered(uint indexed pixelsbeachIndex, uint minValue, address indexed toAddress);
event pixelsbeachBidEntered(uint indexed pixelsbeachIndex, uint value, address indexed fromAddress);
event pixelsbeachBidWithdrawn(uint indexed pixelsbeachIndex, uint value, address indexed fromAddress);
event pixelsbeachBought(uint indexed pixelsbeachIndex, uint value, address indexed fromAddress, address indexed toAddress);
event pixelsbeachNoLongerForSale(uint indexed pixelsbeachIndex);

/* Initializes contract with initial supply tokens to the creator of the contract */
function PixelsBeachMarket() payable {
    //        balanceOf[msg.sender] = initialSupply;              // Give the creator all initial tokens
    owner = msg.sender;
    totalSupply = 10000;                        // Update total supply
    pixelsbeachRemainingToAssign = totalSupply;
    name = "PixelsBeach";                                   // Set the name for display purposes
    symbol = "Ͼ";                               // Set the symbol for display purposes
    decimals = 0;                                       // Amount of decimals for display purposes
}

function setInitialOwner(address to, uint pixelsbeachIndex) {
    if (msg.sender != owner) throw;
    if (allpixelsbeachAssigned) throw;
    if (pixelsbeachIndex >= 10000) throw;
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] != to) {
        if (pixelsbeachIndexToAddress[pixelsbeachIndex] != 0x0) {
            balanceOf[pixelsbeachIndexToAddress[pixelsbeachIndex]]--;
        } else {
            pixelsbeachRemainingToAssign--;
        }
        pixelsbeachIndexToAddress[pixelsbeachIndex] = to;
        balanceOf[to]++;
        Assign(to, pixelsbeachIndex);
    }
}

function setInitialOwners(address[] addresses, uint[] indices) {
    if (msg.sender != owner) throw;
    uint n = addresses.length;
    for (uint i = 0; i < n; i++) {
        setInitialOwner(addresses[i], indices[i]);
    }
}

function allInitialOwnersAssigned() {
    if (msg.sender != owner) throw;
    allpixelsbeachAssigned = true;
}

function getpixelsbeach(uint pixelsbeachIndex) {
    if (!allpixelsbeachAssigned) throw;
    if (pixelsbeachRemainingToAssign == 0) throw;
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] != 0x0) throw;
    if (pixelsbeachIndex >= 10000) throw;
    pixelsbeachIndexToAddress[pixelsbeachIndex] = msg.sender;
    balanceOf[msg.sender]++;
    pixelsbeachRemainingToAssign--;
    Assign(msg.sender, pixelsbeachIndex);
}

// Transfer ownership of a pixelsbeach to another user without requiring payment
function transferpixelsbeach(address to, uint pixelsbeachIndex) {
    if (!allpixelsbeachAssigned) throw;
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
    if (pixelsbeachIndex >= 10000) throw;
    if (pixelsbeachOfferedForSale[pixelsbeachIndex].isForSale) {
        pixelsbeachNoLongerForSale(pixelsbeachIndex);
    }
    pixelsbeachIndexToAddress[pixelsbeachIndex] = to;
    balanceOf[msg.sender]--;
    balanceOf[to]++;
    Transfer(msg.sender, to, 1);
    pixelsbeachTransfer(msg.sender, to, pixelsbeachIndex);
    // Check for the case where there is a bid from the new owner and refund it.
    // Any other bid can stay in place.
    Bid bid = pixelsbeachBids[pixelsbeachIndex];
    if (bid.bidder == to) {
        // Kill bid and refund value
        pendingWithdrawals[to] += bid.value;
        pixelsbeachBids[pixelsbeachIndex] = Bid(false, pixelsbeachIndex, 0x0, 0);
    }
}

function pixelsbeachNoLongerForSale(uint pixelsbeachIndex) {
    if (!allpixelsbeachAssigned) throw;
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
    if (pixelsbeachIndex >= 10000) throw;
    pixelsbeachOfferedForSale[pixelsbeachIndex] = Offer(false, pixelsbeachIndex, msg.sender, 0, 0x0);
    pixelsbeachNoLongerForSale(pixelsbeachIndex);
}

function offerpixelsbeachForSale(uint pixelsbeachIndex, uint minSalePriceInWei) {
    if (!allpixelsbeachAssigned) throw;
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
    if (pixelsbeachIndex >= 10000) throw;
    pixelsbeachOfferedForSale[pixelsbeachIndex] = Offer(true, pixelsbeachIndex, msg.sender, minSalePriceInWei, 0x0);
    pixelsbeachOffered(pixelsbeachIndex, minSalePriceInWei, 0x0);
}

function offerpixelsbeachForSaleToAddress(uint pixelsbeachIndex, uint minSalePriceInWei, address toAddress) {
    if (!allpixelsbeachAssigned) throw;
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
    if (pixelsbeachIndex >= 10000) throw;
    pixelsbeachOfferedForSale[pixelsbeachIndex] = Offer(true, pixelsbeachIndex, msg.sender, minSalePriceInWei, toAddress);
    pixelsbeachOffered(pixelsbeachIndex, minSalePriceInWei, toAddress);
}

function buypixelsbeach(uint pixelsbeachIndex) payable {
    if (!allpixelsbeachAssigned) throw;
    Offer offer = pixelsbeachOfferedForSale[pixelsbeachIndex];
    if (pixelsbeachIndex >= 10000) throw;
    if (!offer.isForSale) throw;                // pixelsbeach not actually for sale
    if (offer.onlySellTo != 0x0 && offer.onlySellTo != msg.sender) throw;  // pixelsbeach not supposed to be sold to this user
    if (msg.value < offer.minValue) throw;      // Didn't send enough ETH
    if (offer.seller != pixelsbeachIndexToAddress[pixelsbeachIndex]) throw; // Seller no longer owner of pixelsbeach

    address seller = offer.seller;

    pixelsbeachIndexToAddress[pixelsbeachIndex] = msg.sender;
    balanceOf[seller]--;
    balanceOf[msg.sender]++;
    Transfer(seller, msg.sender, 1);

    pixelsbeachNoLongerForSale(pixelsbeachIndex);
    pendingWithdrawals[seller] += msg.value;
    pixelsbeachBought(pixelsbeachIndex, msg.value, seller, msg.sender);

    // Check for the case where there is a bid from the new owner and refund it.
    // Any other bid can stay in place.
    Bid bid = pixelsbeachBids[pixelsbeachIndex];
    if (bid.bidder == msg.sender) {
        // Kill bid and refund value
        pendingWithdrawals[msg.sender] += bid.value;
        pixelsbeachBids[pixelsbeachIndex] = Bid(false, pixelsbeachIndex, 0x0, 0);
    }
}

function withdraw() {
    if (!allpixelsbeachAssigned) throw;
    uint amount = pendingWithdrawals[msg.sender];
    // Remember to zero the pending refund before
    // sending to prevent re-entrancy attacks
    pendingWithdrawals[msg.sender] = 0;
    msg.sender.transfer(amount);
}

function enterBidForpixelsbeach(uint pixelsbeachIndex) payable {
    if (pixelsbeachIndex >= 10000) throw;
    if (!allpixelsbeachAssigned) throw;                
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] == 0x0) throw;
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] == msg.sender) throw;
    if (msg.value == 0) throw;
    Bid existing = pixelsbeachBids[pixelsbeachIndex];
    if (msg.value <= existing.value) throw;
    if (existing.value > 0) {
        // Refund the failing bid
        pendingWithdrawals[existing.bidder] += existing.value;
    }
    pixelsbeachBids[pixelsbeachIndex] = Bid(true, pixelsbeachIndex, msg.sender, msg.value);
    pixelsbeachBidEntered(pixelsbeachIndex, msg.value, msg.sender);
}

function acceptBidForpixelsbeach(uint pixelsbeachIndex, uint minPrice) {
    if (pixelsbeachIndex >= 10000) throw;
    if (!allpixelsbeachAssigned) throw;                
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
    address seller = msg.sender;
    Bid bid = pixelsbeachBids[pixelsbeachIndex];
    if (bid.value == 0) throw;
    if (bid.value < minPrice) throw;

    pixelsbeachIndexToAddress[pixelsbeachIndex] = bid.bidder;
    balanceOf[seller]--;
    balanceOf[bid.bidder]++;
    Transfer(seller, bid.bidder, 1);

    pixelsbeachOfferedForSale[pixelsbeachIndex] = Offer(false, pixelsbeachIndex, bid.bidder, 0, 0x0);
    uint amount = bid.value;
    pixelsbeachBids[pixelsbeachIndex] = Bid(false, pixelsbeachIndex, 0x0, 0);
    pendingWithdrawals[seller] += amount;
    pixelsbeachBought(pixelsbeachIndex, bid.value, seller, bid.bidder);
}

function withdrawBidForpixelsbeach(uint pixelsbeachIndex) {
    if (pixelsbeachIndex >= 10000) throw;
    if (!allpixelsbeachAssigned) throw;                
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] == 0x0) throw;
    if (pixelsbeachIndexToAddress[pixelsbeachIndex] == msg.sender) throw;
    Bid bid = pixelsbeachBids[pixelsbeachIndex];
    if (bid.bidder != msg.sender) throw;
    pixelsbeachBidWithdrawn(pixelsbeachIndex, bid.value, msg.sender);
    uint amount = bid.value;
    pixelsbeachBids[pixelsbeachIndex] = Bid(false, pixelsbeachIndex, 0x0, 0);
    // Refund the bid money
    msg.sender.transfer(amount);
}

Add New Page

about:blankParagraph: Change block type or styleChange text alignmentAdd title

Pixels Beach Contract Marketplace – Pragma Coding

Pragma Solidity ^0.4.8;


Contract PixelsBeachMarket {

// You can use this hash to verify the image file containing all the pixelsbeach
string public imageHash = "number here";

address owner;

string public standard = 'PixelsBeach';
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;

uint public nextpixelsbeachIndexToAssign = 0;

bool public allpixelsbeachAssigned = false;
uint public pixelsbeachRemainingToAssign = 0;

//mapping (address => uint) public addressTopixelsbeachIndex;
mapping (uint => address) public pixelsbeachIndexToAddress;

/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;

struct Offer {
bool isForSale;
uint pixelsbeachIndex;
address seller;
uint minValue; // in ether
address onlySellTo; // specify to sell only to a specific person
}

struct Bid {
bool hasBid;
uint pixelsbeachIndex;
address bidder;
uint value;
}

// A record of pixelsbeach that are offered for sale at a specific minimum value, and perhaps to a specific person
mapping (uint => Offer) public pixelsbeachOfferedForSale;

// A record of the highest pixelsbeach bid
mapping (uint => Bid) public pixelsbeachBids;

mapping (address => uint) public pendingWithdrawals;

event Assign(address indexed to, uint256 pixelsbeachIndex);
event Transfer(address indexed from, address indexed to, uint256 value);
event pixelsbeachTransfer(address indexed from, address indexed to, uint256 pixelsbeachIndex);
event pixelsbeachOffered(uint indexed pixelsbeachIndex, uint minValue, address indexed toAddress);
event pixelsbeachBidEntered(uint indexed pixelsbeachIndex, uint value, address indexed fromAddress);
event pixelsbeachBidWithdrawn(uint indexed pixelsbeachIndex, uint value, address indexed fromAddress);
event pixelsbeachBought(uint indexed pixelsbeachIndex, uint value, address indexed fromAddress, address indexed toAddress);
event pixelsbeachNoLongerForSale(uint indexed pixelsbeachIndex);

/* Initializes contract with initial supply tokens to the creator of the contract */
function PixelsBeachMarket() payable {
// balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
owner = msg.sender;
totalSupply = 10000; // Update total supply
pixelsbeachRemainingToAssign = totalSupply;
name = "PixelsBeach"; // Set the name for display purposes
symbol = "Ͼ"; // Set the symbol for display purposes
decimals = 0; // Amount of decimals for display purposes
}

function setInitialOwner(address to, uint pixelsbeachIndex) {
if (msg.sender != owner) throw;
if (allpixelsbeachAssigned) throw;
if (pixelsbeachIndex >= 10000) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] != to) {
if (pixelsbeachIndexToAddress[pixelsbeachIndex] != 0x0) {
balanceOf[pixelsbeachIndexToAddress[pixelsbeachIndex]]--;
} else {
pixelsbeachRemainingToAssign--;
}
pixelsbeachIndexToAddress[pixelsbeachIndex] = to;
balanceOf[to]++;
Assign(to, pixelsbeachIndex);
}
}

function setInitialOwners(address[] addresses, uint[] indices) {
if (msg.sender != owner) throw;
uint n = addresses.length;
for (uint i = 0; i < n; i++) {
setInitialOwner(addresses[i], indices[i]);
}
}

function allInitialOwnersAssigned() {
if (msg.sender != owner) throw;
allpixelsbeachAssigned = true;
}

function getpixelsbeach(uint pixelsbeachIndex) {
if (!allpixelsbeachAssigned) throw;
if (pixelsbeachRemainingToAssign == 0) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] != 0x0) throw;
if (pixelsbeachIndex >= 10000) throw;
pixelsbeachIndexToAddress[pixelsbeachIndex] = msg.sender;
balanceOf[msg.sender]++;
pixelsbeachRemainingToAssign--;
Assign(msg.sender, pixelsbeachIndex);
}

// Transfer ownership of a pixelsbeach to another user without requiring payment
function transferpixelsbeach(address to, uint pixelsbeachIndex) {
if (!allpixelsbeachAssigned) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
if (pixelsbeachIndex >= 10000) throw;
if (pixelsbeachOfferedForSale[pixelsbeachIndex].isForSale) {
pixelsbeachNoLongerForSale(pixelsbeachIndex);
}
pixelsbeachIndexToAddress[pixelsbeachIndex] = to;
balanceOf[msg.sender]--;
balanceOf[to]++;
Transfer(msg.sender, to, 1);
pixelsbeachTransfer(msg.sender, to, pixelsbeachIndex);
// Check for the case where there is a bid from the new owner and refund it.
// Any other bid can stay in place.
Bid bid = pixelsbeachBids[pixelsbeachIndex];
if (bid.bidder == to) {
// Kill bid and refund value
pendingWithdrawals[to] += bid.value;
pixelsbeachBids[pixelsbeachIndex] = Bid(false, pixelsbeachIndex, 0x0, 0);
}
}

function pixelsbeachNoLongerForSale(uint pixelsbeachIndex) {
if (!allpixelsbeachAssigned) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
if (pixelsbeachIndex >= 10000) throw;
pixelsbeachOfferedForSale[pixelsbeachIndex] = Offer(false, pixelsbeachIndex, msg.sender, 0, 0x0);
pixelsbeachNoLongerForSale(pixelsbeachIndex);
}

function offerpixelsbeachForSale(uint pixelsbeachIndex, uint minSalePriceInWei) {
if (!allpixelsbeachAssigned) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
if (pixelsbeachIndex >= 10000) throw;
pixelsbeachOfferedForSale[pixelsbeachIndex] = Offer(true, pixelsbeachIndex, msg.sender, minSalePriceInWei, 0x0);
pixelsbeachOffered(pixelsbeachIndex, minSalePriceInWei, 0x0);
}

function offerpixelsbeachForSaleToAddress(uint pixelsbeachIndex, uint minSalePriceInWei, address toAddress) {
if (!allpixelsbeachAssigned) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
if (pixelsbeachIndex >= 10000) throw;
pixelsbeachOfferedForSale[pixelsbeachIndex] = Offer(true, pixelsbeachIndex, msg.sender, minSalePriceInWei, toAddress);
pixelsbeachOffered(pixelsbeachIndex, minSalePriceInWei, toAddress);
}

function buypixelsbeach(uint pixelsbeachIndex) payable {
if (!allpixelsbeachAssigned) throw;
Offer offer = pixelsbeachOfferedForSale[pixelsbeachIndex];
if (pixelsbeachIndex >= 10000) throw;
if (!offer.isForSale) throw; // pixelsbeach not actually for sale
if (offer.onlySellTo != 0x0 && offer.onlySellTo != msg.sender) throw; // pixelsbeach not supposed to be sold to this user
if (msg.value < offer.minValue) throw; // Didn't send enough ETH
if (offer.seller != pixelsbeachIndexToAddress[pixelsbeachIndex]) throw; // Seller no longer owner of pixelsbeach

address seller = offer.seller;

pixelsbeachIndexToAddress[pixelsbeachIndex] = msg.sender;
balanceOf[seller]--;
balanceOf[msg.sender]++;
Transfer(seller, msg.sender, 1);

pixelsbeachNoLongerForSale(pixelsbeachIndex);
pendingWithdrawals[seller] += msg.value;
pixelsbeachBought(pixelsbeachIndex, msg.value, seller, msg.sender);

// Check for the case where there is a bid from the new owner and refund it.
// Any other bid can stay in place.
Bid bid = pixelsbeachBids[pixelsbeachIndex];
if (bid.bidder == msg.sender) {
// Kill bid and refund value
pendingWithdrawals[msg.sender] += bid.value;
pixelsbeachBids[pixelsbeachIndex] = Bid(false, pixelsbeachIndex, 0x0, 0);
}
}

function withdraw() {
if (!allpixelsbeachAssigned) throw;
uint amount = pendingWithdrawals[msg.sender];
// Remember to zero the pending refund before
// sending to prevent re-entrancy attacks
pendingWithdrawals[msg.sender] = 0;
msg.sender.transfer(amount);
}

function enterBidForpixelsbeach(uint pixelsbeachIndex) payable {
if (pixelsbeachIndex >= 10000) throw;
if (!allpixelsbeachAssigned) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] == 0x0) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] == msg.sender) throw;
if (msg.value == 0) throw;
Bid existing = pixelsbeachBids[pixelsbeachIndex];
if (msg.value <= existing.value) throw;
if (existing.value > 0) {
// Refund the failing bid
pendingWithdrawals[existing.bidder] += existing.value;
}
pixelsbeachBids[pixelsbeachIndex] = Bid(true, pixelsbeachIndex, msg.sender, msg.value);
pixelsbeachBidEntered(pixelsbeachIndex, msg.value, msg.sender);
}

function acceptBidForpixelsbeach(uint pixelsbeachIndex, uint minPrice) {
if (pixelsbeachIndex >= 10000) throw;
if (!allpixelsbeachAssigned) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] != msg.sender) throw;
address seller = msg.sender;
Bid bid = pixelsbeachBids[pixelsbeachIndex];
if (bid.value == 0) throw;
if (bid.value < minPrice) throw;

pixelsbeachIndexToAddress[pixelsbeachIndex] = bid.bidder;
balanceOf[seller]--;
balanceOf[bid.bidder]++;
Transfer(seller, bid.bidder, 1);

pixelsbeachOfferedForSale[pixelsbeachIndex] = Offer(false, pixelsbeachIndex, bid.bidder, 0, 0x0);
uint amount = bid.value;
pixelsbeachBids[pixelsbeachIndex] = Bid(false, pixelsbeachIndex, 0x0, 0);
pendingWithdrawals[seller] += amount;
pixelsbeachBought(pixelsbeachIndex, bid.value, seller, bid.bidder);
}

function withdrawBidForpixelsbeach(uint pixelsbeachIndex) {
if (pixelsbeachIndex >= 10000) throw;
if (!allpixelsbeachAssigned) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] == 0x0) throw;
if (pixelsbeachIndexToAddress[pixelsbeachIndex] == msg.sender) throw;
Bid bid = pixelsbeachBids[pixelsbeachIndex];
if (bid.bidder != msg.sender) throw;
pixelsbeachBidWithdrawn(pixelsbeachIndex, bid.value, msg.sender);
uint amount = bid.value;
pixelsbeachBids[pixelsbeachIndex] = Bid(false, pixelsbeachIndex, 0x0, 0);
// Refund the bid money
msg.sender.transfer(amount);
}

}

<–! end >



Free Cryptocurrency

Win up to $200 in Bitcoins every hour, no strings attached! Multiply your bitcoins, free weekly lottery with big prizes, 50% referral commission. https://freebitco.in/?r=8569251



Cryptocurrency Exchanges

Gate.io

Gate.io Buy Ethereum Cryptocurrency. They have the best deals, and also offer many many new coins on the market . Claim your invite now : https://www.gate.io/ref/129542

Coinbase

Coinbase if sign up you can get $10.00 of free Bitcoin when you buy or sell at least $100 of any digital Crypto Currency to your wallet. Once you have the plugin installed, this website will recognize it and add buttons that allow you to bid on, buy and sell them directly in the interface. or you can copy Meta Mask Wallet Address at Top and Send from Any ETH Wallet! Claim your invite now: https://www.coinbase.com/join/jr_pl1 .



Gemini App

Have you seen the Gemini app? Try it using code and get $10 USD of Free Bitcoin.

Claim your invite now: https://gemini.com/share/vgeymr6t8