Skip to main content
Deploy a Solidity contract to StableNet Testnet using Foundry’s forge and cast tools.

What you’ll learn

By the end of this tutorial, you’ll be able to:
  • Configure a Foundry project for StableNet Testnet
  • Deploy a WKRC payment contract using forge script
  • Call contract functions with cast send and verify the result on Explorer

Prerequisites

  • Foundry installed — run forge --version to check. If not installed:
  • Testnet WKRC from the Faucet

Scaffold your project

Configure foundry.toml

Add the StableNet Testnet endpoint to foundry.toml:

Write WKRCPayment.sol

Delete the placeholder and create src/WKRCPayment.sol:
Compile to confirm there are no errors:

Write the deploy script

Create script/DeployWKRCPayment.s.sol:

Deploy to Testnet

Never commit your private key to version control. Store it in a .env file and add .env to .gitignore.
Save the Contract Address — you need it in the next step.
StableNet enforces a minimum priority fee set by the GovValidator contract. Pass --priority-gas-price 27600000000000 on every forge script and cast send call.

Approve WKRC and send a payment

Before calling pay(), approve the deployed contract to spend WKRC from your wallet:
Confirm the allowance was consumed:

Verify on Explorer

Open explorer.stablenet.network and search for your contract address. You should see the deployment transaction, the approve call on the WKRC contract, and the pay call with a Payment event in the logs.

Next steps

Deploy with Hardhat

Deploy the same contract using Hardhat and ethers.js.

Listen to Events

Subscribe to on-chain events with WebSocket.

RPC API Reference

Full list of supported JSON-RPC methods.

Fee Delegation

Let a separate account pay gas for your users.