0

我在这里建立自己的合同: https ://www.blockcypher.com/dev/ethereum/#create-contract-endpoint

引擎.PHP

<?php
function blockcypher($method,$page,$data = ""){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://api.blockcypher.com/v1/".$page);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    if($data != ''){
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);

    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

    $headers = array();
    $headers[] = 'Content-Type: application/x-www-form-urlencoded';
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    
    $result = curl_exec($curl);
    if (curl_errno($curl)) {
        echo 'Error:' . curl_error($curl);
    }
    curl_close ($curl);
    return $result;
}
?>

进程.PHP

<?php
session_start();
error_reporting(1);
include 'ENGINE.PHP';

$token = '?token=YOURFREETOKEN';
$server = "eth/main";

$data = "{\"solidity\":\"contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) suicide(owner); } } contract greeter is mortal { string greeting; function greeter(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }\",\"params\":[\"Hello BlockCypher Test\"]}";
$contract_details = blockcypher("POST","$server/contracts$token",$data);
echo "<br><br>USDT Generate Contract: ";
var_dump($contract_details);

PROCESS.PHP 的输出

USDT Generate Contract: string(101) "{"error": "Error compiling Solidity source code: fork/exec /usr/bin/solc: no such file or directory"}"

我收到了这个错误,不知道问题出在哪里,因为对这类事情的了解太少了。

代码示例: https ://paiza.io/projects/XNbO9tM4UwxL-NPaxY1Wcw?language=php

4

1 回答 1

1

编译 Solidity 源代码时出错:fork/exec /usr/bin/solc: no such file or directory

这是 Blockcypher 方面的一个错误。您可能想向他们报告。

solc是一个“solidity 编译器”以及它的作用——它将文本源代码和配置(例如您正在使用的 Solidity 版本,是否要运行优化器,...)作为输入,并返回字节码、ABI 和元数据作为输出。

因此,当您调用 Blockchypher 端点时,他们的系统会尝试打开二进制文件/usr/bin/solc。但是该文件在他们的系统上放错了位置,并且端点返回此错误。

于 2021-03-11T09:41:15.267 回答