require("@nomicfoundation/hardhat-toolbox");require("dotenv").config();module.exports = { solidity: { version: "0.8.20", settings: { // Blob opcodes are not supported on StableNet — do not use cancun evmVersion: "shanghai", }, }, networks: { stablenet_testnet: { url: "https://api.test.stablenet.network", chainId: 8283, accounts: [process.env.PRIVATE_KEY], }, },};
evmVersion을 cancun으로 설정하지 마세요. StableNet은 blob 옵코드(BLOBHASH, BLOBBASEFEE)를 지원하지 않습니다. paris 또는 shanghai를 사용하세요.
3
WKRCPayment.sol 작성
기본 제공 컨트랙트를 삭제하고 contracts/WKRCPayment.sol을 만듭니다:
rm contracts/Lock.sol
// SPDX-License-Identifier: MITpragma solidity ^0.8.20;interface IERC20 { function transferFrom(address from, address to, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256);}/// @title WKRCPayment/// @notice Accepts WKRC payments from an approved sender./// The sender must approve this contract before calling pay().contract WKRCPayment { /// @dev NativeCoinAdapter (WKRC) — fixed system contract address on StableNet. IERC20 public constant WKRC = IERC20(0x0000000000000000000000000000000000001000); event Payment(address indexed from, address indexed to, uint256 amount); /// @notice Pull `amount` of WKRC from msg.sender and forward it to `to`. /// Requires prior WKRC.approve(address(this), amount). function pay(address to, uint256 amount) external { require(WKRC.transferFrom(msg.sender, to, amount), "WKRC transfer failed"); emit Payment(msg.sender, to, amount); } /// @notice Check how much WKRC `owner` has approved for this contract. function allowanceOf(address owner) external view returns (uint256) { return WKRC.allowance(owner, address(this)); }}
Hardhat v3 — npx hardhat init이 인터랙티브 전용으로 변경됐습니다. Hardhat v3는 npx hardhat init이 인터랙티브 전용으로 바뀌어 일부 환경에서 정상 동작하지 않을 수 있습니다. 표준 프로젝트 구조를 사용하려면 Hardhat v2를 설치하세요:
npm install --save-dev hardhat@2
27,600 Gwei에서 블록 포함이 느린 경우. 트랜잭션 확정이 느리면 두 값을 모두 높이세요: