承接 locpx/moralis-tracker 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

locpx/moralis-tracker

Composer 安装命令:

composer require locpx/moralis-tracker

包简介

Laravel package to track and log multi-chain transactions for given addresses via Moralis API

README 文档

README

A Laravel package that tracks and logs transactions for one or more wallet addresses across multiple EVM chains (BSC, Ethereum, Polygon, Arbitrum, Base, Avalanche, and more) using the Moralis API, storing them in your database with full logging support.

Features

  • Multi-chain — track the same or different addresses on BSC, ETH, Polygon, Arbitrum, Base, Avalanche simultaneously
  • Tracks native, ERC-20/BEP-20 token, and NFT transfers per chain
  • Incremental sync — resumes from the last synced block per address per chain
  • Cursor-based pagination — handles wallets with thousands of transactions
  • Upsert strategy — new transactions inserted, existing ones updated on re-sync
  • Configurable via .env and config/moralis.php
  • Artisan commands: moralis:sync and moralis:add-address
  • Auto-discovers via Laravel's package discovery
  • Rate-limit aware with retry logic

Requirements

  • PHP ≥ 8.1
  • Laravel 10 or 11
  • A free Moralis API key
  • ext-bcmath and ext-curl enabled

Installation

1. Require via Composer

composer require locpx/moralis-tracker

2. Publish Config & Migrations

php artisan vendor:publish --tag=moralis-config
php artisan vendor:publish --tag=moralis-migrations
php artisan migrate

3. Configure .env

# Get your free key at https://admin.moralis.io/api-keys
MORALIS_API_KEY=your_api_key_here

# Default chain when --chain is not specified (bsc, eth, polygon, arbitrum, base, avalanche)
MORALIS_CHAIN=bsc

# Optional: comma-separated addresses seeded on the default chain at first boot
MORALIS_ADDRESSES=0xabc123...,0xdef456...

# Optional overrides
MORALIS_TIMEOUT=30
MORALIS_MAX_RETRIES=3
MORALIS_LOG_CHANNEL=stack

Usage

Add an address to track

# Track on the default chain (MORALIS_CHAIN)
php artisan moralis:add-address 0xYourAddress --label="My Wallet"

# Track the same address on multiple chains
php artisan moralis:add-address 0xYourAddress --chain=bsc  --label="BSC Wallet"
php artisan moralis:add-address 0xYourAddress --chain=eth  --label="ETH Wallet"
php artisan moralis:add-address 0xYourAddress --chain=polygon

Sync transactions

# Sync all active addresses on all chains
php artisan moralis:sync

# Sync only BSC addresses
php artisan moralis:sync --chain=bsc

# Sync a specific address on a specific chain
php artisan moralis:sync --address=0xYourAddress --chain=eth

# Sync from a specific block
php artisan moralis:sync --address=0xYourAddress --chain=bsc --from-block=25000000

# Force full re-sync (ignore last_synced_block)
php artisan moralis:sync --fresh

Schedule automatic syncing

Laravel 10 — app/Console/Kernel.php:

protected function schedule(Schedule $schedule): void
{
    $schedule->command('moralis:sync')->everyMinute();
}

Laravel 11 — routes/console.php:

use Illuminate\Support\Facades\Schedule;

Schedule::command('moralis:sync')->everyMinute();

Add this cron entry to your server:

* * * * * cd /path-to-your-app && php artisan schedule:run >> /dev/null 2>&1

Each sync fetches only blocks newer than the last synced block, so running every minute is efficient even across multiple chains.

Database Tables

tracked_addresses

Column Type Description
address string Wallet address (0x...)
chain string Chain key: bsc, eth, polygon, etc.
label string Human-readable name (optional)
is_active boolean Whether to sync this address
last_synced_block bigint Last block synced (incremental)
last_synced_at timestamp Timestamp of last sync
meta json Extra metadata

Unique key: (address, chain) — the same address can be tracked on multiple chains independently.

chain_transactions

Column Type Description
tx_hash string Transaction hash
type string normal, token, nft
chain string Chain key: bsc, eth, polygon, etc.
tracked_address string Address being tracked
block_number bigint Block number
block_timestamp timestamp Block time
from_address string Sender
to_address string Receiver
value_native decimal Value in native currency (ETH/BNB/MATIC)
tx_fee_native decimal Fee in native currency
token_name string Token name (token/nft txs)
token_symbol string Token symbol
is_error boolean Whether the tx failed
raw_data json Full raw Moralis response

Unique key: (tx_hash, type, chain, tracked_address)

Programmatic Usage

use Locpx\MoralisTracker\Services\TransactionSyncService;
use Locpx\MoralisTracker\Models\ChainTransaction;
use Locpx\MoralisTracker\Models\TrackedAddress;

// Sync all chains
$service = app(TransactionSyncService::class);
$service->syncAll();

// Sync only BSC
$service->syncAll('bsc');

// Sync a specific address on a specific chain
$result = $service->syncByAddress('0xYourAddress', 'eth');
// $result = ['new' => 12, 'highestBlock' => 19340000]

// Query transactions
ChainTransaction::forAddress('0xYourAddress')->onChain('bsc')->ofType('token')->latest('block_number')->get();

// Get all incoming ETH transactions
ChainTransaction::onChain('eth')->incoming('0xYourAddress')->get();

Adding a Custom Chain

Add any Moralis-supported chain to config/moralis.php:

'chains' => [
    // ... existing chains ...
    'optimism' => [
        'name'              => 'Optimism',
        'moralis_id'        => 'optimism',
        'native_symbol'     => 'ETH',
        'transaction_types' => ['normal', 'token', 'nft'],
    ],
],

Then track an address on it:

php artisan moralis:add-address 0xYourAddress --chain=optimism

Configuration Reference

// config/moralis.php
return [
    'api_key'       => env('MORALIS_API_KEY', ''),
    'base_url'      => env('MORALIS_BASE_URL', 'https://deep-index.moralis.io/api/v2.2'),
    'default_chain' => env('MORALIS_CHAIN', 'bsc'),

    'chains' => [
        'bsc'       => ['name' => 'BNB Smart Chain',    'moralis_id' => 'bsc',       'native_symbol' => 'BNB',  'transaction_types' => ['normal','token','nft']],
        'eth'       => ['name' => 'Ethereum',            'moralis_id' => 'eth',       'native_symbol' => 'ETH',  'transaction_types' => ['normal','token','nft']],
        'polygon'   => ['name' => 'Polygon',             'moralis_id' => 'polygon',   'native_symbol' => 'MATIC','transaction_types' => ['normal','token','nft']],
        'arbitrum'  => ['name' => 'Arbitrum One',        'moralis_id' => 'arbitrum',  'native_symbol' => 'ETH',  'transaction_types' => ['normal','token','nft']],
        'base'      => ['name' => 'Base',                'moralis_id' => 'base',      'native_symbol' => 'ETH',  'transaction_types' => ['normal','token','nft']],
        'avalanche' => ['name' => 'Avalanche C-Chain',   'moralis_id' => 'avalanche', 'native_symbol' => 'AVAX', 'transaction_types' => ['normal','token','nft']],
    ],

    'addresses'            => [],
    'timeout'              => env('MORALIS_TIMEOUT', 30),
    'max_retries'          => env('MORALIS_MAX_RETRIES', 3),
    'max_records_per_page' => 100,
    'start_block'          => 0,
    'log_channel'          => env('MORALIS_LOG_CHANNEL', 'stack'),

    'table_names' => [
        'tracked_addresses'  => 'tracked_addresses',
        'chain_transactions' => 'chain_transactions',
    ],
];

License

MIT

locpx/moralis-tracker 适用场景与选型建议

locpx/moralis-tracker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 locpx/moralis-tracker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 locpx/moralis-tracker 我们能提供哪些服务?
定制开发 / 二次开发

基于 locpx/moralis-tracker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 32
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-06