Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.skale.space/llms.txt

Use this file to discover all available pages before exploring further.

Now that you’re connected and have CREDITS to cover compute costs, let’s deploy your first smart contract on SKALE Base Mainnet. This guide uses Foundry — a fast, portable toolkit for Ethereum development. If you prefer Hardhat, see the Setup Hardhat guide.
Every transaction in this guide deducts from your CREDIT balance — no gas token needed. Make sure you have CREDITS before starting. See Buy CREDITS.

Prerequisites

Step 1: Set Up a Foundry Project

forge init my-skale-contract
cd my-skale-contract
Project structure:
my-skale-contract/
├── src/          # Smart contracts
├── script/       # Deployment scripts
├── test/         # Test files
├── lib/          # Dependencies
├── foundry.toml  # Configuration
└── remappings.txt
Install OpenZeppelin contracts:
forge install OpenZeppelin/openzeppelin-contracts

Step 2: Configure foundry.toml

Update foundry.toml to point at SKALE Base Mainnet:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]

[rpc_endpoints]
skale_mainnet = "https://skale-base.skalenodes.com/v1/base"

Step 3: Create Your Contract

Create an ERC-721 (NFT) contract in src/MyNFT.sol:
touch src/MyNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract MyNFT is ERC721 {
    uint256 private _nextTokenId;

    constructor() ERC721("MyNFT", "MNFT") {}

    function mint(address to) public {
        uint256 tokenId = _nextTokenId;
        _safeMint(to, tokenId);
        _nextTokenId++;
    }

    function getNextTokenId() public view returns (uint256) {
        return _nextTokenId;
    }
}

Step 4: Compile

forge build

Step 5: Deploy to Mainnet

Deploy your contract to SKALE Base Mainnet:
forge create src/MyNFT.sol:MyNFT \
    --interactive \
    --rpc-url skale_mainnet \
    --legacy
Or use an encrypted keystore:
forge create src/MyNFT.sol:MyNFT \
    --account skale-deployer \
    --rpc-url skale_mainnet \
    --broadcast \
    --legacy
SKALE Chains require the --legacy flag. If you don’t have a keystore, --interactive prompts for your private key. The deployment will deduct CREDITS from your wallet to cover compute.
Done. Your contract is live on SKALE Base Mainnet. Next, verify your contract or deploy an ERC-20 token.