简体   繁体   English

在智能合约 Fundme 中出现错误,错误是“VM 执行错误。恢复为 0x”

[英]Getting an error in smart contract Fundme, The error is "VM execution error. Reverted to 0x"

//  SPDX-License-Identifier: MIT
pragma solidity >=0.6.6 <0.9.0;

import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";

contract FundMe {
     mapping(address => uint256) public addressToAmountFunded;

   function fund() public payable {
        addressToAmountFunded[msg.sender] += msg.value;

   }

   function getVersion() public view returns (uint256){
        AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
        return priceFeed.version();
   }

   function getPrice() public view returns (uint256){
       AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
       priceFeed.latestRoundData();
   }
}

Your code is correct.你的代码是正确的。 I googled 0x8A753747A1Fa494EC906cE90E9f37563A8AF630e and got this website:我用谷歌搜索了0x8A753747A1Fa494EC906cE90E9f37563A8AF630e并得到了这个网站:

https://docs.chain.link/docs/ethereum-addresses/ https://docs.chain.link/docs/ethereum-addresses/

So the contract address that you are passing is deployed on Rinkeby test network.因此,您传递的合约地址部署在 Rinkeby 测试网络上。 connect to Rinkeby account on metamask wallet, chooce injected web3 in remix environment:连接到 metamask 钱包上的 Rinkeby 帐户,在混音环境中选择注入 web3:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我试图测试这种流动性智能合约代码,但如果显示错误。 流动性类似于ocaml,tezos的智能合约语言。 - I am trying to test this liquidity smart contract code but if shows error. Liquidity is similar to ocaml, tezos's smart contract language. 0x 协议错误:未找到给定网络 ID 的默认合约地址 - 0x Protocol Error: No default contract addresses found for the given network id 使用Web 3连接到智能合约时出错 - Getting error while connecting to smart contract using web 3 在 Hedera 区块链中创建智能合约时出现错误“交易过大” - Getting error "Transaction Oversize" while creating a smart contract in Hedera blockchain 向以太坊智能合约发送价值时出错 - Error sending value to Ethereum smart contract 在币安智能链中部署合约时面临错误 - Facing error on deploying contract in Binance Smart Chain 在Testnet上部署智能合约时出现未知错误,导致合约错误 - Unknown action hi in contract error while deploying smart contract on testnet 如何验证智能合约没有错误? - how to verify smart contract without error? 为 Azure Blockchain Workbench 部署智能合约时出错 - Error on deploying Smart Contract for Azure Blockchain Workbench 尝试运行智能合约时出现解析器错误 - Parser error when trying to run a smart contract
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM