[英]“VM Exception while processing transaction: revert” when using OpenZeppelin ERC721 mint in truffle console
我正在使用帶有簡單薄荷函數的OpenZeppelin的ERC721。 但是, VM Exception while processing transaction: revert
時出現VM Exception while processing transaction: revert
在truffle console
調用函數時VM Exception while processing transaction: revert
我先打開Ganache,然后再遷移truffle migrate --reset
。 然后,我truffle console
,然后設置合同SimpleStorage.deployed().then((instance)=>{app=instance})
。 最后,我調用該函數並得到錯誤app.buyOneToken
這是我的SimpleStorage.sol
pragma solidity >=0.4.21 <0.6.0;
import './MyToken.sol';
contract SimpleStorage {
//The ERC721 token
MyToken public myToken;
uint256 public tokenId;
constructor (MyToken _myToken) public {
myToken = _myToken;
tokenId=0;
}
function buyOneToken() public payable {
myToken.addMinter(msg.sender);
require(myToken.mint(msg.sender, tokenId));
tokenId++;
}
}
這是MyToken.sol
pragma solidity >=0.4.21 <0.6.0;
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol';
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol';
contract MyToken is ERC721Full, ERC721Mintable{
string name;
string symbol;
constructor (string memory _name, string memory _symbol) public
ERC721Full(_name, _symbol) {
// solhint-disable-previous-line no-empty-blocks
name=_name;
symbol=_symbol;
}
}
這是兩個.sol文件2_deploy_contracts.js的遷移
var SimpleStorage = artifacts.require("./SimpleStorage.sol");
var MyToken = artifacts.require("./MyToken.sol");
module.exports = function(deployer) {
const _name = "Like Token";
const _symbol = "LIKE";
deployer.deploy(MyToken, _name, _symbol).then(function(){
return deployer.deploy(SimpleStorage, MyToken.address);
});
};
我有一個修改后的版本,其中僅遷移MyToken.sol
(可以訪問OpenZeppelin的ERC721庫)。 那我可以鑄幣罰款。 但是,當我在遷移后按照上面概述的步驟並使用松露控制台調用該函數時,出現了錯誤。
ERC721Mintable.mint
具有onlyMinter
修飾符。
嘗試添加一個鑄造者地址,然后從該地址調用鑄造者。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.