Provider
The JsonRpcProvider
class in the Eidolon.Unity SDK is a class that provides access to the Ethereum blockchain via a JSON-RPC (Remote Procedure Call) Protocol. It provides a simplified interface for developers to interact with the blockchain from within Unity.
Create a custom provider
You can create a custom provider using your own RPC URL by doing the following:
JsonRpcProvider Methods
After going through the initial project setup, you can utilize any of the below provider methods anywhere in your Unity project.
GetBlock
Description
This method retrieves the latest block number on the blockchain.
Example Code
Parameters
None
Returns
BigInteger
: The latest block number.
GetBlockWithTransactions
Description
This method fetches a block and provides access to an array of block properties, including transaction information.
Example Code
Parameters
blockNumber
(string): The block number to fetch.
Returns
BlockWithTransactions
: A block object containing transaction information.
GetChainId
Description
This method returns the current chain ID for a given provider
Example Code
Parameters
None
Returns
BigInteger
: The current chain ID.
GetTransaction
Description
This method retrieves a transaction by its hash and allows you to access transaction data like the Transaction Nonce, Gas, Input etc.
Example Code
Parameters
transactionHash
(string): The hash of the transaction to retrieve.
Returns
Transaction
: The transaction details.
GetTransactionReceipt
Description
This method retrieves a transaction receipt by its hash and allows you to access transaction data like the logs, status, Input etc.
Example Code
Parameters
transactionHash
(string): The hash of the transaction to retrieve.
Returns
TransactionReceipt
: The transaction receipt.
GetTransactionStatus
Description
This method retrieves the status of a transaction by its hash.
Example Code
Parameters
transactionHash
(string): The hash of the transaction to check.
Returns
string
:True
orFalse
. -True
: Transaction has been successful. -False
: Transaction has failed.
GetBalance
Description
This method retrieves the native chain balance (in Ether) for a specified wallet address.
Example Code
Parameters
address
(string): The Ethereum wallet address for which to retrieve the balance.
Returns
decimal
: The balance in Ether.
GetTransactionCount
Description
This method retrieves the total transaction count for a designated wallet address.
Example Code
Parameters
address
(string): The Ethereum wallet address for which to retrieve the transaction count.
Returns
BigInteger
: The total transaction count.
LookupAddress
Description
This method resolves the address for an ENS name asynchronously.
Example Code
Parameters
address
(string): The Ethereum wallet address to lookup.
Returns
string
: The ENS Name for the provided address.
ResolveURL
Description
This method resolves the URL for an ENS name asynchronously.
Example Code
Parameters
address
(string): The ENS address to lookup.
Returns
string
: The URL for the provided ENS Name.
EstimateGas
Description
This method estimates gas for a transaction asynchronously.
Example Code
Parameters
address
(string): The ENS address to lookup.
Returns
string
: The URL for the provided ENS Name.