| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- // SPDX-License-Identifier: Apache 2
- pragma solidity ^0.8.0;
- import "./EntropyEvents.sol";
- interface IEntropy is EntropyEvents {
- // Register msg.sender as a randomness provider. The arguments are the provider's configuration parameters
- // and initial commitment. Re-registering the same provider rotates the provider's commitment (and updates
- // the feeInWei).
- //
- // chainLength is the number of values in the hash chain *including* the commitment, that is, chainLength >= 1.
- function register(
- uint128 feeInWei,
- bytes32 commitment,
- bytes calldata commitmentMetadata,
- uint64 chainLength,
- bytes calldata uri
- ) external;
- // Withdraw a portion of the accumulated fees for the provider msg.sender.
- // Calling this function will transfer `amount` wei to the caller (provided that they have accrued a sufficient
- // balance of fees in the contract).
- function withdraw(uint128 amount) external;
- // As a user, request a random number from `provider`. Prior to calling this method, the user should
- // generate a random number x and keep it secret. The user should then compute hash(x) and pass that
- // as the userCommitment argument. (You may call the constructUserCommitment method to compute the hash.)
- //
- // This method returns a sequence number. The user should pass this sequence number to
- // their chosen provider (the exact method for doing so will depend on the provider) to retrieve the provider's
- // number. The user should then call fulfillRequest to construct the final random number.
- //
- // This method will revert unless the caller provides a sufficient fee (at least getFee(provider)) as msg.value.
- // Note that excess value is *not* refunded to the caller.
- function request(
- address provider,
- bytes32 userCommitment,
- bool useBlockHash
- ) external payable returns (uint64 assignedSequenceNumber);
- // Fulfill a request for a random number. This method validates the provided userRandomness and provider's proof
- // against the corresponding commitments in the in-flight request. If both values are validated, this function returns
- // the corresponding random number.
- //
- // Note that this function can only be called once per in-flight request. Calling this function deletes the stored
- // request information (so that the contract doesn't use a linear amount of storage in the number of requests).
- // If you need to use the returned random number more than once, you are responsible for storing it.
- function reveal(
- address provider,
- uint64 sequenceNumber,
- bytes32 userRandomness,
- bytes32 providerRevelation
- ) external returns (bytes32 randomNumber);
- function getProviderInfo(
- address provider
- ) external view returns (EntropyStructs.ProviderInfo memory info);
- function getDefaultProvider() external view returns (address provider);
- function getRequest(
- address provider,
- uint64 sequenceNumber
- ) external view returns (EntropyStructs.Request memory req);
- function getFee(address provider) external view returns (uint128 feeAmount);
- function getAccruedPythFees()
- external
- view
- returns (uint128 accruedPythFeesInWei);
- function setProviderFee(uint128 newFeeInWei) external;
- function setProviderUri(bytes calldata newUri) external;
- function constructUserCommitment(
- bytes32 userRandomness
- ) external pure returns (bytes32 userCommitment);
- function combineRandomValues(
- bytes32 userRandomness,
- bytes32 providerRandomness,
- bytes32 blockHash
- ) external pure returns (bytes32 combinedRandomness);
- }
|