# Hello World 步驟提示 ```bash= truffle init # 1. 初始化 # 2. 更改檔案內容 truffle compile #3. 寫完智能合約後編譯 truffle migrate #4. 部屬 ``` contracts/HelloWorld.sol ```solidity= // SPDX-License-Identifier: MIT // compiler version must be greater than or equal to 0.8.10 and less than 0.9.0 pragma solidity ^0.8.10; contract HelloWorld { string public greet = "Hello World!"; } ``` migrations/2_depoly_hello_world.js // 要加上序數,否則migrate 無法辨認 ```js= const HelloWorld = artifacts.require("HelloWorld.sol"); module.exports = function (deployer) { deployer.deploy(HelloWorld); }; ``` truffle-config.js ```javascript= module.exports = { networks: { development: { host: "127.0.0.1", // Localhost (default: none) port: 7545, // Standard Ethereum port (default: none) network_id: "*", // Any network (default: none) }, }, compilers: { solc: { version: "0.8.10", // Fetch exact version from solc-bin (default: truffle's version) optimizer: { enabled: true, runs: 200 }, } }, }; ``` 貼完上述程式就可以執行 `truffle compile # 編譯` `truffle migrate # 部屬` truffle migrate 後結果 ![](https://hackmd.io/_uploads/SJhr4Y-3F.png)