Skip to content


Intro diagram


Truffle is a popular development framework for compiling, testing, and deploying Solidity smart contracts. Since Moonbeam is Ethereum compatible, with a few lines of extra configuration, you can use Truffle as you normally would with Ethereum to develop on Moonbeam.

Configure Truffle to Connect to Moonbeam

If you haven't yet, you'll want to globally install Truffle:

npm install -g truffle

In your truffle-config.js file, add network configurations for a Moonbeam development node and the Moonbase Alpha TestNet:

const HDWalletProvider = require('@truffle/hdwallet-provider');
// Moonbeam Development Node Private Key
const privateKeyDev =
// Moonbase Alpha Private Key
const privateKeyMoonbase = "YOUR-PRIVATE-KEY-HERE";
// Moonriver Private Key - Note: This is for example purposes only. Never store your private keys in a JavaScript file.
const privateKeyMoonriver = "YOUR-PRIVATE-KEY-HERE";

module.exports = {
   networks: {
      // Moonbeam Development Node
      dev: {
        provider: () => {
          return new HDWalletProvider(privateKeyDev, 'http://localhost:9933/')
        network_id: 1281,
      // Moonbase Alpha TestNet
      moonbase: {
        provider: () => {
          return new HDWalletProvider(
        network_id: 1287,
      // Moonriver
      moonriver: {
        provider: () => {
          return new HDWalletProvider(
        network_id: 1285,


If you are interested in a more detailed step-by-step guide, go to our specific tutorial about using Truffle with Moonbeam.