Skip to content

Instantly share code, notes, and snippets.

@Beatz748

Beatz748/api.sol Secret

Created Jan 10, 2022
Embed
What would you like to do?
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "https://github.com/provable-things/ethereum-api/blob/master/provableAPI_0.6.sol";
contract RandomExample is usingProvable
{
bytes public result;
bytes32 public queryId;
constructor() public
{
provable_setProof(proofType_Ledger);
}
function __callback(bytes32 _queryId, string memory _result, bytes memory _proof) override public
{
require(msg.sender == provable_cbAddress());
if (provable_randomDS_proofVerify__returnCode(_queryId,_result,_proof)== 0)
result = bytes(_result);
else
result = "Error";
}
function GetRandom(uint8 nrbytes) public payable
{
queryId=provable_newRandomDSQuery(
0,
nrbytes,
200000
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment