Skip to content

Latest commit

 

History

History
94 lines (70 loc) · 3.05 KB

File metadata and controls

94 lines (70 loc) · 3.05 KB

rpcnode/sdk

Official PHP client for the RpcNode Public API: dedicated fullnode RPC (Ethereum, Solana, Bitcoin, Tron, BNB Chain, Polygon, Arbitrum, Optimism, Base, and more), HMAC-signed merchant HTTP, address watch webhooks, and crypto payments.

API: https://api.rpcnode.dev

Package: rpcnode/sdk
Repo: github.com/rpcnode/api-sdk-php

Install

composer config repositories.rpcnode-sdk vcs https://github.com/rpcnode/api-sdk-php.git
composer require rpcnode/sdk:dev-master

Or clone:

git clone git@github.com:rpcnode/api-sdk-php.git
cd api-sdk-php && composer install

Auth

Every request is HMAC-signed. Query string is not part of the signature.

Header Value
X-Api-Key Key prefix (pk_live_…)
X-Timestamp Unix seconds (±300s)
X-Signature hex(hmac_sha256(secret, canonical))
{timestamp}\n{METHOD}\n{path}\n{sha256_hex(body)}

Empty body → SHA-256 of "". Headers are added by the client.

Quickstart

<?php

use RpcNode\Sdk\Client;

$client = new Client(
    baseUrl: getenv('PUBLIC_API_BASE') ?: 'https://api.rpcnode.dev',
    apiKey: (string) getenv('PUBLIC_API_KEY'),    // pk_live_…
    secret: (string) getenv('PUBLIC_API_SECRET'), // sk_live_…
);

$account = $client->getAccount();
$tokens = $client->listNetworkTokens('tron-nile', true);

Methods

Client HTTP
getAccount() GET /v1/account
getAccountUsage($days = 30) GET /v1/account/usage
listEndpoints() GET /v1/endpoints
listAvailableNetworks() GET /v1/endpoints/available-networks
getWorkspaceUsage(?int $days) GET /v1/endpoints/usage
createEndpoint(array $body) POST /v1/endpoints
getEndpointUsage($id, ?int $days) GET /v1/endpoints/{id}/usage
updateEndpointStatus($id, $status) PATCH /v1/endpoints/{id}/status
updateEndpointAllowedIps($id, array $ips) PATCH /v1/endpoints/{id}/allowed-ips
getAddressWatchAccount() GET /v1/address-watch/account
listAddresses(?array $params) GET /v1/address-watch/addresses
addAddress($networkSlug, $address) POST /v1/address-watch/addresses
deleteAddress($watchId) DELETE /v1/address-watch/addresses
listEvents(?array $params) GET /v1/address-watch/events
getWebhook() GET /v1/address-watch/webhook
setWebhook(array $body) PUT /v1/address-watch/webhook
listPayments(?array $params) GET /v1/payments
createPayment(array $body) POST /v1/payments
getPayment($paymentId) GET /v1/payments/{id}
getPaymentByOrderId($orderId) GET /v1/payments/orders/{orderId}
listNetworkTokens($networkSlug, ?bool $includeNative) GET /v1/network-tokens

Tests

cp .env.example .env   # PUBLIC_API_KEY + PUBLIC_API_SECRET for live smokes
composer test

HMAC unit tests run without credentials. Live reads use .env or the environment. Writes: PUBLIC_API_SMOKE_MUTATE=1, PUBLIC_API_SMOKE_CREATE_PAYMENT=1.

License

MIT