Skip to content

Instantly share code, notes, and snippets.

@Beatz748

Beatz748/api.sol Secret

Created January 10, 2022 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Beatz748/0c721617ce0817224dd523a5440dad5b to your computer and use it in GitHub Desktop.
Save Beatz748/0c721617ce0817224dd523a5440dad5b to your computer and use it in GitHub Desktop.
// 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