Foundry

Deploy smart contracts to Neura with Foundry using your existing EVM workflow. This guide covers installing Foundry, initializing a project, configuring Neura Testnet (RPC + chain ID), compiling, and deploying from a keystore (recommended). If you already use Foundry, just point your RPC to Neura and update the chain ID.

Tooling Requirements

Before you begin, make sure the following dependencies are installed:

  • Rust (required for Foundry setup):

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Foundryup (official installer for the Foundry toolchain):

curl -L https://foundry.paradigm.xyz | bash

After installing foundryup, run the following:

foundryup

This will install the full toolchain:

  • forge – build & test tool

  • cast – CLI for Ethereum RPC calls

  • anvil – local Ethereum node

  • chisel – code generation utility


Project Initialization

Create a new Foundry project using the default template:

forge init [project_name]

This will generate a basic contract workspace with default folders:

  • src/ – Solidity contracts

  • test/ – test files

  • lib/ – dependencies


Configuration for Neura

Foundry uses a foundry.toml file for configuration. You can optionally define the Neura RPC and chain ID directly in this file:

[profile.default]
src = "src"
out = "out"
libs = ["lib"]

# Optional: RPC & chain settings for Neura
eth-rpc-url = "https://testnet.rpc.neuraprotocol.io"
chain_id = 267

Alternatively, you can store sensitive values like eth-rpc-url in a .env file:

ETH_RPC_URL=https://testnet.rpc.neuraprotocol.io
CHAIN_ID=267

Then access them via:

--rpc-url $ETH_RPC_URL

Example Smart Contract

A minimal example is included in your Foundry project as src/Counter.sol:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract Counter {
    uint256 public number;

    function setNumber(uint256 newNumber) public {
        number = newNumber;
    }

    function increment() public {
        number++;
    }
}

Compile Smart Contract

Use the following command to compile your contract:

forge compile

Compiled output will appear in the out/ directory, including the ABI and bytecode.


Wallet Setup and Deployment

  1. Generate and securely store a new wallet in a keystore:

cast wallet import neura-deployer --private-key $(cast wallet new | grep 'Private key:' | awk '{print $3}')

This will do the following:

  • Create a new private key.

  • Encrypt and save it as a keystore file.

  • Prompt you to set a password.

  1. Retrieve the address of the keystore:

cast wallet address --account neura-deployer

Deploy the Contract

Deploy the Counter contract to the Neura testnet:

forge create src/Counter.sol:Counter \
  --account neura-deployer \
  --broadcast \
  --rpc-url https://testnet.rpc.neuraprotocol.io

Make sure you have testnet $ANKR (see faucet section below).

Sample Output

Deployer: 0xF5d4...c5e2
Deployed to: 0x8A2E...Af01
Transaction hash: 0xabc123...

Neura Testnet Faucet

You can request testnet ANKR using the Neura faucet:

Paste your wallet address, solve the captcha, and claim your test tokens.


Last updated