UNPKG

@orao-network/fuel-vrf

Version:

ORAO VRF SDK Verifiable Random Function for the Fuel Network

71 lines (70 loc) 2.79 kB
import { Provider, BN, BigNumberish, Account, TxParams, B256Address, AssetId, Address } from "fuels"; import { VrfImpl } from "./contracts"; import { Option } from "./contracts/common"; import { ContractIdInput, IdentityOutput, RandomnessOutput } from "./contracts/VrfImpl"; /** Deployed contract address */ export declare const MAINNET_CONTRACT_ID = "0xf0b0fcded2b3dcbc529d611300b904df97bf473240ce4679993e418b36b3e8d0"; export declare const TESTNET_CONTRACT_ID = "0x2a8d96911becbe05b2a9f5253c91865f0f4b365ed0e2abab17a35e9fc9c4ac76"; export declare class Vrf { abi: VrfImpl; /** * Returns the provider reference. */ provider(): Provider; /** * Helper returning the network base asset identifier. */ getNetworkBaseAsset(): Promise<AssetId>; /** * Created object will use deployed Vrf instance at the given address. * * Note, that you'll need a configured wallet to perform requests. */ constructor(walletOrProvider: Account | Provider, id?: B256Address | Address); /** * Returns the configured authority (if any). */ getAuthority(): Promise<IdentityOutput | null>; /** * Returns contract balance for the given asset. */ getBalance(asset: B256Address | Address | AssetId): Promise<BN>; /** * Returns the additional asset to pay fees with. * * Returns default asset if additional asset is not configured. */ getAsset(): Promise<B256Address>; /** * Returns the configured fee for the given asset. */ getFee(asset: B256Address | Address | AssetId): Promise<BN>; /** * Returns the list of fulfillment authorities. */ getFulfillmentAuthorities(): Promise<B256Address[]>; /** * Returns the number of received randomness requests. */ getNumRequests(): Promise<BN>; /** * Returns the given randomness request (if exists). */ getRequest(seedHexOrNum: string | BigNumberish): Promise<Option<RandomnessOutput>>; /** * Performs a randomness request. * * Please note, that fees will be paid. Caller is able to choose additional * asset to pay fees, if it is configured (see `getAsset()`). This function * will fall back to the base asset. * * @returns A promise that resolves to an object containing: * - transactionId: A string representing the ID of the submitted transaction. * - requestNum: A BN (Big Number) representing the unique identifier for this randomness request. */ request(seedHex: string, useAdditionalAsset?: boolean, txParams?: TxParams): Promise<{ transactionId: string; requestNum: BN; }>; } export declare function toContractIdInput(value: B256Address | Address): ContractIdInput;