Adds formal verification DSL, multi-sig contract, and Hardhat plugin: synor-verifier crate: - Verification DSL for contract invariants and properties - SMT solver integration (Z3 backend optional) - Symbolic execution engine for path exploration - Automatic vulnerability detection (reentrancy, overflow, etc.) - 29 tests passing contracts/multi-sig: - M-of-N multi-signature wallet contract - Transaction proposals with timelock - Owner management (add/remove) - Emergency pause functionality - Native token and contract call support apps/hardhat-plugin (@synor/hardhat-plugin): - Network configuration for mainnet/testnet/devnet - Contract deployment with gas estimation - Contract verification on explorer - WASM compilation support - TypeScript type generation - Testing utilities (fork, impersonate, time manipulation) - Synor-specific RPC methods (quantum status, shard info, DAG) |
||
|---|---|---|
| .. | ||
| src | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
@synor/hardhat-plugin
Hardhat plugin for Synor blockchain development. Provides seamless integration between Hardhat and Synor network.
Features
- 🔗 Network Configuration: Pre-configured Synor mainnet, testnet, and devnet
- 📦 Smart Deployment: Deploy contracts with gas estimation and verification
- 🔐 Quantum-Safe: Support for post-quantum cryptographic signatures
- 🧪 Testing Utilities: Fork network, time manipulation, account impersonation
- 📊 DAG Integration: Access GHOSTDAG/DAGKnight consensus data
- 🌐 Cross-Shard: Support for sharded architecture
Installation
npm install @synor/hardhat-plugin
# or
yarn add @synor/hardhat-plugin
# or
pnpm add @synor/hardhat-plugin
Setup
Add the plugin to your hardhat.config.ts:
import "@synor/hardhat-plugin";
const config: HardhatUserConfig = {
solidity: "0.8.20",
synor: {
defaultNetwork: "testnet",
verifyContracts: true,
quantumSafe: true,
},
networks: {
"synor-mainnet": {
url: "https://rpc.synor.cc",
chainId: 1337,
accounts: [process.env.PRIVATE_KEY!],
},
"synor-testnet": {
url: "https://testnet-rpc.synor.cc",
chainId: 1338,
accounts: [process.env.PRIVATE_KEY!],
},
},
};
export default config;
Usage
Deploy a Contract
npx hardhat synor:deploy --contract MyContract --network synor-testnet
Or programmatically:
import { ethers } from "hardhat";
async function main() {
const contract = await hre.synor.deployer.deploy("MyContract", [arg1, arg2]);
console.log("Deployed to:", contract.address);
}
Verify a Contract
npx hardhat synor:verify --address 0x... --contract MyContract --network synor-testnet
Get Network Info
npx hardhat synor:info --network synor-testnet
Request Testnet Tokens
npx hardhat synor:faucet --address 0x... --network synor-testnet
Compile to WASM
npx hardhat synor:compile
API Reference
hre.synor.provider
Synor-specific JSON-RPC provider with methods:
getBalance(address)- Get account balancegetBlockNumber()- Get current block numbergetTransaction(hash)- Get transaction by hashsendTransaction(tx)- Send a transactioncall(tx)- Call a contract (read-only)estimateGas(tx)- Estimate gas for transactiongetQuantumStatus()- Get quantum signature statusgetShardInfo()- Get shard informationgetDagBlock(hash)- Get DAG block information
hre.synor.deployer
Contract deployment utilities:
deploy(name, args, options)- Deploy a contractdeployDeterministic(name, args, salt)- CREATE2 deploymentcompileToWasm()- Compile contracts to WASMgenerateTypes()- Generate TypeScript types
hre.synor.network
Network utilities:
getNetworkInfo()- Get network informationverifyContract(address, args)- Verify on explorerrequestFaucet(address, amount)- Request testnet tokensfork(blockNumber)- Fork network at blockimpersonate(address)- Impersonate accountsetBalance(address, balance)- Set account balanceincreaseTime(seconds)- Advance blockchain timesnapshot()- Take state snapshotrevert(snapshotId)- Revert to snapshot
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
defaultNetwork |
string |
"devnet" |
Default Synor network |
gasPrice |
"auto" | number |
"auto" |
Gas price setting |
gasLimit |
number |
3000000 |
Default gas limit |
confirmations |
number |
1 |
Confirmations to wait |
timeout |
number |
60000 |
Transaction timeout (ms) |
verifyContracts |
boolean |
true |
Auto-verify on deploy |
quantumSafe |
boolean |
true |
Use quantum signatures |
Testing
The plugin provides testing utilities for Synor-specific features:
import { expect } from "chai";
import { ethers } from "hardhat";
describe("MyContract", function () {
beforeEach(async function () {
// Fork testnet
await hre.synor.network.fork("latest");
});
it("should deploy and interact", async function () {
const contract = await hre.synor.deployer.deploy("MyContract", []);
// Test cross-shard messaging
const messages = await hre.synor.provider.getPendingCrossShardMessages(
contract.address
);
expect(messages).to.be.empty;
});
it("should handle time-based logic", async function () {
const contract = await hre.synor.deployer.deploy("TimeLock", []);
// Advance time by 1 day
await hre.synor.network.increaseTime(86400);
// Now timelock should be expired
expect(await contract.isExpired()).to.be.true;
});
});
License
MIT