定制 lido-nation/cardano-nft-maker-laravel 二次开发

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

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

lido-nation/cardano-nft-maker-laravel

最新稳定版本:2.1.1

Composer 安装命令:

composer require lido-nation/cardano-nft-maker-laravel

包简介

Nft Maker on Cardano

README 文档

README

Latest Version on Packagist Packagist Downloads GitLab Release GitLab Tag

This package aims at making the cardano nft creation easy, We use NMKR Studio behind the scenes to make this process seemless.

Support us

You can support us by buying one of our nfts or donating.

Installation

You can install the package via composer:

composer require lido-nation/cardano-nft-maker-laravel

You can publish the config file with:

php artisan vendor:publish --tag="cardano-nft-maker-laravel-config"

This is the contents of the published config file:

return [
    'auth_key' => env('MAKER_AUTH_KEY', ''),
    'baseUrl' => env('MAKER_BASE_URL', 'https://studio-api.preprod.nmkr.io'),
    'project_uuid' => env('MAKER_PROJECT_UUID',)
];

Usage

Set up a project at NMKR Studio.

To use this package your dedicated nft model neets to implement the CardanoNftInterface that has predefined properties maker_nft_uuid which will be the uuid of the remote nft that will be created in the api and maker_project_uuid the uuid of the project your remote nft will be under.For simplicity we will make the properties as columns in our nft model. Use NftServiceTrait which lets you utilise the NftMakerService to make the api calls.

<?php

namespace App\Models;

use Lidonation\CardanoNftMaker\Interfaces\CardanoNftInterface;
use Lidonation\CardanoNftMaker\Traits\NftServiceTrait;

class Nft extends Model implements CardanoNftInterface
{
    use NftServiceTrait;
}

lets upload our nft to the api

//get our nft instance 
$myNft = Nft::first();

$metadata = [
    "tokenname" => $myNft->name,
    "displayname" => $myNft->name,
    "description" => $myNft->description,
    "previewImageNft" => [
        "mimetype" => "image/png",
        "fileFromsUrl" => "https://images.pexels.com/photos/45201/kitty-cat-kitten-pet-45201.jpeg?auto=compress&cs=tinysrgb&w=800",
    ],
    "metadataPlaceholder" => [
        [
            "name" => "Age",
            "value" => "1"
        ],
        [
            "name" => "Color",
            "value" => "Black and white"
        ]
    ],
];

//our metadata has to conform to the format specified by the api, our DTO can do the validation for us 
$validatedMetadata = MetadataUpload::from($metadata);

//set the remote project uuid
$myNft->update([
  'maker_project_uuid' => '92fa1da3-df83-40b9-a21b-dc819553e98b'
]);

//upload
/* @var $response \Saloon\Http\Response  */
$response = $mynft->uploadNMKRNft($validatedMetadata);

//response details 
$remoteNftDetails = $response->json();

//save the nftUid for further updating if required, we will also save our metadata for updating later 
$metadataDetails = $remoteNftDetails['metadata'];
$myNft->update([
  'maker_nft_uuid' => $remoteNftDetails['nftUid'],
  'maker_nft_metadata' => $metadataDetails,
  'policy' => array_key_first(json_decode($metadataDetails, true)[721])
]);

If we need to update our metadata, we can easily do that. For our case we will add social contacts.

$metadataDetails = json_decode($myNft->maker_nft_metadata, true);
$metadata = $metadataDetails[721][$myNft->policy][$myNft->name];

//remove empty fields if any
$updatedMetadata = array_filter($metadata, fn ($value) => !empty($value));

// add custom static metadata
$updatedMetadata['web contact'] = [
    'twitter' => 'https://x.com/catAstrophy',
    'discord' => 'https://discordapp.com/users/7734909132320',
    'website' => 'https://www.cat-astrophy.com',
];
$metadataDetails[721][$myNft->policy][$myNft->name] = $updatedMetadata;

//lets update remote our nft
$response = $myNft->updateNMKRNft($metadataDetails)->json();

//sync local with remote nft
$myNft->update([
  'maker_nft_metadata' => $response['metadata'],
]);

To delete our remote nft

$myNft->deleteNMKRNft();

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-17