Getting Started

Install the Laravel package, configure your environment, and make your first API call in minutes.

Requirements

RequirementVersion
PHP8.1 or higher
Laravel10.x or 11.x
Composer2.x
ext-jsonbundled with PHP 8.x
guzzlehttp/guzzle^7.0 (auto-installed)

Installation

Step 1 — Install via Composer

composer require web3sdk/laravel

Step 2 — Publish the config file

php artisan vendor:publish --tag=web3api-config

This creates config/web3api.php in your Laravel app.

Step 3 — Add environment variables

WEB3_API_KEY=ak_live_xxxxxxxxxx
WEB3_DEFAULT_NETWORK=polygon

Create your API key in the provider dashboard (Dashboard → API Keys). The API endpoint is built into the SDK — no URL configuration needed.

Step 4 — Use the Facade

The Web3Api facade is automatically registered by the ServiceProvider. No manual registration needed.

<?php
use Web3Sdk\Laravel\Facades\Web3Api;

$balance = Web3Api::balance()->getNative(address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045');
// ['balance' => '1.5', 'symbol' => 'MATIC', 'network' => 'polygon', ...]

Environment Variables

VariableRequiredDefaultDescription
WEB3_API_KEY Yes Your API key (ak_live_xxx), created in the provider dashboard. The SDK throws on boot if missing.
WEB3_DEFAULT_NETWORK No polygon Default network used when no $network argument is passed to module methods.
WEB3_TIMEOUT No 30 HTTP request timeout in seconds.

Authentication

Every request authenticates with your API key — sent automatically as the X-Api-Key header. Account login, key management, package purchase, and webhooks all live in the provider dashboard, not in this SDK.

<?php
// config/web3api.php is already populated via .env
// Just use the facade — the API key is sent automatically

use Web3Sdk\Laravel\Facades\Web3Api;

$balance = Web3Api::balance()->getNative(address: '0xABC...');

// Transfers can omit privateKey (pass null) — the API signs with the
// stored managed wallet for the from address.
$tx = Web3Api::transfer()->native(
    fromAddress: '0xSENDER...',
    privateKey:  null,
    toAddress:   '0xRECEIVER...',
    amount:      '0.5',
);
ℹ️
With an API Key, the network is bound to the key configuration. You do not need to pass a $network argument — the key's network is used automatically.

Network Resolution

How the API determines which blockchain network to use:

⚠️
API Key: Network is determined by the key's configuration. The $network parameter is ignored.
Plugin default: If WEB3_DEFAULT_NETWORK is set and no $network arg is passed, the plugin uses that value.
<?php
// Pass network explicitly — overrides .env default
$balance = Web3Api::balance()->getNative(
    address: '0xABC...',
    network: 'ethereum',  // use Ethereum mainnet for this call
);

// Omit network — uses WEB3_DEFAULT_NETWORK (.env)
$balance = Web3Api::balance()->getNative(address: '0xABC...');

Supported Networks

Network SlugFull NameChain IDSymbolType
ethereumEthereum Mainnet1ETHMainnet
polygonPolygon Mainnet137MATICMainnet
bscBNB Smart Chain56BNBMainnet
arbitrumArbitrum One42161ETHMainnet
optimismOptimism10ETHMainnet
avalancheAvalanche C-Chain43114AVAXMainnet
polygon_mumbaiPolygon Mumbai80001MATICTestnet
goerliGoerli5ETHTestnet
sepoliaSepolia11155111ETHTestnet

Fetch the live list of networks (including any newly added ones) at any time:

<?php
$networks = Web3Api::networks()->list();
// Returns array of network objects with chain_id, symbol, explorer_url, is_testnet, etc.