【问题标题】:Unable to run blockchain project with ruby on rails无法使用 ruby​​ on rails 运行区块链项目
【发布时间】:2021-01-14 23:53:21
【问题描述】:

以下是版本说明:

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

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

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

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

我已经从 metamask 创建了 testnet 帐户并通过命令将其导入我们的系统: geth account import --datadir "account address" --password "password" "pvt key" 但是当我们通过 (geth console --testnet 2>>geth.log) 进入 get 控制台并运行 eth.accounts[0] 我们收到 0eth

As you can see the screenshot I have 4.9962 ETH

我的 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. 我们如何检查交易是否成功创建并部署到区块链中。

【问题讨论】:

  • 1.您可以事先在奇偶校验 cli 中查看余额。 2. 获取您的交易哈希并在 etherscan 上搜索,
  • 我通过 geth 创建了帐户,当我们进入 geth 控制台时,它显示为 0。
  • 你连接到哪个区块链?你必须从已经有一些以太币的账户中转出一些余额。
  • 当您创建一个帐户时,它带有 0 个以太币,您必须从某个帐户或水龙头中获取以太币。

标签: ruby-on-rails blockchain ethereum solidity geth


【解决方案1】:

你需要用以太测试来喂你的钱包。你可以通过 https://faucet.ropsten.be/ 来实现,填充你的测试网钱包 etherbase,然后获得以太测试

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多