首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ERC 721租赁合同

ERC 721租赁合同
EN

Ethereum用户
提问于 2018-07-08 15:57:55
回答 1查看 732关注 0票数 1

我正试着写一份租车合同。我已经实现了以下addCar ->,以将一辆新车添加到lot rentCar ->中,从而将汽车所有权转移到租车人手中,并创建了一个租车对象。

我想使用erc 721代币,以降低每辆车的价格。我如何实现这一点?例如,我的mint函数应该调用addCar函数吗?我从UI中调用薄荷函数?

EN

回答 1

Ethereum用户

发布于 2019-01-03 05:43:43

请参阅ERC-721参考实现页面中的示例https://github.com/0xcert/ethereum-erc721#usage

代码语言:javascript
复制
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);
  }

}
票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/52929

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档