On this page

Use this guide for a new Solidity project. Forge compiles and tests contracts; Cast reads chain data and sends signed transactions. The examples target Paxeer chain ID 125, whose native gas token is PAX.

Set up the project

Install Forge and Cast using the Foundry installation instructions, then create a project. Keep the generated project files; add the named files below alongside the scaffold.

forge init paxeer-counter
cd paxeer-counter
forge --version
cast --version

Use this foundry.toml for the example. The explicit Paris target keeps these basic contracts independent of newer opcode requirements. Match compiler settings to the network upgrade you intend to use when adding newer EVM features.

[profile.default]
src = "src"
out = "out"
libs = ["lib"]
solc_version = "0.8.28"
evm_version = "paris"
optimizer = true
optimizer_runs = 200

[rpc_endpoints]
paxeer = "${PAXEER_RPC_URL}"

Write the contract

Create src/PaxeerCounter.sol. Anyone can update this demonstration counter; it is useful for checking storage, events, and frontend reads.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

contract PaxeerCounter {
    uint256 public number;
    event NumberChanged(address indexed caller, uint256 number);

    function setNumber(uint256 next) external {
        number = next;
        emit NumberChanged(msg.sender, next);
    }

    function increment() external {
        number += 1;
        emit NumberChanged(msg.sender, number);
    }
}

Test local behavior

Create test/PaxeerCounter.t.sol. These tests run the contract locally in Forge, using an isolated test environment.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {Test} from "forge-std/Test.sol";
import {PaxeerCounter} from "../src/PaxeerCounter.sol";

contract PaxeerCounterTest is Test {
    PaxeerCounter private counter;

    function setUp() public {
        counter = new PaxeerCounter();
    }

    function test_Increment() public {
        counter.increment();
        assertEq(counter.number(), 1);
    }

    function testFuzz_SetNumber(uint256 next) public {
        counter.setNumber(next);
        assertEq(counter.number(), next);
    }
}
forge build
forge test --match-contract PaxeerCounterTest -vv
forge test --match-contract PaxeerCounterTest --gas-report

The expected result is two passing tests, including the generated fuzz cases. Use the gas report to compare the cost of individual contract calls. Measure network throughput separately with a Paxeer development cluster.

Connect and rehearse deployment

Set PAXEER_RPC_URL to your EVM HTTP endpoint. This is different from a Cosmos RPC endpoint. Confirm its chain ID before selecting a signer. Import a development account into Foundry’s encrypted keystore when prompted.

: "${PAXEER_RPC_URL:?Set your Paxeer EVM RPC URL}"
test "$(cast chain-id --rpc-url "$PAXEER_RPC_URL")" = 125 || { echo "Expected Paxeer chain ID 125" >&2; exit 1; }
cast wallet import paxeer-dev --interactive
forge create src/PaxeerCounter.sol:PaxeerCounter   --rpc-url "$PAXEER_RPC_URL" --account paxeer-dev

forge create without --broadcast performs a dry run. Review the destination chain, sender, and estimated cost. The signer needs PAX for an actual Paxeer deployment. For a local development network, use its actual chain ID and local funds.

Publish and read the result

The next command broadcasts a contract-creation transaction. Save its address and transaction hash from the output.

forge create src/PaxeerCounter.sol:PaxeerCounter   --rpc-url "$PAXEER_RPC_URL" --account paxeer-dev --broadcast

# Set CONTRACT_ADDRESS and TX_HASH from the deployment output.
cast receipt "$TX_HASH" --rpc-url "$PAXEER_RPC_URL"
cast code "$CONTRACT_ADDRESS" --rpc-url "$PAXEER_RPC_URL"
cast call "$CONTRACT_ADDRESS" 'number()(uint256)'   --rpc-url "$PAXEER_RPC_URL"

Confirm a successful receipt, nonempty deployed bytecode, and an initial counter value of zero. The contract ABI is in out/PaxeerCounter.sol/PaxeerCounter.json. Use that artifact in your frontend; keep the compiler version and optimizer settings with your deployment record.

Reference: Foundry deployment and verification. For explorer verification, select a verifier that supports your Paxeer endpoint and submit the same compiler settings used for deployment.

Paxeer source: paxeer-network/ — contracts/hardhat.config.js (Solidity 0.8.28), modules/evm/config/config.go (ChainIDMapping), and rpc/send.go (SendRawTransaction).
Paxeer Network · Developer documentationBack to top ↑

Ask Paxeer Docs

Answers from the documentation.

What would you like to know?

Ask a question, find a guide, or get help with your next step.

Enter to send · Shift+Enter for a new line