Using Truffle
Overview
This guide walks you through using Truffle migrations to deploy an NFT smart contract to the Palm network.
🏁 Prerequisites
- Get PALM Tokens to pay the deployment transaction fees.
- Connect to Palm network
- MetaMask Wallet Setup to get your private key.
Tutorial
1. Initialize Your NPM Project
2. Install Truffle on Your Project Folder
3. Initialize Truffle
4. Install Truffle's HDWalletProvider
5. Add your Contract
We'll use a contract based on the OpenZeppelin library’s ERC-721 implementation.
a) First, install the Open Zeppelin library in order to inherit its classes:
b) Next, create a file named NFT.sol under the contracts folder.

c) Lastly, add the following smart contract to NFT.sol file. Note that we have named our contract NFT, this can be any name.
The name will be important in the next step.
6. Create Your Migration File
What are Migrations?
Migrations are JavaScript files that help you deploy contracts to the Ethereum network. These files are responsible for staging your deployment tasks, and they're written under the assumption that your deployment needs will change over time.`
Under the migrations folder, create your filename: 1_example_migration.js

Additional Resources
7. Set environment variables with dotenv
- Install dotenv
Keep Your Private Keys Secret Private keys must be kept secret and not committed to any code repository. In the example of this tutorial, the .env file should be added to your .gitignore file and kept local. For example, see MyCrypto's Protecting Yourself and Your Funds guide.
- Create a .gitignore file
A great example of a Solidity .gitignore file can be found here

- Create an .env file n your project's root folder, and set environment variables in the file as follows

8. Edit truffle-config.js with the following text
9. Deploy to the Target Palm Network Environment
10. Look Up Your Deployment on the Palm Network Block Explorer
Paste your `contract address:` from the log of the previous step into the search bar. It may take 10-20 minutes to appear.
| Testnet | Mainnet |
Explorer URL |
If successful, you will see something like this screenshot:

11. Install Truffle-Plugin-Verify
This plugin will allow you to automatically verify your smart contracts's source code straight from the CLI.
12. Add the plugin to your truffle-config.js file
13. Verify Contract
Use the name of your contract to verify on the desired network.
