问题描述
我无法使用 ERC20PresetMinterPauserUpgradeable 铸造令牌。
我不明白这里发生了什么,我正在尝试部署一种简单的 ICO,其中我有一个代币合约 ERC20PresetMinterPauserUpgradeable Paddy。我尝试从第二个合约中部署它,该合约将被授予角色 MINTER、IcoSeller。
调用 IcoSeller.getTokenNameFromPaddy 出错:错误:内部 JSON-RPC 错误。 { "message": "处理过程中出现 VM 异常 交易:还原”,“代码”:-32000,“数据”:{ “0x04c0f0d7e658c964b706f47d7263bb9e291fd02ada2a683259efc397bde4aac3”: { "error": "revert","program_counter": 511,"return": "0x" },"stack": "c: 处理事务时出现 VM 异常:还原\n 函数.c.fromresults (/Users/fabri/.nvm/versions/node/v10.24.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:192416)\n 随时通话 (/Users/fabri/.nvm/versions/node/v10.24.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:42:50402)","name": "c" } }
我想我在这里遗漏了一些东西,但我真的不明白是什么。 我能够编译和部署一切。
帕迪:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/presets/ERC20PresetMinterPauserUpgradeable.sol";
/**
* @title PadelCoin
* @dev it is the coin itself. here I specify the name and the simbol
*
*/
contract Paddy is Initializable,ERC20PresetMinterPauserUpgradeable {
function initializePaddy(string memory _name,string memory _symbol) public initializer{
//create token and gives admin,minter,pauser to who deploys the contract
ERC20PresetMinterPauserUpgradeable.initialize(_name,_symbol);
}
}
我什至无法从 IcoSeller 合同中获取 tokenName。 IcoSeller:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/presets/ERC20PresetMinterPauserUpgradeable.sol";
import "./Paddy.sol";
/**
* @dev //initializes paddy and gives this contract minter,pauser and admin role
**/
contract IcoSeller is Initializable {
ERC20PresetMinterPauserUpgradeable paddy;
function initializeIcoDeployer() public initializer{
paddy.initialize("PaddyCoin","PADDY");
}
/**
* @dev emits Transfer
**/
function sellToPublic(address _to,uint _amount) public{
paddy.mint(_to,_amount);
}
function getTokenNameFromPaddy() public view
returns(string memory name){
return paddy.name();
}
}
这是迁移脚本:
const { deployProxy,upgradeProxy } = require('@openzeppelin/truffle-upgrades');
const IcoSeller = artifacts.require('IcoSeller');
module.exports = async function (deployer) {
const ico = await deployProxy(IcoSeller,{ deployer });
const icoUpgraded = await upgradeProxy(ico.address,IcoSeller,{ deployer });
console.log('Ico Deployed at address: ',ico.address);
console.log('Ico Upgraded at address: ',icoUpgraded.address);
};
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)