EVM -> Solana

SolanaにおけるERC721とは?

EVMエコシステムから来た方にとって、ERC721はおなじみでしょう。NFT(非代替性トークン)は多くのブロックチェーンアプリケーションの中核であり、ERC721はNFTコレクションをデプロイする際に開発者が最初に学ぶ標準の1つです。Solanaでは、ERC721に相当するものは何で、どのように異なるのでしょうか?

ERC721は非代替性トークン(NFT)の標準を定めたもので、各トークンが他のトークンと比べて(種類と価値の両面で)固有であることを意味します。ERC721標準は、個別の識別子を持つ個々のトークンを表現するために使用されます。ERC20トークンとは異なり、ERC721トークンは固有の特性や機能を持つことができます。

Token Program(プラスメタデータ)

Solanaでは、NFTコレクションごとに新しいスマートコントラクトは存在しません。代わりに、NFTは単一のオンチェーンToken Programの下で作成されます。これは代替可能トークンに使用されるものと同じプログラムで、供給量を1にしてミントされるだけです。NFTの追加詳細(名前、シンボル、画像URIなど)を保存するために、開発者はMetaplex Token Metadata Programを使用します。

Metaplex Metadataは、NFT(非代替性トークン)とデジタルアセットのためのオープンソースプロトコル兼プラットフォームです。Solanaブロックチェーン上に構築され、MetaplexはSolana上のトークンに追加のメタデータを付与することを容易にします。

これは、通常コレクションごとに新しいERC721コントラクトをデプロイするEthereumとは異なります。なぜSolana上のNFTには単一の主要プログラムがあるのでしょうか?それは、状態(データ)と実行ロジック(プログラム)を分離するSolanaアカウントモデルによるものです。Solanaはすべてのトークンに対してToken Programを再利用するため、新しいNFTコントラクトを作成してデプロイする必要はなく、供給量=1の新しいmint accountを作成するだけです。

NFTにはコントラクトアドレスはなく、ミントアドレスのみ

Ethereumでは、各NFTコレクションはコントラクトアドレスで識別され、各トークンはそのコントラクト内で一意のtokenIdを持ちます。Solanaでは、各NFTはミントアドレスで識別されます。違いは、個別の「NFTコントラクト」をデプロイするのではなく、汎用のToken Programに新しいミントを作成するよう指示するだけという点です。

SolanaのToken Programは汎用的であるため、固有の「NFTコントラクトアドレス」という概念はありません。代わりに、各NFTは独自のミントアドレスを持つ特別なSPLトークン(供給量1)です。

「コレクション」が必要な場合は、MetaplexのCollection Addressを介して複数のミントアドレスをグループ化しますが、ミントされた各NFTはあくまで固有のミントアドレスを持つSPLトークンです。

承認フローは不要

Ethereumでは、外部のマーケットプレイスやdAppがNFTを転送するために、ERC721は多くの場合approveやsetApprovalForAllに依存します。Solanaでは、各NFTはユーザーのATA(Associated token account)に保存され、単一のトランザクションに必要なすべてのステップを含めることができます。個別の承認フローはなく、1つのアトミックなトランザクションですべてのinstructions(所有権の移転、メタデータの更新など)を処理できます。

Solana Token Programはどのようなものか?

Solana Token Programをごく大まかに変換すると、次のようになります:

Solidity
// SPDX-License-Identifier: MIT license
pragma solidity =0.8.28;

struct Mint {
    uint8 decimals;
    uint256 supply;
    address mintAuthority;
    address freezeAuthority;
    address mintAddress;
}

struct TokenAccount {
    address mintAddress;
    address owner;
    uint256 balance;
    bool isFrozen;
}

struct Metadata {
    string name;
    string symbol;
    string tokenURI;
}

contract Spl721 {
    mapping(address => Mint) public mints;
    mapping(address => TokenAccount) public tokenAccounts;
    mapping(address => Metadata) public nftMetadata;
    mapping(address => bool) public mintAddresses;
    mapping(address => bool) public tokenAddresses;

    function initializeMint(
        uint8 decimals,
        address mintAuthority,
        address freezeAuthority,
        address mintAddress
    )
        public
        returns (Mint memory)
    {
        require(!mintAddresses[mintAddress], "Mint already exists");
        mints[mintAddress] = Mint(decimals, 0, mintAuthority, freezeAuthority, mintAddress);
        mintAddresses[mintAddress] = true;
        return mints[mintAddress];
    }

    function setMetadata(
        address mintAddress,
        string memory name,
        string memory symbol,
        string memory tokenURI
    )
        public
    {
        require(mintAddresses[mintAddress], "Mint does not exist");
        nftMetadata[mintAddress] = Metadata(name, symbol, tokenURI);
    }

    function mintNFT(address toMintTokens, address mintAddress) public {
        require(mintAddresses[mintAddress], "NFT mint does not exist");
        require(mints[mintAddress].mintAuthority == msg.sender, "Only the mint authority can mint");
        require(mints[mintAddress].supply == 0, "NFT already minted");
        mints[mintAddress].supply = 1;
        address tokenAddress = address(uint160(uint256(keccak256(abi.encodePacked(toMintTokens, mintAddress)))));
        if (!tokenAddresses[tokenAddress]) {
            tokenAccounts[tokenAddress] = TokenAccount(mintAddress, toMintTokens, 0, false);
            tokenAddresses[tokenAddress] = true;
        }
        tokenAccounts[tokenAddress].balance = 1;
        tokenAccounts[tokenAddress].owner = toMintTokens;
    }

    function transfer(address to, address mintAddress, uint256 amount) public {
        address toTokenAddress = address(uint160(uint256(keccak256(abi.encodePacked(to, mintAddress)))));
        address fromTokenAddress = address(uint160(uint256(keccak256(abi.encodePacked(msg.sender, mintAddress)))));
        require(tokenAccounts[fromTokenAddress].balance >= amount, "Insufficient balance");
        require(amount == 1, "Only transferring 1 NFT at a time");
        require(tokenAccounts[fromTokenAddress].owner == msg.sender, "Not the NFT owner");
        require(!tokenAccounts[fromTokenAddress].isFrozen, "Sender token account is frozen");
        if (tokenAddresses[toTokenAddress]) {
            require(!tokenAccounts[toTokenAddress].isFrozen, "Receiver token account is frozen");
        }
        if (!tokenAddresses[toTokenAddress]) {
            tokenAccounts[toTokenAddress] = TokenAccount(mintAddress, to, 0, false);
            tokenAddresses[toTokenAddress] = true;
        }
        tokenAccounts[fromTokenAddress].balance -= amount;
        tokenAccounts[toTokenAddress].balance += amount;
        tokenAccounts[toTokenAddress].owner = to;
    }

    function freezeAccount(address owner, address mintAddress) public {
        require(mintAddresses[mintAddress], "Mint does not exist");
        require(mints[mintAddress].freezeAuthority == msg.sender, "Only the freeze authority can freeze");
        address tokenAddress = address(uint160(uint256(keccak256(abi.encodePacked(owner, mintAddress)))));
        require(tokenAddresses[tokenAddress], "Token account not found");
        tokenAccounts[tokenAddress].isFrozen = true;
    }

    function getMint(address token) public view returns (Mint memory) {
        return mints[token];
    }

    function getTokenAccount(address owner, address token) public view returns (TokenAccount memory) {
        return tokenAccounts[address(uint160(uint256(keccak256(abi.encodePacked(owner, token)))))];
    }

    function getMetadata(address mintAddress) public view returns (Metadata memory) {
        return nftMetadata[mintAddress];
    }
}

このコントラクトからわかるように、承認フローの代わりに、トークンを移動するための転送関数だけが存在します。Solanaでは、単一のトランザクションで複数のスマートコントラクト関数をアトミックに呼び出せるため、承認フローが不要になります。もう1つの違いは、Solanaではすべてがtoken accountに保存され、所有者のトークンの詳細が他の状態とは分離して保持される点です。

NFTメタデータはどこにある?

Ethereumでは、ERC721コントラクトはメタデータURIを保存したり、トークンメタデータを取得するためのロジックを組み込んだりすることがよくあります。Solanaでは、(Metaplexによる)Token Metadata Programが、別のアカウントでNFTメタデータを管理します。名前、シンボル、説明、画像URIなどのフィールドを含めることができ、基盤となるToken Programを変更する必要はありません。そのため、ミントのトランザクションにメタデータを付与するための別のinstructionが含まれることになります。Solanaは1つのトランザクション内で複数のプログラム呼び出しをアトミックに処理できるため、ミントの作成とメタデータの設定を一度に簡単に行えます。

各アプローチのトレードオフ

Solana上のtoken programとmetadata programの仕組みの概要を理解したところで、各NFT規格のトレードオフを見ていきましょう。

ERC721

  • 高度にカスタマイズ可能なコントラクト
  • コレクションごとに新しいコントラクトをデプロイ
  • 多数のコントラクトにまたがるインデックス作成が困難
  • メタデータはコントラクト内またはURI経由で定義されることが多い
  • 個別の監査が必要

Solana NFT(SPL + Metaplex)

  • すべてのNFTに単一のプログラムを使用
  • 新しいNFTは新しいコントラクトではなくトランザクションで作成
  • 主要なプログラムが1つのため、インデックス作成が容易
  • メタデータは別のプログラムに保存
  • 監査済みの既存コードを再利用

概要比較

以下の表は、EthereumでERC-721トークンをデプロイする基本手順と、SolanaでNFT(メタデータ付きSPLトークン)を作成する基本手順を比較したものです。(Solanaでは、コマンドラインツールのspl-tokenコマンドを使って、SPLトークンを自由にミントできます。)

ステップEthereum (ERC-721)Solana (SPL + Metaplex)
1. トークンコードの準備通常、OpenZeppelinのERC721ライブラリを使用します。Solidityファイル(例:MyNFT.sol)を作成します。基本的なNFT機能にカスタムコントラクトは不要です。Token Programは既にデプロイされています。Mint Account(供給量=1)を作成するだけです。
2. コンパイル&デプロイHardhat/Truffleを使用してコンパイルおよびデプロイします(例:npx hardhat run deploy.js --network ...)。CLI(例:spl-token create-token --decimals 0)またはSDKツール(MetaplexのCandy Machineなど)を使用します。個別のコントラクトデプロイは不要です。
3. NFTのミントコントラクトのmint()関数を呼び出し、NFTをアドレスに割り当て、通常はトークンメタデータURIを設定します。ガス代は変動します。spl-token mint <MINT_ADDRESS> 1を実行するか、Metaplexのミントinstructionsを使用して正確に1の供給量を作成します。Solanaのトランザクション手数料は通常非常に低額です。
4. 受取人の作成通常は一般的なEthereumアドレスです。多くのウォレットでNFTを表示するには、ユーザーがNFTコントラクトアドレスを追加する必要があります。各ユーザーはassociated token accountを持っています。Phantomなどのウォレットは、NFT用のATAを自動的に認識します。トークンを「追加」する追加手順は不要ですが、認識されると「コレクティブル」タブに表示される場合があります。
5. 結果の確認EtherscanまたはOpenSeaなどのNFTマーケットプレイスで確認します。多くの場合、一部のウォレットでトークンを表示するには、ユーザーが手動でコントラクトアドレスを追加する必要があります。solana balance <ADDRESS>またはspl-token accountsを使用してトークン保有量を確認します。Solana ExplorerまたはNFTマーケットプレイス(Magic Eden、OpenSea Solanaなど)を使用してNFTの存在を確認することもできます。
6. 一意の識別子コントラクトアドレス + tokenId。Mint Address。各NFTは単に供給量=1のSPLトークンです。
7. コレクション1つのコントラクト内のすべてのトークンは、通常1つのコレクションを表します。コレクションはMetaplexの「コレクションアドレス」を介して割り当てられます。専用のコントラクトをデプロイする必要はありません。
8. コードの更新大規模なアップグレードの場合、プロキシパターンを使用するか、コントラクトを再デプロイする可能性があります。通常、これは上級開発者のみが行います。Token Programは固定されています。高度な機能(ロイヤリティ、動的メタデータなど)が必要な場合は、個別のオンチェーンプログラムを使用または構築できます。MetaplexはプログラマブルNFTなどの拡張機能もサポートしています。
9. 監査要件各コントラクトは通常、特にカスタムミントロジックやマーケットプレイスなどを追加する場合、監査が必要です。主要なToken ProgramとMetaplex Metadata Programは複数回監査されています。標準的なNFTのミントには、通常、追加のコントラクト監査は不要です。

SolanaでNFTをミントしたいですか?このガイドをご覧ください!

SolanaでERC721を実現する方法

EthereumのERC721インターフェース構造をもとに、solana/web3.jsを使ってToken Programとやり取りする方法を見ていきましょう。

前述のとおり、SolanaのNFTコレクションは特定のコントラクトに紐づいていないため、tokenIdという概念は存在しません。そのため、トークンの具体的なデータを調べるには、MintアドレスまたはCollectionアドレスを使用します。

name()の実装方法

Solidity
function name() external view returns (string); // Returns the token collection name

@metaplex-foundation/umi-bundle-defaultsと@metaplex-foundation/mpl-token-metadataを使用して、ミントアドレスからNFTのオフチェーンメタデータを取得・解析できます。

JSX
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { fetchDigitalAsset, mplTokenMetadata } from "@metaplex-foundation/mpl-token-metadata";
import { PublicKey } from "@metaplex-foundation/js";
const mintAddress = new PublicKey("Token Address");

async function name() {
  try {
    const umi = createUmi("https://api.devnet.solana.com");
    umi.use(mplTokenMetadata());
    const digitalAsset = await fetchDigitalAsset(umi, mintAddress);
    return digitalAsset.metadata.name;
  } catch (error) {
    console.error("Error fetching NFT name:", error);
    return null;
  }
}

name().then(nftName => {
    console.log("NFT Name:", nftName);
  })
  .catch(error => {
    console.error("Error:", error);
  });

symbol()の実装方法

Solidity
function symbol() external view returns (string); // Returns the token collection symbol

name()と同様に、@metaplex-foundation/umi-bundle-defaultsと@metaplex-foundation/mpl-token-metadataを使ってシンボルも取得できます。

JSX
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { fetchDigitalAsset, mplTokenMetadata } from "@metaplex-foundation/mpl-token-metadata";
import { PublicKey } from "@metaplex-foundation/js";
const mintAddress = new PublicKey("Token Address");

async function symbol() {
  try {
    const umi = createUmi("https://api.devnet.solana.com");
    umi.use(mplTokenMetadata());
    const digitalAsset = await fetchDigitalAsset(umi, mintAddress);
    return digitalAsset.metadata.symbol;
  } catch (error) {
    console.error("Error fetching NFT symbol:", error);
    return null;
  }
}

symbol().then(nftSymbol => {
  console.log("NFT Symbol:", nftSymbol);
}).catch(error => {
  console.error("Error:", error);
});

tokenURI()の実装方法

Bash
function tokenURI(uint256 _tokenId) external view returns (string); // Returns the tokenURI of the token

@metaplex-foundation/umi-bundle-defaultsと@metaplex-foundation/mpl-token-metadataを使って、NFTのToken Metadataアカウントからメタデータ URI(tokenURI()に相当するもの)を読み取れます。

JSX
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { fetchDigitalAsset, mplTokenMetadata } from "@metaplex-foundation/mpl-token-metadata";
import { PublicKey } from "@metaplex-foundation/js";
const mintAddress = new PublicKey("Token Address");

async function tokenURI( /* no tokenId */ ) {
  try {
    const umi = createUmi("https://api.devnet.solana.com");
    umi.use(mplTokenMetadata());
    const digitalAsset = await fetchDigitalAsset(umi, mintAddress);
    return digitalAsset.metadata.uri;
  } catch (error) {
    console.error("Error fetching token URI:", error);
    return null;
  }
}

tokenURI()
  .then(uri => {
    console.log("Token URI:", uri);
  })
  .catch(error => {
    console.error("Error:", error);
  });

ownerOf()の実装方法

Bash
function ownerOf(uint256 _tokenId) public view returns (address) // Returns the owner of the tokenId token

tokenIdの代わりにミントアドレスを使用して、NFTの所有者を確認できます。

JSX
import { Connection, PublicKey } from "@solana/web3.js";

const connection = new Connection("https://api.devnet.solana.com", "confirmed");
const mintAddress = new PublicKey("Token Address");

async function ownerOf( /*no tokenId*/ ){
  const largestAccounts = await connection.getTokenLargestAccounts(new PublicKey(mintAddress));
  const largestAccountInfo = await connection.getParsedAccountInfo(largestAccounts.value[0].address);
  return largestAccountInfo.value.data.parsed.info.owner;
}

ownerOf().then(owner => {
  console.log(owner);
}).catch(error => {
  console.error("Error:", error);
});

transferFrom()の実装方法

Solidity
function transferFrom(address _from, address _to, uint256 _tokenId) external payable; // Transfers tokenId token from _from to _to

まず、ロジックを理解するためにこのコードを見てみましょう:

Solanaでは、各トークンは固有のMintアドレスで識別され、ユーザーはAssociated Token Account(ATA)に残高を保管します。トランザクションでは、ATAアドレスがトークン送受信の送信元または受信先として使用されます。ERC-20コントラクトを直接呼び出すEthereumとは異なり、Solanaは共有のToken Programを通じてトークン転送を処理します。

createTransferCheckedInstructionでトランザクションの転送instructionsを作成し、@solana/spl-tokenのsendTransactionで送信できます。


JSX
import { Keypair, Transaction, Connection, PublicKey } from "@solana/web3.js";
import { createTransferCheckedInstruction } from "@solana/spl-token";

const connection = new Connection("https://api.devnet.solana.com", "confirmed");

// Replace with your real private key (as a Uint8Array)
const ownerSecretkey = [];
const ownerPrivatekeypair = Keypair.fromSecretKey(new Uint8Array(ownerSecretkey));

const fromPublicKey = ownerPrivatekeypair.publicKey; // The sender's public key
const toPublicKey = new PublicKey("Receiver's Wallet Address");

const mintAddress = new PublicKey("Token Address");

// Pre-existing ATA addresses (for `_from` and `_to`)
const ownerTokenAccount = new PublicKey("Associated Token Account of _from");
const receiverTokenAccount = new PublicKey("Associated Token Account of _to");

// For an NFT, decimals = 0 and amount = 1
async function transferFrom(_from, _to) {
  try {
    const tx = new Transaction().add(
      createTransferCheckedInstruction(
        ownerTokenAccount,              // _from's ATA
        mintAddress,
        receiverTokenAccount,           // _to's ATA
        ownerPrivatekeypair.publicKey,  // Authority for `_from` (the private key must match this public key)
        1,                              // amount = 1 NFT
        0                               // decimals = 0 for NFT
      )
    );
    
    // Send transaction (simple version)
    await connection.sendTransaction(tx, [ownerPrivatekeypair]);
    return true;
  } catch (error) {
    console.error("Error in transferFrom:", error);
    return false;
  }
}

transferFrom(fromPublicKey, toPublicKey)
  .then(result => {
    console.log("transferFrom result:", result);
  })
  .catch(error => {
    console.error("Error:", error);
  });

receiverAddressからreceiverTokenAddressを確認するにはどうすればよいでしょうか?getOrCreateAssociatedTokenAccountを使用できます。associated token accountを取得し、存在しない場合は作成します。

JSX
import { Keypair, Transaction, Connection, PublicKey } from "@solana/web3.js";
import { createTransferCheckedInstruction, getOrCreateAssociatedTokenAccount } from "@solana/spl-token";

const connection = new Connection("https://api.devnet.solana.com", "confirmed");

// Insert your private key as a Uint8Array
const ownerSecretkey = [];
const ownerPrivatekeypair = Keypair.fromSecretKey(new Uint8Array(ownerSecretkey));

const fromAddress = ownerPrivatekeypair.publicKey;  // The sender's public key
const toAddress = new PublicKey("Receiver's Wallet Address");

const mintAddress = new PublicKey("Token Address");

// For an NFT: decimals = 0, amount = 1
async function transferFrom(_from, _to) {
  try {
    // Retrieve (or create if missing) the sender's ATA
    const ownerTokenAccount = await getOrCreateAssociatedTokenAccount(
      connection,
      ownerPrivatekeypair,    // Fee payer
      mintAddress,
      _from
    );

    // Retrieve (or create if missing) the receiver's ATA
    const receiverTokenAccount = await getOrCreateAssociatedTokenAccount(
      connection,
      ownerPrivatekeypair,    // Fee payer (use the receiver if needed)
      mintAddress,
      _to
    );

    // Create transaction with a transfer of 1 NFT (decimals=0)
    const tx = new Transaction().add(
      createTransferCheckedInstruction(
        ownerTokenAccount.address,
        mintAddress,
        receiverTokenAccount.address,
        ownerPrivatekeypair.publicKey,
        1, // Always transfer exactly 1 (NFT)
        0  // decimals = 0 for an NFT
      )
    );

    // Send the transaction
    await connection.sendTransaction(tx, [ownerPrivatekeypair]);
    return true;
  } catch (error) {
    console.error("Error in transferFrom:", error);
    return false;
  }
}

transferFrom(fromAddress, toAddress)
  .then(result => {
    console.log("Transaction result:", result);
  })
  .catch(error => {
    console.error("Error:", error);
  });

さらに多くの機能を探求したいですか?このガイドをご覧ください!

すべてのデータを保存し、コンセンサスに参加するノード

  • Ethereum:アーカイブノード
  • Solana:[該当なし]

一部のデータを保存し、コンセンサスに参加するノード

  • Ethereum:フルノード
  • Solana:コンセンサスノード

一部のデータを保存し、コンセンサスに参加しないノード

  • Ethereum:ライトノード
  • Solana:RPCノード

Keep Learning

SolanaのERC20について学ぶ

EthereumとSolanaでトークンのミントがどのように異なるかをご覧ください

Explore
© 2026 Solana Foundation. 無断転載を禁じます。
SolanaにおけるERC721とは? | Solana