我正试着写一份租车合同。我已经实现了以下addCar ->,以将一辆新车添加到lot rentCar ->中,从而将汽车所有权转移到租车人手中,并创建了一个租车对象。
我想使用erc 721代币,以降低每辆车的价格。我如何实现这一点?例如,我的mint函数应该调用addCar函数吗?我从UI中调用薄荷函数?
发布于 2019-01-03 05:43:43
请参阅ERC-721参考实现页面中的示例https://github.com/0xcert/ethereum-erc721#usage。
pragma solidity 0.5.1;
import "https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol";
import "https://github.com/0xcert/ethereum-erc721/src/contracts/ownership/ownable.sol";
/**
* @dev This is an example contract implementation of NFToken with metadata extension.
*/
contract MyCarCollection is
NFTokenMetadata,
Ownable
{
/**
* @dev Contract constructor. Sets metadata extension `name` and `symbol`.
*/
constructor()
public
{
nftName = "My Car Collection";
nftSymbol = "MCC";
}
/**
* @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 msg.sender.
* @param _uri String representing RFC 3986 URI.
*/
function mint(
address _to,
uint256 _tokenId,
string calldata _uri
)
external
onlyOwner
{
super._mint(_to, _tokenId);
super._setTokenUri(_tokenId, _uri);
}
/**
* @dev Removes a NFT from owner.
* @param _tokenId Which NFT we want to remove.
*/
function burn(
uint256 _tokenId
)
external
onlyOwner
{
super._burn(_tokenId);
}
}https://ethereum.stackexchange.com/questions/52929
复制相似问题