OPNet
    Preparing search index...

    Class AbstractRpcProviderAbstract

    This class is used to provide an abstract RPC provider.

    AbstractRpcProvider

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    network: Network

    Accessors

    Methods

    • Get the next block gas parameters.

      Returns Promise<BlockGasParameters>

      The gas parameters of the next block

      This method is used to get the next block gas parameters. Such as base gas, gas limit, and gas price.

      await provider.gasParameters();
      

      If something went wrong while calling the contract

    • Get the bitcoin balance of an address.

      Parameters

      • address: string | Address

        The address to get the balance of

      • filterOrdinals: boolean = true

        Whether to filter ordinals or not

      Returns Promise<bigint>

      The balance of the address

      This method is used to get the balance of a bitcoin address.

      await getBalance('bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq');
      
    • Get the bitcoin balances of multiple addresses.

      Parameters

      • addressesLike: string[]

        The addresses to get the balances of

      • filterOrdinals: boolean = true

        Whether to filter ordinals or not

      Returns Promise<Record<string, bigint>>

      The balance of the address

      This method is used to get the balance of a bitcoin address.

      await getBalances(['bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq']);
      
    • Get block by number or hash.

      Parameters

      • blockNumberOrHash: BlockTag

        The block number or hash

      • prefetchTxs: boolean = false

        Whether to prefetch transactions

      Returns Promise<Block>

      The requested block

      This method is used to get a block by its number or hash.

      If the block is not found

      await getBlock(123456);
      
    • Get block by checksum.

      Parameters

      • checksum: string

        The block checksum

      • prefetchTxs: boolean = false

        Whether to prefetch transactions

      Returns Promise<Block>

      The requested block

      This method is used to get a block by its checksum.

      If the block is not found

      await getBlockByChecksum('0xabcdef123456...');
      
    • Get block by hash. This is the same method as getBlock.

      Parameters

      • blockHash: string

        The block hash

      Returns Promise<Block>

      The requested block

      This method is used to get a block by its hash. Note that this method is the same as getBlock.

      If the block is not found

    • Get the latest block number.

      Returns Promise<bigint>

      The latest block number

      This method is used to get the latest block number.

      await getBlockNumber();
      
    • Get multiple blocks by number or hash.

      Parameters

      • blockNumbers: BlockTag[]

        The block numbers or hashes

      • prefetchTxs: boolean = false

        Whether to prefetch transactions

      Returns Promise<Block[]>

      The requested blocks

      This method is used to get multiple blocks by their numbers or hashes.

    • Get block witnesses.

      Parameters

      • height: BigNumberish = -1

        The block number or hash, use -1 for latest block

      • Optionaltrusted: boolean

        Whether to trust the witnesses or not

      • Optionallimit: number

        The maximum number of witnesses to return

      • Optionalpage: number

        The page number of the witnesses

      Returns Promise<BlockWitnesses>

      The witnesses of the block

      This method is used to get the witnesses of a block. This proves that the actions executed inside a block are valid and confirmed by the network. If the minimum number of witnesses are not met, the block is considered as potentially invalid.

      await getBlockWitness(123456n);
      

      If something went wrong while fetching the witnesses

    • Get the chain id.

      Returns Promise<bigint>

      The chain id

      This method is used to get the chain id.

      If something went wrong while fetching the chain id

    • Get the latest challenge to use in a transaction.

      Returns Promise<ChallengeSolution>

      The challenge and epoch data

      This method is used to get the latest challenge along with epoch winner and verification data.

      const challenge = await getChallenge();
      

      If no challenge found or OPNet is not active

    • Get the contract code of an address.

      Parameters

      • address: string | Address

        The address of the contract

      • OptionalonlyBytecode: boolean = false

        Whether to return only the bytecode

      Returns Promise<Buffer<ArrayBufferLike> | ContractData>

      The contract data or bytecode

      This method is used to get the contract code of an address.

      await getCode('tb1pth90usc4f528aqphpjrfkkdm4vy8hxnt5gps6aau2nva6pxeshtqqzlt3a');
      

      If something went wrong while fetching the contract code

    • Get the CSV1 address for a given address.

      Parameters

      • address: Address

        The address to get the CSV1 address for

      Returns IP2WSHAddress

      The CSV1 address

      This method is used to get the CSV1 address for a given address.

      const csv1Address = provider.getCSV1ForAddress(Address.fromString('bcrt1q...'));
      
    • Get an epoch by its hash.

      Parameters

      • epochHash: string

        The epoch hash

      • OptionalincludeSubmissions: boolean = false

        Whether to include submissions in the response

      Returns Promise<Epoch | EpochWithSubmissions>

      The requested epoch

      This method is used to get an epoch by its hash.

      await getEpochByHash('0x1234567890abcdef...');
      

      If something went wrong while fetching the epoch

    • Get an epoch by its number.

      Parameters

      • epochNumber: BigNumberish

        The epoch number (-1 for latest)

      • OptionalincludeSubmissions: boolean = false

        Whether to include submissions in the response

      Returns Promise<Epoch | EpochWithSubmissions>

      The requested epoch

      This method is used to get an epoch by its number.

      await getEpochByNumber(123n);
      

      If something went wrong while fetching the epoch

    • Get the current epoch mining template.

      Returns Promise<EpochTemplate>

      The epoch template

      This method is used to get the current epoch mining template with target hash and requirements.

      await getEpochTemplate();
      

      If something went wrong while fetching the template

    • Get the latest epoch.

      Parameters

      • includeSubmissions: boolean

      Returns Promise<Epoch>

      The latest epoch

      This method is used to get the latest epoch in the OPNet protocol.

      await getLatestEpoch();
      

      If something went wrong while fetching the epoch

    • Get the current connected network type.

      Returns Network

      The current connected network type

      This method is used to get the current connected network type.

      If the chain id is invalid

    • Get the public key information.

      Parameters

      • addressRaw: string | Address

        The address or addresses to get the public key information of

      Returns Promise<Address>

      The public keys information

      This method is used to get the public key information.

      await getPublicKeyInfo('bcrt1qfqsr3m7vjxheghcvw4ks0fryqxfq8qzjf8fxes');
      

      If the address is invalid

    • Get the public key information.

      Parameters

      • addresses: string | Address | string[] | Address[]

        The address or addresses to get the public key information of

      • logErrors: boolean = false

      Returns Promise<AddressesInfo>

      The public keys information

      This method is used to get the public key information.

      await getPublicKeysInfo(['addressA', 'addressB']);
      

      If the address is invalid

    • Get the storage at a specific address and pointer.

      Parameters

      • address: string | Address

        The address to get the storage from

      • rawPointer: string | bigint

        The pointer to get the storage from as base64 or bigint

      • proofs: boolean = true

        Whether to send proofs or not

      • Optionalheight: BigNumberish

        The height to get the storage from

      Returns Promise<StoredValue>

      The storage value

      This method is used to get the storage at a specific address and pointer.

      await getStorageAt('tb1pth90usc4f528aqphpjrfkkdm4vy8hxnt5gps6aau2nva6pxeshtqqzlt3a', 'EXLK/QhEQMI5d9DrthLvozT+UcDQ7WuSPaz7g8GV3AQ=');
      

      If something went wrong while fetching the storage

    • Get a transaction receipt by its hash.

      Parameters

      • txHash: string

        The transaction hash

      Returns Promise<TransactionReceipt>

      The requested transaction receipt

      This method is used to get a transaction receipt by its hash.

      await getTransactionReceipt('63e77ba9fa4262b3d4d0d9d97fa8a7359534606c3f3af096284662e3f619f374');
      

      Something went wrong while fetching the transaction receipt

    • Send a raw transaction.

      Parameters

      • tx: string

        The raw transaction to send as hex string

      • Optionalpsbt: boolean

        Whether the transaction is a PSBT or not

      Returns Promise<BroadcastedTransaction>

      The result of the transaction

      This method is used to send a raw transaction.

      await sendRawTransaction('02000000000101ad897689f66c98daae5fdc3606235c1ad7a17b9e0a6aaa0ea9e58ecc1198ad2a0100000000ffffffff01a154c39400000000160014482038efcc91af945f0c756d07a46401920380520247304402201c1f8718dec637ddb41b42abc44dcbf35a94c6be6a9de8c1db48c9fa6e456b7e022032a4b3286808372a7ac2c5094d6341b4d61b17663f4ccd1c1d92efa85c7dada80121020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c00000000', false);
      

      If something went wrong while sending the transaction

    • Bulk send transactions.

      Parameters

      • txs: string[]

        The raw transactions to send as hex string

      Returns Promise<BroadcastedTransaction[]>

      The result of the transaction

      This method is used to send multiple transactions at the same time.

      If something went wrong while sending the transaction

    • Submit a new epoch solution.

      Parameters

      Returns Promise<SubmittedEpoch>

      The submission result

      This method is used to submit a SHA-1 collision solution for epoch mining.

      await submitEpoch({
      epochNumber: 123n,
      targetHash: Buffer.from('00000000000000000000000000000000', 'hex'),
      salt: Buffer.from('0a0a0a0a0a0a00a', 'hex'),
      publicKey: Address.dead(),
      graffiti: Buffer.from('Hello, world!'),
      signature: Buffer.from('1234567890abcdef', 'hex'),
      });

      If something went wrong while submitting the epoch

    • Verify an address.

      Parameters

      • addr: string | Address

        The address to verify

      • network: Network

        The network to verify the address against

      Returns null | AddressTypes

      The address type, return null if the address is invalid