无法在红宝石的轨道上运行区块链项目

问题描述

下面是版本说明:

  1. 安装geth(用于登录控制台)-版本:1.9.21稳定

  2. 安装版本(从终端运行solc文件-版本:0.4.26 + commit.4563c3fc.Darwin.appleclang

  3. 安装奇偶校验(为端口8584连接RPC连接)版本:-Parity-Ethereum / v2.7.2-stable-d961010f63-20200205 / x86_64-apple-darwin / rustc1.41.0

  4. 安装Metamask(浏览器扩展)

我已经从Metamask创建了testnet帐户,并通过命令将其导入到我们的系统中:geth account import --datadir“帐户地址” --password“密码”“ pvt密钥” 但是当我们通过(geth console --testnet 2 >> geth.log)进入get控制台并运行eth.accounts [0]时,我们收到了 0eth

howtos

我的Solc文件

pragma solidity ^0.4.2;

contract mortal {
    /* Define variable owner of the type address*/
    address owner;

    /* this function is executed at initialization and sets the owner of the contract */
    function mortal() { owner = msg.sender; }

    /* Function to recover the funds on the contract */
    function kill() { if (msg.sender == owner) selfdestruct(owner); }
}

contract greeter is mortal {
    /* define variable greeting of the type string */
    string greeting;

    /* this runs when the contract is executed */
    function greeter(string _greeting) public {
        greeting = _greeting;
    }

    /* main function */
    function greet() constant returns (string) {
        return greeting;
    }
}

创建合同并部署

@contract = Ethereum::Contract.create(file: "#{Dir.pwd}/contracts/greeter.sol")
@tx = @contract.deploy("Hello")
@link = "https://testnet.etherscan.io/tx/#{@tx}"

每当我运行该程序时,我都会得到 IOError(资金不足。您尝试从其发送交易的帐户资金不足。需要1000000并获得:0。):

我的问题是:

  1. 我们如何获得测试所需的余额以进行交易并创建合同。
  2. 我们如何检查交易是否成功创建并部署到区块链中。

解决方法

你需要用以太币测试来喂养你的钱包。您可以通过 https://faucet.ropsten.be/ 实现这一点,填充您的测试网钱包 etherbase,然后赚取以太币测试