Standalone scripts for interacting with StableNet Testnet and the WKRCPayment contract.
| File | Description |
|---|---|
ethers-demo.js |
Connect, query balance, approve, and pay using ethers.js v6 |
viem-demo.mjs |
Same flow using viem |
npm install ethers viem dotenvCreate a .env file:
PRIVATE_KEY=0xYourPrivateKey
CONTRACT=0xYourDeployedWKRCPaymentAddress
RECIPIENT=0xRecipientAddress
# ethers.js
node ethers-demo.js
# viem
node viem-demo.mjsWith Node.js v20+, you can skip dotenv and use:
node --env-file=.env ethers-demo.js
node --env-file=.env viem-demo.mjs- Connect to
https://api.test.stablenet.network(Chain ID8283) - Print the wallet address and WKRC balance (native and ERC-20 — always equal)
- Approve the
WKRCPaymentcontract to spend 1 WKRC - Call
pay()to forward 1 WKRC to the recipient - Print remaining allowance (should be 0)
Every StableNet transaction requires both fee fields:
| Field | Minimum |
|---|---|
maxPriorityFeePerGas |
27,600 Gwei |
maxFeePerGas |
>= maxPriorityFeePerGas (80,000 Gwei recommended) |
Omitting either field causes the transaction to be rejected.