首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在没有错误的情况下生成Blockcypher合同?

如何在没有错误的情况下生成Blockcypher合同?
EN

Stack Overflow用户
提问于 2021-03-11 02:06:36
回答 1查看 94关注 0票数 0

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

ENGINE.PHP

代码语言:javascript
复制
<?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;
}
?>

PROCESS.PHP

代码语言:javascript
复制
<?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的输出

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-11 09:41:15

编译稳固源代码的

错误源代码:叉/exec /usr/bin/solc:没有这样的文件或目录

这是发条密码方面的一个错误。你可能要向他们报告。

solc是一个“稳固编译器”,它所做的一切-它需要文本源代码和配置(例如您使用的Solidity版本,是否要运行优化器,.)作为输入,并返回字节码、ABI和元数据作为输出。

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66575496

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档