合同“ itemmint”应该标记为抽象

发布于 2025-02-03 06:28:18 字数 883 浏览 1 评论 0 原文

代码

尝试使用KIP37作为基本合同创建合同。它适用于以前版本的 @klaytn/Contracts -0.9.0,但它不适用于 @klaytn/Contracts -1.0.0

//SPDX-License-Identifier: Unlincesed
pragma solidity ^0.8.0;

import "@klaytn/contracts/contracts/KIP/token/KIP37/KIP37.sol";
// this line showing error "Contract ItemMint should be abstract
contract ItemMint is KIP37 {
    string public name;

    constructor(string memory _name) {
        name = _name;
    }

    function mint(address to) public pure returns (bool) {
        require(msg.sender == to , "your are authorized");
        return true;
    }
}

使用npm I @klaytn/Contracts -1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0

code

trying to create contract using KIP37 as base contract. its works fine for the previous version of @klaytn/contracts - 0.9.0, but it is not working for @klaytn/contracts - 1.0.0

//SPDX-License-Identifier: Unlincesed
pragma solidity ^0.8.0;

import "@klaytn/contracts/contracts/KIP/token/KIP37/KIP37.sol";
// this line showing error "Contract ItemMint should be abstract
contract ItemMint is KIP37 {
    string public name;

    constructor(string memory _name) {
        name = _name;
    }

    function mint(address to) public pure returns (bool) {
        require(msg.sender == to , "your are authorized");
        return true;
    }
}

using npm i @klaytn/contracts - 1.0.0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情独悲 2025-02-10 06:28:18

父母 uri _ 的字符串,因此您也需要调用父构造器。

constructor(string memory _name, string memory uri_) KIP37(uri_) {
    name = _name;
}

The parent KIP37 contract defines a constructor that takes one argument - a string named uri_, so you need to invoke the parent constructor as well.

constructor(string memory _name, string memory uri_) KIP37(uri_) {
    name = _name;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文