我正在尝试将智能合约部署到使用oraclizeAPI.sol库代码的私有区块链。 基本上,智能合约是oraclize的一个小实现。
导入不起作用,无论是使用github链接还是使用本地导入,solc编译因导入而失败。
下面两个都不起作用,合同没有通过solc正确编译
1.import "oraclizeAPI.sol";
2.import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
所以,我接下来的方法是将oraclizeAPI.sol的代码直接复制到合同代码文件中。 现在合同得到了正确的编制,但是我在每次部署时都会砸油门。
错误:
The contract couldn't be stored, please check your gas amount.
现在这里是区块链的详细信息。
genesis.json
{
"nonce": "0x0000000000000042",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x4000",
"alloc": {
"84840c340067c75806273d2524dfbae646a7c68f":
{ "balance": "1606938044258990275541962092341162602522202993782792835301376" }
},
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"coinbase": "0x84840c340067c75806273d2524dfbae646a7c68f",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x8000000000000000"
}
我目前正在尝试使用coinbase id来解除合同。
web3.eth.getBlock("latest").gasLimit
132661998547049420
web3.eth.getBalance('0x84840c340067c75806273d2524dfbae646a7c68f').e
60
合同代码:
contract oraclizeExample is usingOraclize {
string public data;
event newOraclizeQuery(string description);
event newData(string data);
event eventC(string data);
function oraclizeExample() payable {
update();
}
function __callback(bytes32 myid, string result) {
if (msg.sender != oraclize_cbAddress()) throw;
data = result;
newData(result);
//return result;
}
function eventCheck(string dataFClient) returns (string) {
eventC(dataFClient);
return dataFClient;
}
function update() payable returns (string) {
newOraclizeQuery("Oraclize query was sent, standing by for the answer..");
oraclize_query("URL", "json(https://jewel-api.herokuapp.com/jewel/58d89d264d59a000110829bb).invoice_num");
return "update function was called!";
}
}
合同创建代码。
var ContractABI = web3.eth.contract(JSON.parse(interface));
var SaveContract = ContractABI.new(
{
from: account,
data: bytecode,
gas: '93048696279858031'
}, function (e, contract) {
if(e){
console.log(e, contract);
return;
}
if (typeof contract.address !== 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
fs.writeFileSync('./contracts_data/'+ contract_name + '_final', 'Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash)
return;
}
});
如果您想查看完整的合同代码以及我的方式,请访问此链接。
https://github.com/utkarsh17ife/oraclizeExample/tree/master/contracts_data
或者节点的完整实现:
https://github.com/utkarsh17ife/oraclizeExample
是的,我可以使用此设置挖掘其他合同。
如果您需要进一步的信息,请注释。
答案 0 :(得分:2)
如果您正在使用私有链,则必须运行ethereum-bridge,因为您的智能合约会在部署(构造函数)上调用oraclize_query函数,但您的链上没有找到Oraclize合约。 / p>