Study
Truffle

Kompilasi (truffle compile)

Penjelasan

Perintah `truffle compile` mengompilasi seluruh contract di folder `contracts/` menggunakan versi solc yang ditentukan di truffle-config.js. Hasil kompilasi disimpan sebagai file JSON "artifact" di folder `build/contracts/`, masing-masing berisi ABI, bytecode, dan informasi jaringan tempat contract itu terakhir di-deploy (networks object). Berbeda dari Hardhat/Foundry yang folder artifact-nya terpisah rapi berdasarkan versi network, artifact Truffle menyimpan riwayat alamat deployment langsung di dalam file JSON yang sama per contract, di bawah key `networks` beridentitas network ID.

Contoh Konsep

# Kompilasi seluruh contract
truffle compile

# Output contoh:
# Compiling your contracts...
# ===========================
# > Compiling ./contracts/Migrations.sol
# > Artifacts written to build/contracts

# Kompilasi ulang paksa (mengabaikan cache)
truffle compile --all

Praktikum

Kompilasi project Truffle-mu, lalu buka file JSON hasil kompilasi di build/contracts/ dan identifikasi field abi serta networks di dalamnya.

Editor Latihan

Ketik/edit bebas di sini untuk latihan — kode ini tidak dijalankan.

Tips

Kalau ganti versi solc di truffle-config.js, jalankan `truffle compile --all` bukan `truffle compile` biasa, supaya seluruh contract dikompilasi ulang, tidak hanya yang berubah.