{
address: "0x0a4c2f3a68f3f43999ece62605d5743ab600fda9",
balance: {
type: "BigNumber",
hex: "0x00"
string: "0"
ether: "0.0"
},
"transactions": [],
code: "
/*
Name: YO NFT
Version: 0.0.3
*/
function IERC721Receiver(tokenAddress) {
return address(tokenAddress).getContract();
}
class ERC721Receiver {
onERC721Received(operator, from, tokenId, data) {
const selector = '0xa8fcc417'; // onERC721Received
return [selector];
};
}
ERC721Receiver.prototype.onERC721Received.inputs = ['address', 'address', 'uint256', 'bytes'];
ERC721Receiver.prototype.onERC721Received.outputs = ['bytes4'];
class ERC721 extends ERC721Receiver {
name = '';
symbol = '';
decimals = number(0);
owners = {}; // mapping(uint256 => address)
balances = {}; // mapping(address => uint256)
tokenApprovals = {}; // mapping(uint256 => address)
operatorApprovals = {}; // mapping(address => mapping(address => bool))
Mint(minter, to, tokenId) {} // event
Burn() {owner, burner, tokenId} // event
Transfer(from, to, tokenId) {} // event
Approval(owner, approved, tokenId) {} // event
ApprovalForAll(owner, operator, approved) {} // event
constructor(name, symbol) {
super();
this.name = name;
this.symbol = symbol;
}
supportsInterface(interfaceId) {
//const result = interfaceId == '0x80ac58cd' || interfaceId == '0x5b5e139f' || super.supportsInterface(interfaceId);
const result = (interfaceId == '0x80ac58cd' || interfaceId == '0x5b5e139f');
return [result];
}
balanceOf(owner) {
owner = owner.toLowerCase();
require(owner != address(0).address, "ERC721: address zero is not a valid owner");
if (owner in this.balances) {
return [this.balances[owner]];
}
return [Number(0)];
}
ownerOf(tokenId) {
require(tokenId in this.owners, "ERC721: owner query for nonexistent token");
const owner = this.owners[tokenId];
return [owner];
}
tokenURI(tokenId) {
require(this._exists(tokenId)[0], "ERC721Metadata: URI query for nonexistent token");
const baseURI = this.baseURI()[0];
const _tokenUri = baseURI.length > 0 ? (baseURI + tokenId.toString()) : "";
return [_tokenUri];
}
_baseURI() {
return [""];
}
approve(to, tokenId) {
to = to.toLowerCase();
require(this._exists(tokenId)[0], "ERC721: approval nonexistent token");
const owner = this.ownerOf(tokenId)[0];
require(to != owner, "ERC721: approval to current owner");
require(
msg.sender == owner || this.isApprovedForAll(owner, msg.sender)[0],
"ERC721: approve caller is not owner nor approved for all"
);
this._approve(to, tokenId);
}
getApproved(tokenId) {
require(this._exists(tokenId)[0], "ERC721: approved query for nonexistent token");
if (tokenId in this.tokenApprovals) {
return [ this.tokenApprovals[tokenId] ];
}
return [ number(0) ];
}
setApprovalForAll(operator, approved) {
operator = operator.toLowerCase();
this._setApprovalForAll(msg.sender, operator, approved);
}
isApprovedForAll(owner, operator) {
owner = owner.toLowerCase();
operator = operator.toLowerCase();
if (owner in this.operatorApprovals && operator in this.operatorApprovals[owner]) {
return [ this.operatorApprovals[owner][operator] ];
}
return [false];
}
transferFrom(from, to, tokenId) {
from = from.toLowerCase();
to = to.toLowerCase();
require(this._isApprovedOrOwner(msg.sender, tokenId)[0], "ERC721: transfer caller is not owner nor approved");
this._transfer(from, to, tokenId);
}
safeTransferFrom(from, to, tokenId, _data) {
from = from.toLowerCase();
to = to.toLowerCase();
require(this._isApprovedOrOwner(msg.sender, tokenId)[0], "ERC721: transfer caller is not owner nor approved");
this._safeTransfer(from, to, tokenId, _data);
}
_safeTransfer(from, to, tokenId, _data) {
from = from.toLowerCase();
to = to.toLowerCase();
this._transfer(from, to, tokenId);
require(this._checkOnERC721Received(from, to, tokenId, _data)[0], "ERC721: transfer to non ERC721Receiver implementer");
}
_exists(tokenId) {
return [ tokenId in this.owners ];
}
_isApprovedOrOwner(spender, tokenId) {
spender = spender.toLowerCase();
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
const owner = this.ownerOf(tokenId)[0];
const result = (spender == owner || this.isApprovedForAll(owner, spender)[0] || this.getApproved(tokenId)[0] == spender);
return [result];
}
_safeMint(to, tokenId, _data) {
to = to.toLowerCase();
this._mint(to, tokenId);
require(
this._checkOnERC721Received(address(0).address, to, tokenId, _data)[0],
"ERC721: transfer to non ERC721Receiver implementer"
);
}
_mint(to, tokenId) {
to = to.toLowerCase();
require(to != address(0).address, "ERC721: mint to the zero address");
require(!this._exists(tokenId)[0], "ERC721: token already minted");
this._beforeTokenTransfer(address(0).address, to, tokenId);
this.balances[to] = this.balances[to] || number(0);
this.balances[to] = this.balances[to].add(1);
this.owners[tokenId] = to;
emit('Mint', [address(0).address, to, tokenId]);
this._afterTokenTransfer(address(0).address, to, tokenId);
}
_burn(tokenId) {
const owner = this.ownerOf(tokenId)[0];
this._beforeTokenTransfer(owner, address(0).address, tokenId);
// Clear approvals
this._approve(address(0).address, tokenId);
this.balances[owner] = this.balances[owner].sub(1);
delete this.owners[tokenId];
emit('Burn', [owner, address(0).address, tokenId]);
_afterTokenTransfer(owner, address(0).address, tokenId);
}
_transfer(from, to, tokenId) {
from = from.toLowerCase();
to = to.toLowerCase();
require(this.ownerOf(tokenId)[0] == from, "ERC721: transfer from incorrect owner");
require(to != address(0).address, "ERC721: transfer to the zero address");
this._beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
this._approve(address(0).address, tokenId);
this.balances[from] = this.balances[from].sub(1);
this.balances[to] = this.balances[to] || number(0);
this.balances[to] = this.balances[to].add(1);
this.owners[tokenId] = to;
emit('Transfer', [from, to, tokenId]);
this._afterTokenTransfer(from, to, tokenId);
}
_approve(approved, tokenId) {
approved = approved.toLowerCase();
this.tokenApprovals[tokenId] = approved;
emit('Approval', [this.ownerOf(tokenId)[0], approved, tokenId]);
}
_setApprovalForAll(owner, operator, approved) {
owner = owner.toLowerCase();
operator = operator.toLowerCase();
require(owner != operator, "ERC721: approve to caller");
if (! (owner in this.operatorApprovals)) {
this.operatorApprovals[owner] = {};
}
this.operatorApprovals[owner][operator] = approved;
emit('ApprovalForAll', [owner, operator, approved]);
}
_checkOnERC721Received(from, to, tokenId, _data) {
from = from.toLowerCase();
to = to.toLowerCase();
if (address(to).isContract()) {
try {
const retval = IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, _data)[0];
const selector = '0xa8fcc417'; // onERC721Received
return [retval == selector];
} catch (e) {
const reason = e.message;
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
revert(reason);
}
}
} else {
return [true];
}
}
_beforeTokenTransfer(from, to, tokenId) {
}
_afterTokenTransfer(from, to, tokenId) {
}
}
// Events
ERC721.prototype.Mint.event = true;
ERC721.prototype.Mint.inputs = ['address indexed', 'address indexed', 'uint256'];
ERC721.prototype.Burn.event = true;
ERC721.prototype.Burn.inputs = ['address indexed', 'address indexed', 'uint256'];
ERC721.prototype.Transfer.event = true;
ERC721.prototype.Transfer.inputs = ['address indexed', 'address indexed', 'uint256'];
ERC721.prototype.Approval.event = true;
ERC721.prototype.Approval.inputs = ['address indexed', 'address indexed', 'uint256'];
ERC721.prototype.ApprovalForAll.event = true;
ERC721.prototype.ApprovalForAll.inputs = ['address indexed', 'address indexed', 'uint256'];
// Methods
ERC721.prototype.supportsInterface.view = true;
ERC721.prototype.supportsInterface.inputs = ['bytes4'];
ERC721.prototype.supportsInterface.outputs = ['bool'];
ERC721.prototype.balanceOf.view = true;
ERC721.prototype.balanceOf.inputs = ['address'];
ERC721.prototype.balanceOf.outputs = ['uint256'];
ERC721.prototype.ownerOf.view = true;
ERC721.prototype.ownerOf.inputs = ['uint256'];
ERC721.prototype.ownerOf.outputs = ['address'];
ERC721.prototype.tokenURI.view = true;
ERC721.prototype.tokenURI.inputs = ['uint256'];
ERC721.prototype.tokenURI.outputs = ['string'];
ERC721.prototype._baseURI.internal = true;
ERC721.prototype.approve.inputs = ['address', 'uint256'];
ERC721.prototype.getApproved.view = true;
ERC721.prototype.getApproved.outputs = ['address'];
ERC721.prototype.setApprovalForAll.inputs = ['address', 'bool'];
ERC721.prototype.isApprovedForAll.view = true;
ERC721.prototype.isApprovedForAll.inputs = ['address', 'address'];
ERC721.prototype.transferFrom.inputs = ['address', 'address', 'uint256'];
ERC721.prototype.safeTransferFrom.inputs = ['address', 'address', 'uint256', 'bytes'];
ERC721.prototype._safeTransfer.internal = true;
ERC721.prototype._exists.internal = true;
ERC721.prototype._isApprovedOrOwner.internal = true;
ERC721.prototype._safeMint.internal = true;
ERC721.prototype._mint.internal = true;
ERC721.prototype._burn.internal = true;
ERC721.prototype._transfer.internal = true;
ERC721.prototype._approve.internal = true;
ERC721.prototype._setApprovalForAll.internal = true;
ERC721.prototype._checkOnERC721Received.private = true;
ERC721.prototype._beforeTokenTransfer.internal = true;
ERC721.prototype._afterTokenTransfer.internal = true;
class YoNFT extends ERC721 {
name = 'YO NFT';
symbol = 'YoNFT';
_tokenIds = 0;
_MAX_SUPPLY = 10;
mintprice = number('1' + '000000000000000000'); // 1 ether
_baseURI() {
const baseURI = 'http://localhost:8545/collections/' + address(this).address + '/';
return [ baseURI ];
}
tokenURI(tokenId) {
require(this._exists(tokenId)[0], "ERC721Metadata: URI query for nonexistent token");
const baseURI = this.baseURI()[0];
const _tokenUri = baseURI.length > 0 ? (baseURI + tokenId.toString() + '.json') : "";
return [_tokenUri];
}
mint(receiver) {
require(this._tokenIds < this._MAX_SUPPLY, 'Max supply reached');
require(msg.value.eq(this.mintprice), 'Invalid price');
this._tokenIds++;
const newNftTokenId = this._tokenIds;
this._safeMint(receiver, newNftTokenId, '');
return [newNftTokenId];
}
}
// Methods
YoNFT.prototype.tokenURI.inputs = ['uint256'];
YoNFT.prototype.tokenURI.outputs = ['string'];
YoNFT.prototype.tokenURI.view = true;
YoNFT.prototype.mint.inputs = ['address'];
YoNFT.prototype.mint.outputs = ['uint256'];
YoNFT.prototype.mint.modifiers = ['onlyOwner'];
YoNFT.prototype.mint.payable = true;
return YoNFT;
",
codeHash: "0xe4a23e6b844c15d980c4a4510d94b4928d7a871db5358a6dd2b0f09cfdf61ef1",
codeAbi: {
0x06fdde03: {
constant: true,
"inputs": [],
name: "name",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x95d89b41: {
constant: true,
"inputs": [],
name: "symbol",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x313ce567: {
constant: true,
"inputs": [],
name: "decimals",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0xaffe39c1: {
constant: true,
"inputs": [],
name: "owners",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x7bb98a68: {
constant: true,
"inputs": [],
name: "balances",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x2369fde5: {
constant: true,
"inputs": [],
name: "tokenApprovals",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x771149fc: {
constant: true,
"inputs": [],
name: "operatorApprovals",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x88eab676: {
constant: true,
"inputs": [],
name: "mintprice",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0xa8ac9b50: {
constant: true,
"inputs": [],
name: "prototype",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x6a627842: {
inputs: [
{
name: "receiver",
type: "address"
}
],
name: "mint",
outputs: [
{
name: "",
type: "uint256"
}
],
stateMutability: "payable",
type: "function"
},
0xab8530f8: {
inputs: [
{
name: "minter",
type: "address",
indexed: true
},
{
name: "to",
type: "address",
indexed: true
},
{
name: "tokenId",
type: "uint256",
indexed: false
}
],
name: "Mint",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0x396ed0ab: {
"inputs": [],
name: "Burn",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0xddf252ad: {
inputs: [
{
name: "from",
type: "address",
indexed: true
},
{
name: "to",
type: "address",
indexed: true
},
{
name: "tokenId",
type: "uint256",
indexed: false
}
],
name: "Transfer",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0x8c5be1e5: {
inputs: [
{
name: "owner",
type: "address",
indexed: true
},
{
name: "approved",
type: "address",
indexed: true
},
{
name: "tokenId",
type: "uint256",
indexed: false
}
],
name: "Approval",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0x935230e6: {
inputs: [
{
name: "owner",
type: "address",
indexed: true
},
{
name: "operator",
type: "address",
indexed: true
},
{
name: "approved",
type: "uint256",
indexed: false
}
],
name: "ApprovalForAll",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0x01ffc9a7: {
inputs: [
{
name: "interfaceId",
type: "bytes4"
}
],
name: "supportsInterface",
outputs: [
{
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
0x70a08231: {
inputs: [
{
name: "owner",
type: "address"
}
],
name: "balanceOf",
outputs: [
{
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
0x6352211e: {
inputs: [
{
name: "tokenId",
type: "uint256"
}
],
name: "ownerOf",
outputs: [
{
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
0xc87b56dd: {
inputs: [
{
name: "tokenId",
type: "uint256"
}
],
name: "tokenURI",
outputs: [
{
name: "",
type: "string"
}
],
stateMutability: "view",
type: "function"
},
0x095ea7b3: {
inputs: [
{
name: "to",
type: "address"
},
{
name: "tokenId",
type: "uint256"
}
],
name: "approve",
"outputs": [],
stateMutability: "nonpayable",
type: "function"
},
0x081812fc: {
inputs: [
{
name: "tokenId",
type: "uint256"
}
],
name: "getApproved",
outputs: [
{
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
0xa22cb465: {
inputs: [
{
name: "operator",
type: "address"
},
{
name: "approved",
type: "bool"
}
],
name: "setApprovalForAll",
"outputs": [],
stateMutability: "nonpayable",
type: "function"
},
0xe985e9c5: {
inputs: [
{
name: "owner",
type: "address"
},
{
name: "operator",
type: "address"
}
],
name: "isApprovedForAll",
"outputs": [],
stateMutability: "view",
type: "function"
},
0x23b872dd: {
inputs: [
{
name: "from",
type: "address"
},
{
name: "to",
type: "address"
},
{
name: "tokenId",
type: "uint256"
}
],
name: "transferFrom",
"outputs": [],
stateMutability: "nonpayable",
type: "function"
},
0xb88d4fde: {
inputs: [
{
name: "from",
type: "address"
},
{
name: "to",
type: "address"
},
{
name: "tokenId",
type: "uint256"
},
{
name: "_data",
type: "bytes"
}
],
name: "safeTransferFrom",
"outputs": [],
stateMutability: "nonpayable",
type: "function"
},
0x150b7a02: {
inputs: [
{
name: "operator",
type: "address"
},
{
name: "from",
type: "address"
},
{
name: "tokenId",
type: "uint256"
},
{
name: "data",
type: "bytes"
}
],
name: "onERC721Received",
outputs: [
{
name: "",
type: "bytes4"
}
],
stateMutability: "nonpayable",
type: "function"
}
},
contractName: "YoNFT",
storage: {
name: "YO NFT",
symbol: "YoNFT",
decimals: {
type: "BigNumber",
hex: "0x00"
string: "0"
ether: "0.0"
},
"owners": {},
"balances": {},
"tokenApprovals": {},
"operatorApprovals": {},
_tokenIds: 0,
_MAX_SUPPLY: 10,
mintprice: {
type: "BigNumber",
hex: "0x0de0b6b3a7640000"
string: "1000000000000000000"
ether: "1.0"
},
prototype: {
address: "0x0a4c2f3a68f3f43999ece62605d5743ab600fda9"
}
},
storageHash: "0xb48d38f93eaa084033fc5970bf96e559c33c4cdc07d889ab00b4d63f9590739d",
savedOnBlockNumber: {
type: "BigNumber",
hex: "0x04"
string: "4"
ether: "0.000000000000000004"
}
}