Getting Started
This chapter provides a complete implementation guide, from project setup to WIA certification. Follow these steps to build your first WIA-FIN-007 compliant smart contract.
Step 1: Project Setup
# Install dependencies
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npm install @openzeppelin/contracts @wia/contracts ethers
# Initialize Hardhat project
npx hardhat init
# Install WIA tooling
npm install -g @wia/cli
wia init
# Configure WIA
wia config set standard FIN-007
wia config set version 1.0.0
Step 2: Contract Development
// contracts/WIASecureToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@wia/contracts/WIAMetadata.sol";
/// @title WIA Secure Token
/// @author Your Organization
/// @notice WIA-FIN-007 compliant ERC-20 token
/// @custom:security-contact security@example.com
contract WIASecureToken is
ERC20Upgradeable,
Ownable2StepUpgradeable,
PausableUpgradeable,
ReentrancyGuardUpgradeable,
WIAMetadata
{
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function initialize(
string memory name,
string memory symbol,
uint256 initialSupply
) public initializer {
__ERC20_init(name, symbol);
__Ownable_init(msg.sender);
__Pausable_init();
__ReentrancyGuard_init();
_mint(msg.sender, initialSupply);
// Set WIA metadata
_setWIAMetadata(WIAContractMetadata({
wiaVersion: "1.0.0",
contractType: "ERC20",
securityLevel: "high",
audited: false
}));
}
function transfer(address to, uint256 amount)
public
override
whenNotPaused
nonReentrant
returns (bool)
{
return super.transfer(to, amount);
}
function transferFrom(address from, address to, uint256 amount)
public
override
whenNotPaused
nonReentrant
returns (bool)
{
return super.transferFrom(from, to, amount);
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
}
Step 3: Testing
// test/WIASecureToken.test.js
const { expect } = require("chai");
const { ethers } = require("hardhat");
const { loadFixture } = require("@nomicfoundation/hardhat-network-helpers");
describe("WIASecureToken", function () {
async function deployTokenFixture() {
const [owner, addr1, addr2] = await ethers.getSigners();
const Token = await ethers.getContractFactory("WIASecureToken");
const token = await Token.deploy();
await token.deployed();
await token.initialize(
"WIA Token",
"WIA",
ethers.utils.parseEther("1000000")
);
return { token, owner, addr1, addr2 };
}
describe("Deployment", function () {
it("Should set the right owner", async function () {
const { token, owner } = await loadFixture(deployTokenFixture);
expect(await token.owner()).to.equal(owner.address);
});
it("Should assign total supply to owner", async function () {
const { token, owner } = await loadFixture(deployTokenFixture);
const ownerBalance = await token.balanceOf(owner.address);
expect(await token.totalSupply()).to.equal(ownerBalance);
});
});
describe("Transfers", function () {
it("Should transfer tokens between accounts", async function () {
const { token, owner, addr1, addr2 } = await loadFixture(deployTokenFixture);
await expect(
token.transfer(addr1.address, 100)
).to.changeTokenBalances(token, [owner, addr1], [-100, 100]);
await expect(
token.connect(addr1).transfer(addr2.address, 50)
).to.changeTokenBalances(token, [addr1, addr2], [-50, 50]);
});
it("Should fail if sender doesn't have enough tokens", async function () {
const { token, owner, addr1 } = await loadFixture(deployTokenFixture);
const initialOwnerBalance = await token.balanceOf(owner.address);
await expect(
token.connect(addr1).transfer(owner.address, 1)
).to.be.revertedWith("ERC20: transfer amount exceeds balance");
expect(await token.balanceOf(owner.address)).to.equal(initialOwnerBalance);
});
it("Should not allow transfers when paused", async function () {
const { token, owner, addr1 } = await loadFixture(deployTokenFixture);
await token.pause();
await expect(
token.transfer(addr1.address, 100)
).to.be.revertedWith("Pausable: paused");
});
});
describe("Security", function () {
it("Should have reentrancy protection", async function () {
// Test reentrancy guard
});
it("Should pass WIA validation", async function () {
const { token } = await loadFixture(deployTokenFixture);
const metadata = await token.getWIAMetadata();
expect(metadata.wiaVersion).to.equal("1.0.0");
});
});
});
Step 4: Security Analysis
# Run static analysis
wia analyze contracts/
# Run Slither
slither contracts/WIASecureToken.sol
# Run Mythril
myth analyze contracts/WIASecureToken.sol
# Generate security report
wia security-report --output security.md
Deployment Guide
Local Deployment
// scripts/deploy.js
const { ethers, upgrades } = require("hardhat");
async function main() {
const WIASecureToken = await ethers.getContractFactory("WIASecureToken");
console.log("Deploying WIA Secure Token...");
const token = await upgrades.deployProxy(
WIASecureToken,
[
"WIA Token",
"WIA",
ethers.utils.parseEther("1000000")
],
{ initializer: 'initialize', kind: 'transparent' }
);
await token.deployed();
console.log("Token deployed to:", token.address);
console.log("Implementation:", await upgrades.erc1967.getImplementationAddress(token.address));
console.log("Admin:", await upgrades.erc1967.getAdminAddress(token.address));
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Multi-Chain Deployment
# Deploy to multiple chains
wia deploy --chains ethereum,polygon,arbitrum --verify
# Check deployment status
wia deployment status
# Verify all contracts
wia verify --all
WIA Certification Process
Certification Levels
WIA-FIN-007 offers three certification levels:
- Basic Certification: Phase 1 compliance, basic security checks
- Standard Certification: Phases 1-3 compliance, full security audit
- Premium Certification: All 4 phases, continuous monitoring, enterprise support
Step 1: Self-Assessment
# Run WIA compliance checker
wia check --level standard
# Output:
# β Phase 1: Data Format (100%)
# β Metadata schema valid
# β ABI extensions present
# β Storage layout optimized
#
# β Phase 2: API Interface (100%)
# β Standard methods implemented
# β Event naming compliant
# β Error handling proper
#
# β Phase 3: Protocol (95%)
# β Deployment protocol followed
# β Upgrade mechanism implemented
# β Multi-sig governance recommended
#
# β Phase 4: Integration (90%)
# β Wallet compatibility
# β Oracle integration
# β Cross-chain bridge optional
#
# Overall Score: 96/100
# Certification Level: Standard (Eligible)
Step 2: Submit for Audit
# Submit for WIA audit
wia submit-audit \
--contract contracts/WIASecureToken.sol \
--level standard \
--contact security@example.com
# Upload documentation
wia upload-docs \
--whitepaper docs/whitepaper.pdf \
--architecture docs/architecture.md \
--security docs/security-analysis.md
Step 3: Audit Process
The WIA audit team will:
- Review code for compliance with WIA-FIN-007 standards
- Perform security analysis using automated and manual testing
- Verify gas optimization and storage patterns
- Test multi-chain compatibility
- Validate integration capabilities
- Provide detailed audit report with recommendations
Step 4: Remediation
# Review audit findings
wia audit-report --id AUD-12345
# Address issues
# ... make necessary fixes ...
# Re-submit for verification
wia resubmit-audit --id AUD-12345 --changes "Fixed reentrancy in transfer"
Step 5: Certification
# Receive certification
wia get-certificate --id AUD-12345 --output certificate.json
# Certificate contains:
{
"certificateId": "WIA-FIN-007-CERT-2025-001",
"contractAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"certificationLevel": "Standard",
"issueDate": "2025-01-20",
"expiryDate": "2026-01-20",
"auditScore": 96,
"auditor": "WIA Security Team",
"signature": "0x...",
"badge": "https://wia.org/badges/FIN-007-standard.svg"
}
Best Practices
WIA Development Best Practices
1. Security First
- Always use latest Solidity version (0.8.20+)
- Implement checks-effects-interactions pattern
- Use OpenZeppelin's audited contracts
- Add reentrancy guards to state-changing functions
- Validate all inputs and check for zero addresses
2. Gas Optimization
- Pack storage variables efficiently
- Cache storage reads in memory
- Use custom errors instead of revert strings
- Prefer calldata over memory for read-only arrays
- Use unchecked blocks for safe arithmetic
3. Testing Coverage
- Aim for 100% code coverage
- Test all edge cases and boundary conditions
- Include fuzzing tests for critical functions
- Test upgrade scenarios thoroughly
- Verify gas costs don't exceed limits
4. Documentation
- Use NatSpec for all public/external functions
- Document security assumptions
- Provide integration examples
- Keep README updated with deployment addresses
- Maintain changelog of all versions
Real-World Example
Complete Implementation
// Full WIA-FIN-007 compliant token with all features
// contracts/WIAFullFeatureToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
contract WIAFullFeatureToken is
Initializable,
ERC20Upgradeable,
ERC20BurnableUpgradeable,
ERC20PausableUpgradeable,
AccessControlUpgradeable,
ReentrancyGuardUpgradeable,
UUPSUpgradeable
{
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function initialize(
string memory name,
string memory symbol,
uint256 initialSupply
) public initializer {
__ERC20_init(name, symbol);
__ERC20Burnable_init();
__ERC20Pausable_init();
__AccessControl_init();
__ReentrancyGuard_init();
__UUPSUpgradeable_init();
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(PAUSER_ROLE, msg.sender);
_grantRole(MINTER_ROLE, msg.sender);
_grantRole(UPGRADER_ROLE, msg.sender);
_mint(msg.sender, initialSupply);
}
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}
function unpause() public onlyRole(PAUSER_ROLE) {
_unpause();
}
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
_mint(to, amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal override(ERC20Upgradeable, ERC20PausableUpgradeable) whenNotPaused {
super._beforeTokenTransfer(from, to, amount);
}
function _authorizeUpgrade(address newImplementation)
internal
override
onlyRole(UPGRADER_ROLE)
{}
}
Maintenance and Updates
Continuous Monitoring
# Setup monitoring
wia monitor start --contract 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb
# Check health status
wia monitor status
# Get alerts
wia monitor alerts --last 7d
Upgrading Contracts
# Prepare upgrade
wia upgrade prepare --contract 0x... --new-version v1.1.0
# Test upgrade on testnet
wia upgrade test --network goerli
# Execute upgrade with timelock
wia upgrade execute --timelock 48h
Community and Support
Join the WIA community to get help and stay updated:
- Documentation: https://docs.wia.org/fin-007
- GitHub: https://github.com/WIA-Official/wia-standards
- Discord: https://discord.gg/wia
- Forum: https://forum.wia.org
- Security Contact: security@wia.org
Conclusion
Congratulations on completing this comprehensive guide to WIA-FIN-007! You now have the knowledge and tools to build secure, efficient, and interoperable smart contracts that meet the highest industry standards.
Remember, the journey doesn't end here. Smart contract development is constantly evolving, and the WIA standard will continue to adapt to new challenges and opportunities. Stay engaged with the community, contribute your learnings, and help make blockchain technology more secure and accessible for everyone.
εΌηδΊΊι - Benefit All Humanity
By adopting WIA-FIN-007, you're not just writing better code - you're contributing to a more secure, accessible, and beneficial blockchain ecosystem for all. Thank you for being part of this mission.