⌘K

Icon SunFilledIcon MoonStars
Running a Local Node

Icon LinkRunning a local Fuel node

In addition to deploying and testing on the Fuel Testnet, you can also run a local Fuel Node.

There are two types of Fuel networks that can be run:

  1. In-memory network (without persistence)
  2. Local network with persistence

Icon LinkIn-memory local node (without state persistence)

An in-memory node does not persist the blockchain state anywhere, it is only stored in memory as long as the node is active and running.

To spin-up a local in-memory Fuel node, run the following command:

fuel-core run --db-type in-memory

To deploy a contract to the local node, run the following command:

forc deploy <signing-key> --node-url 127.0.0.1:4000/graphql

Or to deploy without using a signing key:

forc deploy --unsigned --node-url 127.0.0.1:4000/graphql

Icon LinkChain Configuration

To modify the initial state of the chain, you must configure a chainConfig.json file. Here is an example of what that looks like using version 0.20.5 of fuel-core:

{
  "chain_name": "Testnet",
  "block_gas_limit": 10000000,
  "initial_state": {
    "coins": [
      {
        "owner": "0x53a9c6a74bee79c5e04115a007984f4bddaafed75f512f68766c6ed59d0aedec",
        "amount": "0x0004000000000000",
        "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
      }
    ]
  },
  "transaction_parameters": {
    "contract_max_size": 16777216,
    "max_inputs": 255,
    "max_outputs": 255,
    "max_witnesses": 255,
    "max_gas_per_tx": 10000000,
    "max_script_length": 1048576,
    "max_script_data_length": 1048576,
    "max_storage_slots": 255,
    "max_predicate_length": 1048576,
    "max_predicate_data_length": 1048576,
    "max_gas_per_predicate": 10000000,
    "gas_price_factor": 1000000000,
    "gas_per_byte": 4,
    "max_message_data_length": 1048576,
    "chain_id": 0
  },
  "gas_costs": {
    "add": 1,
    "addi": 1,
    "aloc": 1,
    "and": 1,
    "andi": 1,
    "bal": 13,
    "bhei": 1,
    "bhsh": 1,
    "burn": 132,
    "cb": 1,
    "cfei": 1,
    "cfsi": 1,
    "croo": 16,
    "div": 1,
    "divi": 1,
    "eck1": 951,
    "ecr1": 3000,
    "ed19": 3000,
    "eq": 1,
    "exp": 1,
    "expi": 1,
    "flag": 1,
    "gm": 1,
    "gt": 1,
    "gtf": 1,
    "ji": 1,
    "jmp": 1,
    "jne": 1,
    "jnei": 1,
    "jnzi": 1,
    "jmpf": 1,
    "jmpb": 1,
    "jnzf": 1,
    "jnzb": 1,
    "jnef": 1,
    "jneb": 1,
    "k256": 11,
    "lb": 1,
    "log": 9,
    "lt": 1,
    "lw": 1,
    "mcpi": 33,
    "mint": 135,
    "mlog": 1,
    "mod": 1,
    "modi": 1,
    "move": 1,
    "movi": 1,
    "mroo": 2,
    "mul": 1,
    "muli": 1,
    "mldv": 1,
    "noop": 1,
    "not": 1,
    "or": 1,
    "ori": 1,
    "ret_contract": 13,
    "rvrt_contract": 13,
    "s256": 2,
    "sb": 1,
    "scwq": 13,
    "sll": 1,
    "slli": 1,
    "srl": 1,
    "srli": 1,
    "srw": 12,
    "sub": 1,
    "subi": 1,
    "sw": 1,
    "sww": 43,
    "swwq": 44,
    "time": 1,
    "tr": 105,
    "tro": 60,
    "wdcm": 1,
    "wqcm": 1,
    "wdop": 1,
    "wqop": 1,
    "wdml": 1,
    "wqml": 1,
    "wddv": 1,
    "wqdv": 2,
    "wdmd": 3,
    "wqmd": 4,
    "wdam": 2,
    "wqam": 3,
    "wdmm": 3,
    "wqmm": 3,
    "xor": 1,
    "xori": 1,
    "call": {
      "base": 144,
      "dep_per_unit": 214
    },
    "ccp": {
      "base": 15,
      "dep_per_unit": 103
    },
    "csiz": {
      "base": 17,
      "dep_per_unit": 790
    },
    "ldc": {
      "base": 15,
      "dep_per_unit": 272
    },
    "logd": {
      "base": 26,
      "dep_per_unit": 64
    },
    "mcl": {
      "base": 1,
      "dep_per_unit": 3333
    },
    "mcli": {
      "base": 1,
      "dep_per_unit": 3333
    },
    "mcp": {
      "base": 1,
      "dep_per_unit": 2000
    },
    "meq": {
      "base": 1,
      "dep_per_unit": 2500
    },
    "retd_contract": {
      "base": 29,
      "dep_per_unit": 62
    },
    "smo": {
      "base": 209,
      "dep_per_unit": 55
    },
    "srwq": {
      "base": 47,
      "dep_per_unit": 5
    }
  },
  "consensus": {
    "PoA": {
      "signing_key": "f65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871"
    }
  }
}

To start the node with a custom configuration, you can use the command below:

fuel-core run --chain ./chainConfig.json --db-type in-memory

To find an example chain configuration file for a specific fuel-core version, refer to the fuel-core Icon Link repo.

Icon LinkFunding a wallet locally

You can edit the coins array inside the inital_state object to modify the initial assets owned by a given address.

The owner address must be a B256 type address (begins with 0x) instead of a Bech32 type (begins with fuel).

The amount is a hex value. In this example, the value translates to 1,125,899.9 ETH.

Icon LinkLocal node (with state persistence)

This node does persist the blockchain state locally. To run a local node with persistence a chain configuration file is required.

To start the node, run the following command:

fuel-core run --ip 127.0.0.1 --port 4000 --chain ./chainConfig.json --db-path ./.fueldb

Icon LinkConnecting to the local node from a browser wallet

To connect to the local node using a browser wallet, import the network address as:

http://127.0.0.1:4000/graphql