定制 howrareis/helius-php-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

howrareis/helius-php-sdk

最新稳定版本:v0.1.0

Composer 安装命令:

composer require howrareis/helius-php-sdk

包简介

Unofficial Helius PHP SDK

README 文档

README

Unofficial Helius PHP SDK is an opinionated (i.e. might not follow the same conventions as TypeScript version) port of the official Helius SDK

Not all features from the official SDK are implemented. Some will never be implemented, because they are not needed in PHP version of the SDK. Some missing features will be implemented in the future. This SDK will have features or conveniences that are not present in the official SDK.

Helius API is very functional and not all of its features are covered by this SDK. If you want some new features to be added / new endpoints to be handled, open an issue or create a pull request.

Consult official Helius API docs before using SDK to learn about methods and their limitations. In most cases SDK will not handle data validation. That's responsibility of the end user.

If you don't have Helius API key yet, you can get one here.

Installation

You can install the package via composer:

composer require howrareis/helius-php-sdk

Usage

use HowRareIs\HeliusPhpSdk\Helius;

$helius = new Helius('<your-api-key>'); // replace <your-api-key> with your API key

Webhooks

Consult official Helius API docs. before using SDK to learn about webhooks and their limitations.

Create webhook

$webhook_data = [
    'webhookURL' => 'https://example.com/webhook',
    'accountAddresses' => [
        Addresses::TENSOR,
        '4B4a93ekt1fmXSVkTrULaxVFHkmME82TUi5Cyc5aF7K',
    ],
    'transactionTypes' => [
        TransactionTypes::NFT_LISTING,
        TransactionTypes::NFT_CANCEL_LISTING,
    ],
    'webhookType' => WebhookType::ENHANCED,
    'authHeader' => 'someouthkey',
];
$webhook = $helius->createWebhook($webhook_data);

Get all webhooks

$webhooks = $helius->getAllWebhooks();

Get webhook by id

$webhook = $helius->getWebhookById('11111111-1111-1111-1111-111111111111'); // replace 11111111-1111-1111-1111-111111111111 with your webhook id

Edit webhook

In the API call to update webhook you need to submit full data for the webhook. To make updates more convenient editWebhook() method will retrieve original data and overwrite only parts you have specified in the update.

$update = [
    'transactionTypes' => [
        TransactionTypes::NFT_MINT,
        TransactionTypes::NFT_BID,
    ],
];

$webhook = $helius->editWebhook($webhook_id, $update);

Append addresses to webhook

Max 100 000 addresses can be added to the webhook. If you try to add more than that, you will get an error.

$webhook = $helius->appendAddressesToWebhook($webhook_id, [Addresses::HYPERSPACE]);

Delete webhook

$helius->deleteWebhook($webhook_id);

Create collection webhook

This is another convenience method. Behind the scenes it will try to fetch mintlist for the collection and will create a webhook with all NFT addresses from the mintlist.

$payload = [
    'webhookURL' => 'https://example.com/webhook',
    'transactionTypes' => [
        TransactionTypes::NFT_SALE
    ],
    'webhookType' => WebhookType::ENHANCED,
    'authHeader' => 'someouthkey',
];
$webhook = $helius->createCollectionWebhook(Collections::ABC, $webhook_rules);

Get mintlist

All mintlist retrieval methods by default will return unmodified data from API response. It will include mints and names of the NFTs. However, if you are interested only in NFT addresses you can pass second argument as true. That will extract only NFT addresses from the response and will return as one array.

$mintlist = $helius->getMintlist(Collections::ABC);

or

$request = [
    'verifiedCollectionAddresses' => ['SMBH3wF6baUj6JWtzYvqcKuj2XCKWDqQxzspY12xPND'],
];
$mintlist = $helius->getMintlist($request, true);

Get mintlist from Collection address

$mintlist = $helius->getMintlistByCollectionAddress($colllection_addrress);

Get mintlist from Creator address

$mintlist = $helius->getMintlistByCreatorAddress($creator_address, true);

Get mintlist from NFT address (mint hash)

Behind the scenes SDK will first call NFT Fingerprint API to find out Creator address and Collection address. If any of the two will be found they will be used to retrieve mintlist. Collection address will have higher priority.

$mintlist = $helius->getMintlistFromNft($nft_mint, true);

Get fingerprints for NFTs

You can pass one mint as a string or multiple mints as an array. Max 1000 mints per request.

$fingerprints = $helius->getNftFingerprints($mint_hashes);

If you want to extract one specific field from returned data (like activeListings) you can use second argument.

$active_listings = $helius->getNftFingerprints($mint_hashes, 'activeListings');

In response, you will get associated array with mint hashes as keys and values as requested field. If field is not found, you will get false.

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固