1

我对松露和坚固性很陌生,这可能是一个菜鸟错误。

输入时truffle migrate --reset,出现以下错误:

    @openzeppelin/contracts/introspection/ERC165.sol:24:5: Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
    constructor () internal {
    ^ (Relevant source part starts here and spans across multiple lines).   
,@openzeppelin/contracts/token/ERC721/ERC721.sol:93:5: Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
    constructor (string memory name_, string memory symbol_) public {       
    ^ (Relevant source part starts here and spans across multiple lines)

> Artifacts written to C:\Users\greathawkeye\blockchain\abis
> Compiled successfully using:
   - solc: 0.7.6+commit.7338295f.Emscripten.clang

看起来这个警告阻止我编译。这是我的代币和我的迁移合同:

// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;

import '@openzeppelin/contracts/token/ERC721/ERC721.sol';

contract MyToken is ERC721 {
    constructor() ERC721('MyToken', 'MYT') {}
}

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;

contract Migrations {
    address public owner;
    uint256 public last_completed_migration;

    modifier restricted() {
        if (msg.sender == owner) _;
    }

    constructor() {
        owner = msg.sender;
    }

    function setCompleted(uint256 completed) public restricted {
        last_completed_migration = completed;
    }

    function upgrade(address new_address) public restricted {
        Migrations upgraded = Migrations(new_address);
        upgraded.setCompleted(last_completed_migration);
    }
}

truffle version给我这个:

Truffle v5.1.62 (core: 5.1.62)
Solidity - >=0.6.0 <0.8.0 (solc-js)
Node v15.5.0
Web3.js v1.2.9

这是我的truffle-config.js

module.exports = {
  compilers: {
    solc: {
      version: ">=0.6.0 <0.8.0",
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*" // Match any network id
    }
  }
};

4

0 回答 0