Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
PHP
web3.php is the primary PHP library for talking to Arbitrum One over JSON-RPC, letting a Laravel or plain-PHP backend read balances and submit transactions against https://arbitrum.therpc.io/YOUR_API_KEY. Install it with composer require web3p/web3.php. The library uses a callback-based API rather than returning values directly, so wrapping every call in a service class keeps your controllers clean and your callback handling in one place.
web3.php hands results back through callbacks of the shape function ($err, $result) rather than as return values. In a Laravel project, hide that pattern inside a dedicated service class so your Arbitrum One controllers stay thin and only deal with already-resolved values.
Web3.php
Build the client by composing the request manager and provider: new Web3(new HttpProvider(new HttpRequestManager('https://arbitrum.therpc.io/YOUR_API_KEY'))). Every eth method takes a callback of the form function ($err, $result) — always check $err first and throw or handle it before touching $result, since a network hiccup or a reverted Arbitrum One transaction surfaces there rather than as a thrown exception.
<?php
use Web3\Web3;
use Web3\Providers\HttpProvider;
use Web3\RequestManagers\HttpRequestManager;
class EthereumService
{
private $web3;
public function __construct()
{
$this->web3= new Web3(new HttpProvider(new HttpRequestManager('https://arbitrum.therpc.io/YOUR_API_KEY')));
}
public function getBalance(string $address): string
{
$balance = null;
$this->web3->eth->getBalance($address, 'latest', function ($err, $result) use (&$balance) {
Key features for Arbitrum One: JSON-RPC support, contract interactions, transaction handling, ETH unit conversion (wei to ether), and ABI encoding/decoding.
Laravel Integration
In Laravel, read the Arbitrum One endpoint from config('services.ethereum.node_url') — backed by an .env entry — so your API key never lands in version control. Wrap repeat reads like balance lookups in Cache::remember with a short TTL; even though Arbitrum One confirms quickly, caching for a few minutes spares your endpoint from identical requests when many users hit the same screen.
<?php
namespace App\Services;
use Web3\Web3;
use Illuminate\Support\Facades\Cache;
class EthereumService
{
private $web3;
public function __construct()
{
$this->web3= new Web3(config('services.ethereum.node_url'));
}
public function getCachedBalance(string $address): string
{
return Cache::remember("eth_balance_{$address}", 300, function () use ($address) {
return $this->getBalance($address);
});
}
public function getTransactionCount(string $address): int
{
$count = null;
$this->web3->eth->getTransactionCount($address, 'latest', function ($err, $result) use (&$count) {
if ($err !== null) {
throw new Exception($err->getMessage());
}
$count = hexdec($result);
});
return $count;
}
}
Smart Contract Integration
To work with a deployed Arbitrum One contract, construct the Contract class with the provider and ABI, then bind it to the on-chain address using ->at($contractAddress). Read methods run through ->call($method, $params, $callback), where the callback receives ($err, $response) — the same pattern as the core eth calls. Fetch the verified ABI for a contract such as a Uniswap or GMX deployment from https://arbiscan.io.
<?php
use Web3\Contract;
class SmartContractService
{
private $contract;
public function __construct(string $abi, string $contractAddress)
{
$web3= new Web3(new HttpProvider(new HttpRequestManager('https://arbitrum.therpc.io/YOUR_API_KEY')));
$this->contract = new Contract($web3->provider, $abi);
$this->contract->at($contractAddress);
}
public function callMethod(string $method, array $params = [])
{
$result = null;
$this->contract->call($method, $params, function ($err, $response) use (&$result) {
if ($err !== null) {
throw new Exception($err->getMessage());
}
$result = $response;
});
return $result;
}
}
Error Handling
Define a domain EthereumException that wraps the original error so the rest of your app catches one predictable type instead of inspecting raw callback errors everywhere. Holding onto the underlying error lets you log the exact Arbitrum One RPC failure while presenting a clean, user-facing message — handy when a revert or a rate-limit response needs different handling than a transient network error.
<?php
class EthereumException extends Exception
{
private $ethError;
public function __construct(string $message, $ethError = null)
{
parent::__construct($message);
$this->ethError = $ethError;
}
public function getEthError()
{
return $this->ethError;
}
}
class SafeEthereumService
{
public function safeGetBalance(string $address): string