Deploy, test, and verify Solidity contracts on TAC using Hardhat - the complete development environment
TAC EVM Layer provides full compatibility with Hardhat, Ethereum’s most popular development framework. Deploy your existing Solidity contracts without modification, test, and verify contracts on the block explorer.
For contracts that need to receive messages from TON, inherit from the TAC proxy base:
Copy
Ask AI
// contracts/TacEnabledContract.solpragma solidity ^0.8.19;import "@tac/proxy-contracts/TacProxyV1.sol";contract TacEnabledContract is TacProxyV1 { uint256 public counter; mapping(address => uint256) public userCounters; event CounterIncremented(address indexed user, uint256 newValue); constructor(address _crossChainLayer) TacProxyV1(_crossChainLayer) { counter = 0; } // Function callable from EVM function incrementCounter() external { counter++; userCounters[msg.sender]++; emit CounterIncremented(msg.sender, counter); } // Function callable from TON via cross-chain message function incrementFromTON(bytes calldata tacHeader, bytes calldata args) external _onlyCrossChainLayer { // Decode TAC header to get TON user info TacHeaderV1 memory header = _decodeTacHeader(tacHeader); // Increment counter for cross-chain user counter++; userCounters[header.sender]++; emit CounterIncremented(header.sender, counter); // Optionally send result back to TON OutMessageV1 memory response = OutMessageV1({ target: header.sender, methodName: "counterUpdated", arguments: abi.encode(counter) }); _sendMessageV1(response); }}
# Deploy to TAC Saint Petersburg testnetnpx hardhat run scripts/deploy.js --network tac_testnet
Expected output:
Copy
Ask AI
Deploying contracts with account: 0x742d35Cc6473...Account balance: 1000000000000000000SimpleStorage deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Copy
Ask AI
# Deploy to TAC Saint Petersburg testnetnpx hardhat run scripts/deploy.js --network tac_testnet
Expected output:
Copy
Ask AI
Deploying contracts with account: 0x742d35Cc6473...Account balance: 1000000000000000000SimpleStorage deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Copy
Ask AI
# Deploy to TAC mainnet (production)npx hardhat run scripts/deploy.js --network tac_mainnet
Ensure you have sufficient TAC tokens for gas fees before deploying to mainnet.