Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
yuyasugano / IERC721
Created January 9, 2019 23:45
ERC721 basic interface
pragma solidity ^0.4.23;
import "../../introspection/IERC165.sol";
/**
* @title ERC721 Non-Fungible Token Standard basic interface
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
@yuyasugano
yuyasugano / CowOwnership
Created January 9, 2019 23:51
Cow ownership smart contract
pragma solidity ^0.4.23;
import "./CowBreeding.sol";
import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol";
/**
* @title ERC721 compatible Cow Standard Basic Implementation
* @dev Implements Cow transfer with inherited OpenZeppelin ERC721
*/
contract CowOwnership is CowBreeding, ERC721 {
@yuyasugano
yuyasugano / ERC721 Burnable
Created January 9, 2019 23:56
ERC721 Burnable implementation
pragma solidity ^0.4.23;
import "./ERC721.sol";
/**
* @title ERC721 Burnable Token
* @dev ERC721 Token that can be irreversibly burned (destroyed).
*/
contract ERC721Burnable is ERC721 {
/**
@yuyasugano
yuyasugano / CowBreeding
Created January 11, 2019 03:26
Cow Breeding frontend sample
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cow Breeding Front-end</title>
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/ethereum/[email protected]/dist/web3.min.js" integrity="sha256-nWBTbvxhJgjslRyuAKJHK+XcZPlCnmIAAMixz6EefVk=" crossorigin="anonymous"></script>
<script language="javascript" type="text/javascript" src="cowbreeding_abi.js"></script>
</head>
<body>
@yuyasugano
yuyasugano / CowBreeding Solidity
Created January 11, 2019 03:30
Cow breeding smart contract
pragma solidity ^0.4.23;
import "./ownable.sol";
import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol";
/**
* @title CowBreeding
* @dev Cow Basic Implementation to breed them and provides basic functions.
*/
contract CowBreeding is Ownable {
@yuyasugano
yuyasugano / ERC721XTokenNFT
Created February 9, 2019 07:01
ERC721XTokenNFT.sol modification for tokenType mapping
mapping(uint256 => uint256) tokenType;
uint256 constant NFT = 1;
uint256 constant FT = 2;
/**
* @dev Returns whether the specified token exists
* @param _tokenId uint256 ID of the token to query the existence of
* @return whether the token exists
*/
@yuyasugano
yuyasugano / CardGame Implementation
Last active February 10, 2019 04:28
CardGame Implementation with multi-fungible token ERC721x
pragma solidity ^0.4.25;
import "erc721x/contracts/Core/ERC721X/ERC721XToken.sol";
import "./Ownable.sol";
contract CardGame is ERC721XToken, Ownable {
mapping(uint => uint) internal tokenIdToIndividualSupply;
mapping(uint => uint) internal nftTokenIdToMouldId;
uint nftTokenIdIndex = 1000000;
@yuyasugano
yuyasugano / Loom_dapp_chain
Created February 16, 2019 10:19
Sample code deploy on loom_dapp_chain
yarn run v1.12.3
$ truffle deploy --network loom_dapp_chain
Compiling ./contracts/Migrations.sol...
Compiling ./contracts/MyCoin.sol...
Compiling ./contracts/MyRinkebyCoin.sol...
Compiling ./contracts/MyRinkebyToken.sol...
Compiling ./contracts/MyToken.sol...
Compiling ./contracts/SimpleStore.sol...
Compiling openzeppelin-solidity/contracts/AddressUtils.sol...
Compiling openzeppelin-solidity/contracts/introspection/ERC165.sol...
@yuyasugano
yuyasugano / ERC721 Metadata
Created March 2, 2019 06:43
ERC721 Metadata implementation
pragma solidity ^0.4.23;
import "./ERC721.sol";
import "./IERC721Metadata.sol";
import "../../introspection/ERC165.sol";
contract ERC721Metadata is ERC165, ERC721, IERC721Metadata {
// Token name
string private _name;
@yuyasugano
yuyasugano / React User Status
Last active April 19, 2019 11:20
Blockstack application React User Status
render() {
const { handleSignOut } = this.props;
const { person } = this.state;
const { username } = this.state;
return (
!isSignInPending() && person ?
<div className="container">
<div className="row">
<div className="col-md-offset-3 col-md-6">