【问题标题】:Contract Address cannot receive ETH合约地址收不到 ETH
【发布时间】:2021-06-28 10:27:10
【问题描述】:

我尝试了很多次,但无法将 ETH 转移到合约地址。 https://rinkeby.etherscan.io/address/0xe9d0430dea9b84a9e32801d6e6072175fd48fb85

错误,例如: 警告!合约执行过程中遇到错误 [out of gas] 警告!合约执行过程中遇到错误[执行恢复]

我尝试增加 Gas Limit 但都失败了,我真的很困惑和卡住了。请帮帮我。

【问题讨论】:

    标签: ethereum contract erc20


    【解决方案1】:

    您的合约需要包含 fallback()receive() 函数才能接收 ETH。

    pragma solidity ^0.8.0;
    
    contract JetToken is ERC20 {
        // TODO rest of your code
    
        receive() external payable {
            // you can leave this function body empty
        }
    }
    

    文档:https://docs.soliditylang.org/en/v0.8.6/contracts.html#receive-ether-function

    【讨论】:

      猜你喜欢
      • 2022-01-02
      • 2020-10-25
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 2023-03-15
      • 2022-11-25
      • 2021-12-14
      • 2023-01-28
      相关资源
      最近更新 更多