Adres bitcoin jak zalozyc - phrase matchless
ownerToOperators[tokenOwner][www.oldyorkcellars.com], NOT_OWNER_OR_OPERATOR); _; } /** * @dev Guarantees that the www.oldyorkcellars.com is allowed to transfer NFT. * @param _tokenId ID of the NFT to transfer. */ modifier canTransfer( uint _tokenId ) { address tokenOwner = idToOwner[_tokenId]; require( tokenOwner == www.oldyorkcellars.com ownerToOperators[tokenOwner][www.oldyorkcellars.com], NOT_OWNER_APPROWED_OR_OPERATOR ); _; } /** * @dev Guarantees that _tokenId is a valid Token. * @param _tokenId ID of the NFT to validate. */ modifier validNFToken( uint _tokenId ) { require(idToOwner[_tokenId] != address(0), NOT_VALID_NFT); _; } /** * @dev Contract constructor. */ constructor() public { supportedInterfaces[0x80ac58cd] = true; // ERC } /** * @dev Transfers the ownership of an NFT from one address to another address. This function can * be changed to payable. * @notice Throws unless `www.oldyorkcellars.com` is the current owner, an authorized operator, or the * approved address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` is * the zero address. Throws if `_tokenId` is not a valid NFT. When transfer is complete, this * function checks if `_to` is a smart contract (code size > 0). If so, it calls * `onERCReceived` on `_to` and throws if the return value is not * `bytes4(keccak("onERCReceived(address,uint,bytes)"))`. * @param _from The current owner of the NFT. * @param _to The new owner. * @param _tokenId The NFT to transfer. * @param _data Additional data with no specified format, sent in call to `_to`. */ function safeTransferFrom( address _from, address _to, uint _tokenId, bytes calldata _data ) external override { _safeTransferFrom(_from, _to, _tokenId, _data); } /** * @dev Transfers the ownership of an NFT from one address to another address. This function can * be changed to payable. * @notice This works identically to the other function with an extra data parameter, except this * function just sets data to "" * @param _from The current owner of the NFT. * @param _to The new owner. * @param _tokenId The NFT to transfer. */ function safeTransferFrom( address _from, address _to, uint _tokenId ) external override { _safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Throws unless `www.oldyorkcellars.com` is the current owner, an authorized operator, or the approved * address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` is the zero * address. Throws if `_tokenId` is not a valid NFT. This function can be changed to payable. * @notice The caller is responsible to confirm that `_to` is capable of receiving NFTs or else * they maybe be permanently lost. * @param _from The current owner of the NFT. * @param _to The new owner. * @param _tokenId The NFT to transfer. */ function transferFrom( address _from, address _to, uint _tokenId ) external override canTransfer(_tokenId) validNFToken(_tokenId) { address tokenOwner = idToOwner[_tokenId]; require(tokenOwner == _from, NOT_OWNER); require(_to != address(0), ZERO_ADDRESS); _transfer(_to, _tokenId); } /** * @dev Set or reaffirm the approved address for an NFT. This function can be changed to payable. * @notice The zero address indicates there is no approved address. Throws unless `www.oldyorkcellars.com` is * the current NFT owner, or an authorized operator of the current owner. * @param _approved Address to be approved for the given NFT ID. * @param _tokenId ID of the token to be approved. */ function approve( address _approved, uint _tokenId ) external override canOperate(_tokenId) validNFToken(_tokenId) { address tokenOwner = idToOwner[_tokenId]; require(_approved != tokenOwner, IS_OWNER); idToApproval[_tokenId] = _approved; emit Approval(tokenOwner, _approved, _tokenId); } /** * @dev Enables or disables approval for a third party ("operator") to manage all of * `www.oldyorkcellars.com`'s assets. It also emits the ApprovalForAll event. * @notice This works even if sender doesn't own any tokens at the time. * @param _operator Address to add to the set of authorized operators. * @param _approved True if the operators is approved, false to revoke approval. */ function setApprovalForAll( address _operator, bool _approved ) external override { ownerToOperators[www.oldyorkcellars.com][_operator] = _approved; emit ApprovalForAll(www.oldyorkcellars.com, _operator, _approved); } /** * @dev Returns the number of NFTs owned by `_owner`. NFTs assigned to the zero address are * considered invalid, and this function throws for queries about the zero address. * @param _owner Address for whom to query the balance. * @return Balance of _owner. */ function balanceOf( address _owner ) external override view returns (uint) { require(_owner != address(0), ZERO_ADDRESS); return _getOwnerNFTCount(_owner); } /** * @dev Returns the address of the owner of the NFT. NFTs assigned to zero address are considered * invalid, and queries about them do throw. * @param _tokenId The identifier for an NFT. * @return _owner Address of _tokenId owner. */ function ownerOf( uint _tokenId ) external override view returns (address _owner) { _owner = idToOwner[_tokenId]; require(_owner != address(0), NOT_VALID_NFT); } /** * @dev Get the approved address for a single NFT. * @notice Throws if `_tokenId` is not a valid NFT. * @param _tokenId ID of the NFT to query the approval of. * @return Address that _tokenId is approved for. */ function getApproved( uint _tokenId ) external override view validNFToken(_tokenId) returns (address) { return idToApproval[_tokenId]; } /** * @dev Checks if `_operator` is an approved operator for `_owner`. * @param _owner The address that owns the NFTs. * @param _operator The address that acts on behalf of the owner. * @return True if approved for all, false otherwise. */ function isApprovedForAll( address _owner, address _operator ) external override view returns (bool) { return ownerToOperators[_owner][_operator]; } /** * @dev Actually preforms the transfer. * @notice Does NO checks. * @param _to Address of a new owner. * @param _tokenId The NFT that is being transferred. */ function _transfer( address _to, uint _tokenId ) internal { address from = idToOwner[_tokenId]; _clearApproval(_tokenId); _removeNFToken(from, _tokenId); _addNFToken(_to, _tokenId); emit Transfer(from, _to, _tokenId); } /** * @dev Mints a new NFT. * @notice This is an internal function which should be called from user-implemented external * mint function. Its purpose is to show and properly initialize data structures when using this * implementation. * @param _to The address that will own the minted NFT. * @param _tokenId of the NFT to be minted by the www.oldyorkcellars.com */ function _mint( address _to, uint _tokenId ) internal virtual { require(_to != address(0), ZERO_ADDRESS); require(idToOwner[_tokenId] == address(0), NFT_ALREADY_EXISTS); _addNFToken(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Burns a NFT. * @notice This is an internal function which should be called from user-implemented external burn * function. Its purpose is to show and properly initialize data structures when using this * implementation. Also, note that this burn implementation allows the minter to re-mint a burned * NFT. * @param _tokenId ID of the NFT to be burned. */ function _burn( uint _tokenId ) internal virtual validNFToken(_tokenId) { address tokenOwner = idToOwner[_tokenId]; _clearApproval(_tokenId); _removeNFToken(tokenOwner, _tokenId); emit Transfer(tokenOwner, address(0), _tokenId); } /** * @dev Removes a NFT from owner. * @notice Use and override this function with caution. Wrong usage can have serious consequences. * @param _from Address from wich we want to remove the NFT. * @param _tokenId Which NFT we want to remove. */ function _removeNFToken( address _from, uint _tokenId ) internal virtual { require(idToOwner[_tokenId] == _from, NOT_OWNER); ownerToNFTokenCount[_from] = ownerToNFTokenCount[_from] - 1; delete idToOwner[_tokenId]; } /** * @dev Assignes a new NFT to owner. * @notice Use and override this function with caution. Wrong usage can have serious consequences. * @param _to Address to wich we want to add the NFT. * @param _tokenId Which NFT we want to add. */ function _addNFToken( address _to, uint _tokenId ) internal virtual { require(idToOwner[_tokenId] == address(0), NFT_ALREADY_EXISTS); idToOwner[_tokenId] = _to; ownerToNFTokenCount[_to] = ownerToNFTokenCount[_to].add(1); } /** * @dev Helper function that gets NFT count of owner. This is needed for overriding in enumerable * extension to remove double storage (gas optimization) of owner nft count. * @param _owner Address for whom to query the count. * @return Number of _owner NFTs. */ function _getOwnerNFTCount( address _owner ) internal virtual view returns (uint) { return ownerToNFTokenCount[_owner]; } /** * @dev Actually perform the safeTransferFrom. * @param _from The current owner of the NFT. * @param _to The new owner. * @param _tokenId The NFT to transfer. * @param _data Additional data with no specified format, sent in call to `_to`. */ function _safeTransferFrom( address _from, address _to, uint _tokenId, bytes memory _data ) private canTransfer(_tokenId) validNFToken(_tokenId) { address tokenOwner = idToOwner[_tokenId]; require(tokenOwner == _from, NOT_OWNER); require(_to != address(0), ZERO_ADDRESS); _transfer(_to, _tokenId); if (_www.oldyorkcellars.comract()) { bytes4 retval = ERCTokenReceiver(_to).onERCReceived(www.oldyorkcellars.com, _from, _tokenId, _data); require(retval == MAGIC_ON_ERC_RECEIVED, NOT_ABLE_TO_RECEIVE_NFT); } } /** * @dev Clears the current approval of a given NFT ID. * @param _tokenId ID of the NFT to be transferred. */ function _clearApproval( uint _tokenId ) private { if (idToApproval[_tokenId] != address(0)) { delete idToApproval[_tokenId]; } } } /** * @dev Optional metadata extension for ERC non-fungible token standard. * See www.oldyorkcellars.com */ interface ERCMetadata { /** * @dev Returns a descriptive name for a collection of NFTs in this contract. * @return _name Representing name. */ function name() external view returns (string memory _name); /** * @dev Returns a abbreviated name for a collection of NFTs in this contract. * @return _symbol Representing symbol. */ function symbol() external view returns (string memory _symbol); /** * @dev Returns a distinct Uniform Resource Identifier (URI) for a given asset. It Throws if * `_tokenId` is not a valid NFT. URIs are defined in RFC The URI may point to a JSON file * that conforms to the "ERC Metadata JSON Schema". * @return URI of _tokenId. */ function tokenURI(uint _tokenId) external view returns (string memory); } /** * @dev Optional metadata implementation for ERC non-fungible token standard. */ contract NFTokenMetadata is NFToken, ERCMetadata { /** * @dev A descriptive name for a collection of NFTs. */ string internal nftName; /** * @dev An abbreviated name for NFTokens. */ string internal nftSymbol; /** * @dev Mapping from NFT ID to metadata uri. */ mapping (uint => string) internal idToUri; /** * @dev Contract constructor. * @notice When implementing this contract don't forget to set nftName and nftSymbol. */ constructor() public { supportedInterfaces[0x5b5ef] = true; // ERCMetadata } /** * @dev Returns a descriptive name for a collection of NFTokens. * @return _name Representing name. */ function name() external override view returns (string memory _name) { _name = nftName; } /** * @dev Returns an abbreviated name for NFTokens. * @return _symbol Representing symbol. */ function symbol() external override view returns (string memory _symbol) { _symbol = nftSymbol; } /** * @dev A distinct URI (RFC ) for a given NFT. * @param _tokenId Id for which we want uri. * @return URI of _tokenId. */ function tokenURI( uint _tokenId ) external override view validNFToken(_tokenId) returns (string memory) { return idToUri[_tokenId]; } /** * @dev Burns a NFT. * @notice This is an internal function which should be called from user-implemented external * burn function. Its purpose is to show and properly initialize data structures when using this * implementation. Also, note that this burn implementation allows the minter to re-mint a burned * NFT. * @param _tokenId ID of the NFT to be burned. */ function _burn( uint _tokenId ) internal override virtual { super._burn(_tokenId); if (bytes(idToUri[_tokenId]).length != 0) { delete idToUri[_tokenId]; } } /** * @dev Set a distinct URI (RFC ) for a given NFT ID. * @notice This is an internal function which should be called from user-implemented external * function. Its purpose is to show and properly initialize data structures when using this * implementation. * @param _tokenId Id for which we want uri. * @param _uri String representing RFC URI. */ function _setTokenUri( uint _tokenId, string memory _uri ) internal validNFToken(_tokenId) { idToUri[_tokenId] = _uri; } } /** * @dev The contract has an owner address, and provides basic authorization control whitch * simplifies the implementation of user permissions. This contract is based on the source code at: * www.oldyorkcellars.com */ contract Ownable { /** * @dev Error constants. */ string public constant NOT_CURRENT_OWNER = ""; string public constant CANNOT_TRANSFER_TO_ZERO_ADDRESS = ""; /** * @dev Current owner address. */ address public owner; /** * @dev An event which is triggered when the owner is changed. * @param previousOwner The address of the previous owner. * @param newOwner The address of the new owner. */ event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The constructor sets the original `owner` of the contract to the sender account. */ constructor() public { owner = www.oldyorkcellars.com; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(www.oldyorkcellars.com == owner, NOT_CURRENT_OWNER); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership( address _newOwner ) public onlyOwner { require(_newOwner != address(0), CANNOT_TRANSFER_TO_ZERO_ADDRESS); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } /** * @dev This is an example contract implementation of NFToken with metadata extension. */ contract MyArtSale is NFTokenMetadata, Ownable { /** * @dev Contract constructor. Sets metadata extension `name` and `symbol`. */ constructor() public { nftName = "Konopacki Maurycy"; nftSymbol = "KOM"; } /** * @dev Mints a new NFT. * @param _to The address that will own the minted NFT. * @param _tokenId of the NFT to be minted by the www.oldyorkcellars.com * @param _uri String representing RFC URI. */ function mint( address _to, uint _tokenId, string calldata _uri ) external onlyOwner { super._mint(_to, _tokenId); super._setTokenUri(_tokenId, _uri); } }5) Wyszukujemy (najlepie użyć skrótu klawiszowego CTRL+F) i wpisujemy nasze parametry:
nftName = "Konopacki Maurycy"; <- nazwę naszego tokenu np. CrytpoCitiesnftSymbol = "KOM"; <- skrót/symbol tokenu np. CK6) Kolejnym krokiem jest zainstalowanie portfela MetaMask w formie wtyczki (plugina) na naszą przeglądarkę. MetaMask to portfel obsługujący Ethereum i tokeny, które się na nim znajdują:
Po zainstalowaniu portfel powinien się pojawić w prawym górnym rogu naszej przeglądarki:
7) Po założeniu portfela wchodzimy na nasz w MetaMask i zmieniamy na sieć testową Ropsten. Token możemy tworzyć na głównym łańcuchu Ethereum oraz na testowych, dla treningu warto potrenować na testowych sieciach.
Następnie kopiujemy nasz adres portfela:
8) Po przekopiowaniu naszego adresu wchodzimy na kranik (faucet) dzięki któremu uzyskamy trochę testowych ETH:
Po kliknięciu Send me test Ether pojawi się potwierdzenie wysłanych testowych ETH, które wygląda identycznie jak na głównym łańcuchu ETH:
Do wpuszczenia w sieć naszego tokenu potrzebujemy jedynie dwóch wtyczek na platformie Remix. Wracamy na stronę www.oldyorkcellars.com i wchodzimy w PLUGIN MANAGER:
W search wpisujemy:
- Solidity compiler;
- Deploy & run transactions;
aktywujemy obie wtyczki.
9) Wchodzimy w Solidity compiler i z listy wyszukujemy wersję +www.oldyorkcellars.com
Klikamy Compile Token_www.oldyorkcellars.com oczywiście tutaj będzie nazwa Waszego projektu. Plugin sprawdza poprawność naszego smart contractu może to potrwać do minuty przy weryfikacji kodu tokenu. Jeśli nasz kod będzie poprawny wyświetli nam się informacja o możliwości publikacji i sprawdzeniu szczegółów Publish on Swarm, Publish on Ipfs i Compilation Details:
Jeśli mamy błąd to wyświetli się następujący komunikat informujący, gdzie jest niespójność:
10) Wchodzimy w Deploy & run transactions. Z Environment wybieramy Injected Web3 oraz z CONTRACT MyArtSale browser/Tutaj będzie nazwa naszego projektu.sol. Jeśli instalowaliśmy portfel MetaMask w trakcie pracy na www.oldyorkcellars.com, wówczas konieczne będzie odświeżenie strony i ponowne skompilowanie naszego kodu.
Wirtualna maszyna ETH będzie prosiła o połączenie z naszym portfelem MetaMask:
*Oczywiście jeśli zmienimy sieć na główny łańcuch to smart contract będzie tam funkcjonował:
Klikamy Deploy, aby nasz smart contract w formie tokenu został stworzony:
IDE poprosi nas o uiszczenie opłaty za stworzenie smart contractu w formie GAS-u (mały ułamek ETH):
Klikamy Potwierdź i czekamy kilkanaście sekund na stworzenie naszego smart contractu:
Na explorerze wygląda to następująco:
11) Wysyłanie tokenu ERC na konkretny adres z danym ID.
Rozwijamy MYARTSALE ATOXC1DF (BLOCKCHAIN).
W miejscu mint:
_to: address <- obowiązkowo wypełniamy - wpisujemy adres na który ma trafić token ERC _tokenId: unit <- opcjonalnie wypełniamy - ID, czyli jego unikalność (będzie tylko jeden z takim ID w ramach naszego tokenu) np. 1 lub Jeśli pozostawimy puste pole ID będzie "0" _url: string <- opcjonalnie wypełniamy - tekst, który będzie możliwy do rozkodowaniaPo kliknieciu transact poprosi nas, aby uiścić opłatę za dokonanie transakcji na smart contracie (procedura identyczna jak podczas generowania smart contractu). Po opłaceniu pojawi się hash którym będziemy mogli podejrzeć przebieg transakcji:
Wchodząc na nasz adres na explorerze zauważymy, że pojawi się kolumna Erc Token Txns będą tam zawarte wszystkie transakcje, które są związane z tokenami ERC
Próba wysłania drugiego takiego tokenu z istniejącym już ID pod naszym smart contractem spotka się z odmową, gdyż może istnieć tylko jedno ID przypisane dla jednego smart contractu. Takich ID możemy wyemitować nieskończenie wiele:
Token możecie dodać również w MetaMasku (lub innym portfelu). Informacje o tym jak to zrobić znajdziecie w artykule Jak stworzyć własny token ERC? [Ethereum] w punkcie
Podsumowanie
Tokeny w formacie ERC są znacznie mniej popularne od ERC, lecz pojawia się ich coraz więcej, gdyż ich potencjał jest ogromny. Smart contract nie jest trudny do napisania. Najczęściej tworzone są w celu potwierdzenia istnienia danego produktu jak np. karty kolekcjonerskiej lub oryginalnego obuwia. W przyszłości mogą służyć w takich dziedzinach jak nieruchomości (ewidencja gruntów) czy prawo (notariat).
Na stronie www.oldyorkcellars.com możemy sprawdzić aktualne statystyki związane z ilością tokenów ERC (wyszczególnione są tokeny, które posiadają największy ruch):
-