5 在zksync测试网验证报错:Deployed bytecode is not equal to generated one from given source

1684293831611.jpg 合约代码 `// SPDX-License-Identifier: MIT pragma solidity ^0.8.17;interface IERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address to, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address from, address to, uint256 amount ) external returns (bool); }

contract Greeter { function multiTransferToken( address _token, address[] calldata _addresses, uint256[] calldata _amounts ) external { require(_addresses.length == _amounts.length, "Lengths of Addresses and Amounts NOT EQUAL"); IERC20 token = IERC20(_token); uint _amountSum = getSum(_amounts); require(token.allowance(msg.sender, address(this)) > _amountSum, "Need Approve ERC20 token");

    for (uint256 i; i < _addresses.length; i++) {
        token.transferFrom(msg.sender, _addresses[i], _amounts[i]);
    }
}

function multiTransferETH(
    address payable[] calldata _addresses,
    uint256[] calldata _amounts
) public payable {
    require(_addresses.length == _amounts.length, "Lengths of Addresses and Amounts NOT EQUAL");
    uint _amountSum = getSum(_amounts); 
    require(msg.value == _amountSum, "Transfer amount error");
    for (uint256 i = 0; i < _addresses.length; i++) {
        _addresses[i].transfer(_amounts[i]);
    }
}

function getSum(uint256[] calldata _arr) public pure returns(uint sum)
{
    for(uint i = 0; i < _arr.length; i++)
        sum = sum + _arr[i];
}

}

contract MyToken is IERC20 {

mapping(address => uint256) public override balanceOf;

mapping(address => mapping(address => uint256)) public override allowance;

uint256 public override totalSupply; 

string public name;   
string public symbol;  

uint8 public decimals = 1; 

constructor(string memory name_, string memory symbol_){
    name = name_;
    symbol = symbol_;
}

function transfer(address recipient, uint amount) external override returns (bool) {
    balanceOf[msg.sender] -= amount;
    balanceOf[recipient] += amount;
    emit Transfer(msg.sender, recipient, amount);
    return true;
}

function approve(address spender, uint amount) external override returns (bool) {
    allowance[msg.sender][spender] = amount;
    emit Approval(msg.sender, spender, amount);
    return true;
}

function transferFrom(
    address sender,
    address recipient,
    uint amount
) external override returns (bool) {
    allowance[sender][msg.sender] -= amount;
    balanceOf[sender] -= amount;
    balanceOf[recipient] += amount;
    emit Transfer(sender, recipient, amount);
    return true;
}

function mint(uint amount) external{
    balanceOf[msg.sender] += amount;
    totalSupply += amount;
    emit Transfer(address(0), msg.sender, amount);
}

function burn(uint amount) external {
    balanceOf[msg.sender] -= amount;
    totalSupply -= amount;
    emit Transfer(msg.sender, address(0), amount);
}

} `

合约部署能够成功,但是每次验证都是报错 Running deploy script for the Greeter contract The deployment is estimated to cost 0.0001113915 ETH constructor args:0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000094869207468657265210000000000000000000000000000000000000000000000 Greeter was deployed to 0xAF193f194B8ACC1B52b256E6d4F5FA747c563de5 Done in 20.35s.

请先 登录 后评论

1 个回答

Elvis - 智能合约开发工程师
请先 登录 后评论
  • 2 关注
  • 0 收藏,2351 浏览
  • 用户_15321 提出于 2023-05-17 11:25