// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TransactionCounter {
// Variable pour compter le nombre de transactions
uint public transactionCount;
// Événement pour journaliser chaque incrément
event TransactionIncremented(uint newCount);
// Constructeur pour initialiser le compteur
constructor() {
transactionCount = 0;
}
// Fonction pour incrémenter le compteur
function incrementCounter() public {
transactionCount += 1;
emit TransactionIncremented(transactionCount);
}
// Fonction pour récupérer la valeur actuelle du compteur
function getTransactionCount() public view returns (uint) {
return transactionCount;
}
}
{
"compilationTarget": {
"TransactionCounter.sol": "TransactionCounter"
},
"evmVersion": "cancun",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newCount","type":"uint256"}],"name":"TransactionIncremented","type":"event"},{"inputs":[],"name":"getTransactionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incrementCounter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"transactionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]