Skip to main content

API Reference

Complete reference for Scaffold-DOT commands and configuration.

Yarn Commands

Development Commands

CommandDescription
yarn chainStart local Substrate node with PolkaVM support
yarn rpcStart Ethereum RPC compatibility server
yarn deployDeploy smart contracts to configured network
yarn startStart NextJS development server
yarn hubStart all services (chain, rpc, frontend) concurrently

Smart Contract Commands

CommandDescription
yarn compileCompile Solidity contracts with resolc
yarn testRun Hardhat contract tests with gas reporting
yarn hardhat:cleanClean build artifacts
yarn hardhat:flattenFlatten contract for verification
yarn hardhat:verifyVerify contract on block explorer

Account Management Commands

CommandDescription
yarn generateGenerate new encrypted account (interactive)
yarn accountDisplay account details and balances
yarn account:importImport existing private key (interactive)
yarn account:reveal-pkReveal encrypted private key (requires password)
yarn fundFund account on testnet via faucet

Build Commands

CommandDescription
yarn next:buildBuild NextJS for production
yarn next:serveServe production build locally
yarn buildBuild Polkadot binaries (alias for polkadot:build)

Code Quality Commands

CommandDescription
yarn lintLint all packages (frontend + contracts)
yarn formatFormat code with Prettier
yarn hardhat:check-typesType-check Hardhat package
yarn next:check-typesType-check NextJS package

Deployment Commands

CommandDescription
yarn deployDeploy to default network (localNode)
yarn deploy --network passetHubDeploy to Paseo testnet
yarn deploy --network kusamaHubDeploy to Kusama Asset Hub
yarn vercelDeploy frontend to Vercel
yarn ipfsDeploy frontend to IPFS

Configuration Files

hardhat.config.ts

Main Hardhat configuration file.

Location: packages/hardhat/hardhat.config.ts

Key Settings:

import { HardhatUserConfig } from "hardhat/config";

const config: HardhatUserConfig = {
// Solidity compiler version
solidity: {
version: "0.8.28",
settings: {
evmVersion: "cancun",
optimizer: {
enabled: true,
runs: 200,
},
},
},

// PolkaVM compiler settings
resolc: {
compilerSource: "npm",
version: "latest",
},

// Default network
defaultNetwork: "localNode",

// Network configurations
networks: {
localNode: {
url: "http://127.0.0.1:8545",
chainId: 420420420,
polkavm: true, // Required!
accounts: [getEncryptedAccount()],
},
passetHub: {
url: "https://paseo-asset-hub-eth-rpc.polkadot.io",
chainId: 420420422,
polkavm: true,
accounts: [getEncryptedAccount()],
},
kusamaHub: {
url: "https://kusama-asset-hub-eth-rpc.polkadot.io",
chainId: 420420418,
polkavm: true,
accounts: [getEncryptedAccount()],
},
},

// Gas reporter for tests
gasReporter: {
enabled: true,
currency: "USD",
},
};

Network Properties:

PropertyTypeRequiredDescription
urlstringRPC endpoint URL
chainIdnumberNetwork chain ID
polkavmbooleanMust be true for PolkaVM networks
accountsarray-Account private keys or getEncryptedAccount()

scaffold.config.ts

Frontend configuration file.

Location: packages/nextjs/scaffold.config.ts

Configuration Options:

import { ScaffoldConfig } from "~~/utils/scaffold-eth/contract";
import { localNode, passetHub, kusamaHub } from "./utils/scaffold-eth/chains";

const scaffoldConfig = {
// Networks your frontend will support
targetNetworks: [localNode],

// Whether to display connection status
showNetworkIndicator: true,

// WalletConnect project ID (get from https://cloud.walletconnect.com)
walletConnectProjectId: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID!,

// Auto-connect to previous wallet
walletAutoConnect: true,

// Only use burner wallet on local network
onlyLocalBurnerWallet: true,

// Wallet provider: "appkit" or "rainbowkit"
walletProvider: "appkit",

// Block explorer API key for contract verification
etherscanApiKey: process.env.ETHERSCAN_API_KEY,
} as const satisfies ScaffoldConfig;

Chain Definitions:

import { defineChain } from "viem";

export const localNode = defineChain({
id: 420420420,
name: "Local Revive Node",
nativeCurrency: {
decimals: 18,
name: "DOT",
symbol: "DOT",
},
rpcUrls: {
default: { http: ["http://127.0.0.1:8545"] },
},
blockExplorers: {
default: {
name: "Local Explorer",
url: "http://localhost:3000/blockexplorer",
},
},
});

Deployment Configuration

Ignition Module Format:

Location: packages/hardhat/ignition/modules/YourContract.ts

import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";

const YourContractModule = buildModule("YourContractModule", (m) => {
// Define parameters
const greeting = m.getParameter("greeting", "Hello Polkadot!");

// Deploy contract
const yourContract = m.contract("YourContract", [greeting]);

// Return deployed contract
return { yourContract };
});

export default YourContractModule;

Deployment with Parameters:

// Define default parameters
const YourContractModule = buildModule("YourContractModule", (m) => {
const owner = m.getParameter("owner", m.getAccount(0));
const initialSupply = m.getParameter("initialSupply", 1000000n);

const token = m.contract("Token", [owner, initialSupply]);

return { token };
});

Environment Variables

Hardhat Environment Variables

File: packages/hardhat/.env (gitignored)

# Encrypted account private key (generated by yarn generate)
ENCRYPTED_PRIVATE_KEY=...

# Password used for encryption (DO NOT commit)
ENCRYPTION_PASSWORD=...

# Optional: Block explorer API key
ETHERSCAN_API_KEY=...

NextJS Environment Variables

File: packages/nextjs/.env.local (gitignored)

# Required: WalletConnect project ID
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=...

# Optional: RPC provider API keys
NEXT_PUBLIC_ALCHEMY_API_KEY=...
NEXT_PUBLIC_INFURA_API_KEY=...

Public Variables:

  • Must be prefixed with NEXT_PUBLIC_ to be accessible in browser
  • Used in scaffold.config.ts

Server-Only Variables:

  • No prefix needed
  • Only accessible in server-side code

Contract Hooks API

useScaffoldReadContract

Read data from smart contracts.

import { useScaffoldReadContract } from "~~/hooks/scaffold-eth";

const { data, isLoading, error, refetch } = useScaffoldReadContract({
contractName: "YourContract",
functionName: "greeting",
args: [], // Optional: function arguments
watch: true, // Optional: auto-refresh on new blocks
});

Parameters:

ParameterTypeRequiredDescription
contractNamestringName of deployed contract
functionNamestringContract function to call
argsarray-Function arguments
watchboolean-Auto-refresh on new blocks (default: false)

Returns:

PropertyTypeDescription
dataanyFunction return value
isLoadingbooleanLoading state
errorError | nullError if call failed
refetchfunctionManually refetch data

useScaffoldWriteContract

Write data to smart contracts.

import { useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
import { parseEther } from "viem";

const { writeContractAsync, isPending } = useScaffoldWriteContract({
contractName: "YourContract",
});

// Call the function
await writeContractAsync({
functionName: "setGreeting",
args: ["Hello Polkadot!"],
value: parseEther("0.01"), // For payable functions
});

Parameters:

ParameterTypeRequiredDescription
contractNamestringName of deployed contract

Write Function Parameters:

ParameterTypeRequiredDescription
functionNamestringContract function to call
argsarray-Function arguments
valuebigint-ETH/DOT to send (payable functions)

Returns:

PropertyTypeDescription
writeContractAsyncfunctionExecute transaction (async)
isPendingbooleanTransaction pending state

useScaffoldEventHistory

Get historical contract events.

import { useScaffoldEventHistory } from "~~/hooks/scaffold-eth";

const { data: events, isLoading } = useScaffoldEventHistory({
contractName: "YourContract",
eventName: "GreetingChanged",
fromBlock: 0n,
toBlock: "latest",
watch: true,
});

Parameters:

ParameterTypeRequiredDescription
contractNamestringName of deployed contract
eventNamestringEvent to watch
fromBlockbigint-Start block (default: 0)
toBlockbigint | "latest"-End block (default: "latest")
watchboolean-Watch for new events (default: false)

Component API

Address

Display Ethereum/Polkadot addresses.

import { Address } from "~~/components/scaffold-eth";

<Address address="0x..." />
<Address address="0x..." disableAddressLink />
<Address address="0x..." format="short" />

Props:

PropTypeDefaultDescription
addressstring-Address to display
disableAddressLinkbooleanfalseDisable block explorer link
format"short" | "long""short"Display format
size"xs" | "sm" | "base" | "lg" | "xl""base"Font size

AddressInput

Input field for Ethereum/Polkadot addresses.

import { AddressInput } from "~~/components/scaffold-eth";

const [address, setAddress] = useState("");

<AddressInput
value={address}
onChange={setAddress}
placeholder="Enter address"
/>

Balance

Display account balance.

import { Balance } from "~~/components/scaffold-eth";

<Balance address="0x..." />
<Balance address="0x..." className="text-xl" />

EtherInput

Input field with ETH/USD conversion.

import { EtherInput } from "~~/components/scaffold-eth";

const [amount, setAmount] = useState("");

<EtherInput
value={amount}
onChange={setAmount}
placeholder="Amount in DOT"
/>

Gas Configuration

PolkaVM uses a fixed fee model:

// packages/nextjs/scaffold.config.ts
export const LOCAL_CHAIN_GAS_CONFIG = {
gasLimit: 1000000n,
gasPriceMultiplier: 25000,
};

Formula: gasLimit × gasPrice ≥ fixed_fee (≈22 billion wei)

Exit Codes

CodeDescription
0Success
1General error
128 + NFatal error signal N

Next Steps