We have already enabled solidity v0.8.28 on testnet and devnet now. Here is a test project example:
# install node and yarn first
git clone https://github.com/gzliudan/hardhat-project
cd hardhat-project
yarn
cp sample.env .env
# set DEPLOYER_PRIVATE_KEY in .env
# ensure your test account has some XDC token on devnet and testnet
vi .env
# test on XDC devnet
yarn test:xdcdev
# test on XDC testnet
yarn test:apothem
Here is my test result:
yarn run v1.22.22
$ hardhat test --network apothem test/v0.8.23/*.js test/v0.8.28/*.js
BaseFee contract
Deploy contract BaseFee ...
Deploy contract BaseFee OK, times=1, address: 0xc7758e0E48873cBCC3254924c539750E046013e0
Running on XDC network, chainId=51
All networks
Test getChainId
✔ should return correct chain ID (299ms)
Test getBaseFee
✔ should return current block number and base fee (652ms)
XDC network
✔ should return expected base fee for XDC networks (754ms)
Prevrandao contract
Deploy contract Prevrandao ...
Deploy contract Prevrandao OK, times=1, address: 0x66Bbb3fc27Bd8A20247D984a575f069B6A711BfA
Test getPrevrandao
✔ should return current block number and contract value (695ms)
Push0 contract
Deploy contract Push0 ...
Deploy contract Push0 OK, times=1, address: 0x4F700AD73a59F4Fa02B212Dbf77bB3780C4fA56D
Test setNum
✔ should initialize to 0 (349ms)
✔ should set the number correctly (5127ms)
✔ should update the number multiple times (18103ms)
✔ should handle large numbers (5727ms)
TestCoin contract
Deploy contract TestCoin ...
Deploy contract TestCoin OK, times=1, address: 0xD5eF8F2A930De17D51a84520808DDd73D4A3E5a8
Test name
✔ should return correct name (257ms)
Test symbol
✔ should return correct symbol (352ms)
Test total supply
✔ should return correct total supply (349ms)
Test transfer
✔ should transfer tokens between accounts (7307ms)
Test mint
✔ should mint new tokens (7359ms)
Test burn
✔ should mint and burn tokens (13139ms)
Test permit
✔ should permit token transfer (7267ms)
BlobBaseFee contract
Deploy contract BlobBaseFee ...
Deploy contract BlobBaseFee OK, times=1, address: 0x421e05263ac014bE686cAc8C0b7bB860d0e40D49
Running on XDC network, chainId=51
All Networks
Test getChainId
✔ should return correct chain ID (253ms)
Test getBlobBaseFee
✔ Should return valid blob base fee (345ms)
Test getBlobHashByIndex
✔ Should return valid blob hash for index 0 (365ms)
✔ Should return valid blob hash for random index (260ms)
✔ Should return valid blob hash for max index (462ms)
Test getMultipleBlobHashes
✔ Should return valid multiple blob hashes starting from index 0 (363ms)
✔ Should return valid multiple blob hashes starting from non-zero index (357ms)
✔ Should handle zero count in getMultipleBlobHashes (358ms)
XDC Network
Test getBlobBaseFee
✔ Should return 0 for blob base fee (371ms)
Test getBlobHashByIndex
✔ Should return 0 for blob hash with index 0 (326ms)
✔ Should return 0 for blob hash with random index (365ms)
✔ Should return 0 for blob hash with max index (341ms)
Test getMultipleBlobHashes
✔ Should return array of zeros starting from index 0 (359ms)
✔ Should return array of zeros starting from non-zero index (492ms)
CustomError contract
Deploy contract CustomError ...
Deploy contract CustomError OK, times=1, address: 0xDa79e4a4e15fcA7BBAb527F4e9cfFE92BC6e8987
Test withdraw
✔ Should pass when amount is valid (401ms)
✔ Should revert with InvalidAmount error when amount is 0 (363ms)
✔ Should revert with InsufficientBalance error when amount exceeds balance (365ms)
Test setOwner
✔ Should pass when new owner is valid (465ms)
✔ Should revert with InvalidAddress error when new owner is zero address (482ms)
✔ Should revert with InvalidAddress error when new owner is current owner (482ms)
Test updateNumbers
✔ Should pass when array length matches (476ms)
✔ Should revert with ArrayLengthMismatch error when array length does not match (352ms)
Test complexOperation
✔ Should pass when all parameters are valid (463ms)
✔ Should revert with InvalidAmount error when amount is 0 (349ms)
✔ Should revert with InsufficientBalance error when amount exceeds balance (375ms)
✔ Should revert with InvalidAddress error when target is zero address (355ms)
MCopy contract
Deploy contract MCopy ...
Deploy contract MCopy OK, times=1, address: 0x77Fd93A888c8aF77f0c2A3B65244ee4100d873bd
Test copyWord
✔ Should copy a word correctly (292ms)
✔ Should copy zero word correctly (349ms)
✔ Should copy max word correctly (357ms)
Test copyByteArray
✔ Should copy a byte array correctly (368ms)
✔ Should copy empty array correctly (360ms)
✔ Should copy long byte array correctly (364ms)
Test copyMultipleWord
✔ Should copy multiple words correctly (385ms)
✔ Should copy zero words correctly (445ms)
✔ Should copy multiple zero words correctly (384ms)
Test copyWithOffset
✔ Should copy with offset correctly (488ms)
✔ Should copy from start correctly (360ms)
✔ Should copy to end correctly (486ms)
✔ Should revert when offset + length exceeds source length (387ms)
TransientStorage contract
Deploy contract TransientStorage ...
Deploy contract TransientStorage OK, times=1, address: 0x8D3eA52bB46921Caee7B003ec548dD95Bcbd90ff
Test readAndWrite
✔ should write and read value from transient storage (418ms)
Test swapSlots
✔ should swap values between slots (363ms)
Test addSlots
✔ should add values and store the result (357ms)
57 passing (3m)
Discussion (1)