Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

scripts

Standalone scripts for interacting with StableNet Testnet and the WKRCPayment contract.

Files

File Description
ethers-demo.js Connect, query balance, approve, and pay using ethers.js v6
viem-demo.mjs Same flow using viem

Setup

npm install ethers viem dotenv

Create a .env file:

PRIVATE_KEY=0xYourPrivateKey
CONTRACT=0xYourDeployedWKRCPaymentAddress
RECIPIENT=0xRecipientAddress

Run

# ethers.js
node ethers-demo.js

# viem
node viem-demo.mjs

With Node.js v20+, you can skip dotenv and use:

node --env-file=.env ethers-demo.js
node --env-file=.env viem-demo.mjs

What the scripts do

  1. Connect to https://api.test.stablenet.network (Chain ID 8283)
  2. Print the wallet address and WKRC balance (native and ERC-20 — always equal)
  3. Approve the WKRCPayment contract to spend 1 WKRC
  4. Call pay() to forward 1 WKRC to the recipient
  5. Print remaining allowance (should be 0)

Fee note

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.