ローカルネットにおけるNFTの発行:Solファイルのコンパイルとデプロイ
次はSolidityファイルをコンパイルしていきます。truffle compileで実行。おわりです。
$ truffle compile
> Compiling your contracts…
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/tbfToken.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/Address.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/Context.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/Strings.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol
> Artifacts written to /Users/takumina/Ethereum/tbftoken/build/contracts
> Compiled successfully using:
- solc: 0.8.0+commit.c7dfd78e.Emscripten.clang
さっき作ったtbfToken.solをdeployしてきましょう。Migrationは以下のファイルを作成します。

中身はこんな感じ。
// migrations/2_deploy.js
const tbfToken = artifacts.require("tbfToken");
module.exports = async function (deployer) {
await deployer.deploy(tbfToken);
};
準備できたら、truffle migrateを実施していきます。
$ truffle migrate --network development
Compiling your contracts…
================================
>Everything is up to date, there is nothing to compile.
Starting migrations…
================================
>Network name: 'development'
>Network id: 5777
>Block gas limit: 6721975 (0x6691b7)
2_deploy.js
================================
Deploying 'tbfToken'
---------------------
>transaction hash: 0x7267bf8cdbe325f81312f8d0547ba19a6b24ea8011dc31469f78a7674ce0d133
>Blocks: 0 Seconds: 0
>contract address: 0x86C0d4D44F6ec22D151b1b7A344E830020323C0a
>block number: 3
>block timestamp: 1623477137
>account: 0x83eFcE6f3C6347D360B67bBDd842c26c855bA850
>balance: 99.95383938
>gas used: 2021218 (0x1ed762)
>gas price: 20 gwei
>value sent: 0 ETH
>total cost: 0.04042436 ETH
>Saving migration to chain.
>Saving artifacts
---------------------
>Total cost: 0.04042436 ETH
Summary
==========
>Total deployments: 1
>Final cost: 0.04042436 ETH
無事完了するとGanacheの一番目(INDEX0)のBALANCEが減っていることがわかります。
