Skip to content

Latest commit

 

History

History
277 lines (253 loc) · 8.78 KB

RpcClientAPI.md

File metadata and controls

277 lines (253 loc) · 8.78 KB

RpcClient API

Class for interacting with the network via RPC


Constructor

__constructor(string $nodeUrl, array $headers = array())

Parameters

Name Type Description Required
$nodeUrl string Full node url string Yes
$headers array Additional headers No

Put deploy

putDeploy(Deploy $deploy): string

Put deploy into the network and returns deploy hash string

Parameters

Name Type Description Required
$deploy Deploy Signed Deploy object Yes

Get deploy

getDeploy(string $deployHash): Deploy

Returns a Deploy object by the given deploy hash

Parameters

Name Type Description Required
$deployHash string Hex-encoded hash of a deploy Yes

Get block by hash

getBlockByHash(string $blockHash): Block

Returns a Block object by the given block hash

Parameters

Name Type Description Required
$blockHash string Hex-encoded hash of a block Yes

Get block by height

getBlockByHeight(int $height): Block

Returns a Block object by the given block height

Parameters

Name Type Description Required
$height int Block height Yes

Get the latest block

getLatestBlock(): Block

Returns a Block object that represents the latest block from the network


Get peers

getPeers(): array

Returns a list of Peer objects connected to the node


Get status

getStatus(): Status

Returns the current Status of the node


Get auction state

getAuctionState(): AuctionState

Returns AuctionState object that contains the bids and validators as of either if specific block (by height or hash), or the most recently added block


Get state root hash

getStateRootHash(string $blockHash): string

Returns state root hash string by the given block hash

Parameters

Name Type Description Required
$blockHash string Hex-encoded hash of the block Yes

Get account

getAccount(string $blockHash, CLPublicKey $publicKey): Account

Returns an Account object by the given block hash and account public key

Parameters

Name Type Description Required
$blockHash string Hex-encoded hash of the block Yes
$publicKey CLPublicKey Public key object Yes

Get account balance

getAccountBalance(string $stateRootHash, CLURef $balanceUref): \GMP

Returns purse's balance from the network

Parameters

Name Type Description Required
$stateRootHash string Hex-encoded hash of the state root Yes
$balanceUref CLURef Balance URef object Yes

Query balance

queryBalance(
    string $purseIdentifierType, 
    string $purseIdentifier, 
    string $stateRootHash = null
): \GMP

Returns a purse’s balance from global state at a given Block or state root hash.

Parameters

Name Type Description Required
$purseIdentifierType string Purse identifier type. Available values: purse_uref, main_purse_under_public_key, main_purse_under_account_hash Yes
$purseIdentifier string Purse identifier Yes
$stateRootHash string Hex-encoded hash of the state root No

Get account balance URef by account hash

getAccountBalanceUrefByAccountHash(string $stateRootHash, CLAccountHash $accountHash): CLURef

Returns an account balance URef by the given state root hash and account hash

Parameters

Name Type Description Required
$stateRootHash string Hex-encoded hash of the state root Yes
$accountHash CLAccountHash Account hash object Yes

Get account balance URef by public key

getAccountBalanceUrefByPublicKey(string $stateRootHsh, CLPublicKey $publicKey): CLURef

Returns an account balance CLURef by the given state root hash and public key

Parameters

Name Type Description Required
$stateRootHash string Hex-encoded hash of the state root Yes
$publicKey CLPublicKey Public key object Yes

Get block state

getBlockState(string $stateRootHash, string $key, array $path = []): StoredValue

Returns StoredValue object by state root hash, key and path

Parameters

Name Type Description Required
$stateRootHash string Hex-encoded hash of the state root Yes
$key string casper_types::Key as formatted string Yes
$path array The path components starting from the key as base. No

Get block transfers

getBlockTransfers(string $blockHash = null): array

Returns a list of Transfer objects for the block from the network by the given block hash

Parameters

Name Type Description Required
$blockHash string Hex-encoded hash of the block No

Get era summary by switch block hash

getEraSummaryBySwitchBlockHash(string $blockHash): ?EraSummary

Returns an EraSummary object or null by the given block hash

Parameters

Name Type Description Required
$blockHash string Hex-encoded hash of the block Yes

Get era summary by switch block height

getEraSummaryBySwitchBlockHeight(int $height): ?EraSummary

Returns an EraSummary object or null by the given block height

Parameters

Name Type Description Required
$height int Block height Yes

Get dictionary item

getDictionaryItemByURef(
    string $stateRootHash,
    string $dictionaryItemKey,
    string $seedUref
): StoredValue

Returns an item from a Dictionary (StoredValue object) by the given state root hash, dictionary item key and seed URef

Parameters

Name Type Description Required
$stateRootHash string Hex-encoded hash of the state root Yes
$dictionaryItemKey string The dictionary item key formatted as a string Yes
$seedUref string The dictionary's seed URef Yes

Get global state by block

getGlobalStateByBlock(
    string $blockHash,
    string $key,
    array $path
): GlobalState

Returns an GlobalState object by the given block hash and key

Parameters

Name Type Description Required
$blockHash string Hex-encoded hash of the block Yes
$key string casper_types::Key as formatted string Yes
$path array The path components starting from the key as base No

Get global state by state root hash

getGlobalStateByStateRootHash(
    string $stateRootHash,
    string $key,
    array $path
): GlobalState

Returns an GlobalState object by the given state root hash and key

Parameters

Name Type Description Required
$stateRootHash string Hex-encoded hash of the state root Yes
$key string casper_types::Key as formatted string Yes
$path array The path components starting from the key as base No

Get chainspec info

getChainspecInfo(): ChainspecRegistryBytes

Returns a ChainspecRegistryBytes object


Speculative execution

speculativeExecution(Deploy $signedDeploy, string $blockHash): DeployExecutionResult

Puts a Deploy to a single node for speculative execution on that node only.

Parameters

Name Type Description Required
$signedDeploy Deploy Signed Deploy object Yes
$blockHash string Hex-encoded hash of the block Yes