Deploy a contract with Truffle
Who this is for: developers deploying a Solidity contract to Lumia with Truffle.
Prerequisites: a Truffle project with your contract already written and compiling; a wallet funded on the network you're targeting. See Get testnet tokens for Beam.
Time: a few minutes once your contract compiles.
2
2. Add a network entry to truffle-config.js
Pull the RPC URL and chain ID from /reference/networks via an environment variable:
require("dotenv").config();
const HDWalletProvider = require("@truffle/hdwallet-provider");
module.exports = {
networks: {
lumiaBeam: {
provider: () =>
new HDWalletProvider(process.env.PRIVATE_KEY, process.env.LUMIA_BEAM_RPC_URL), // RPC from /reference/networks
network_id: 2030232745,
},
},
compilers: {
solc: {
version: "0.8.24",
},
},
};3
3. Set LUMIA_BEAM_RPC_URL and PRIVATE_KEY in a .env file
Never commit this file. Copy the RPC value from /reference/networks.
4
Verify it worked
The migration output prints the deployed contract address. Search that address on the Beam explorer (see Block explorers) and confirm a confirmed contract-creation transaction.
Troubleshooting
Was this helpful?