false
false

Contract Address Details

0x4F5B78F2F587763666F94ba3789BFE9d9d34A4B8

Contract Name
cityAudit
Creator
0x864f78–c6436b at 0x6d0295–cd659f
Balance
0
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
15520750
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
cityAudit




Optimization enabled
true
Compiler version
v0.8.0+commit.c7dfd78e




Optimization runs
200
EVM Version
default




Verified at
2024-09-12T07:18:49.411794Z

Contract source code

Sol2uml
new
pragma solidity ^0.8.0;

contract cityAudit {
    struct Project {
        string name;
        uint256 budget;
        uint256 spent;
        bool active;
    }

    address public cityPlanner;
    mapping(uint256 => Project) public projects;
    uint256 public projectCount;

    event ProjectCreated(uint256 indexed projectId, string name, uint256 budget);
    event FundsAllocated(uint256 indexed projectId, uint256 amount);
    event ExpenseRecorded(uint256 indexed projectId, uint256 amount);

    modifier onlyCityPlanner() {
        require(msg.sender == cityPlanner, "Only city planner can call this function");
        _;
    }

    constructor() {
        cityPlanner = msg.sender;
    }

    function createProject(string memory _name, uint256 _budget) public onlyCityPlanner {
        projectCount++;
        projects[projectCount] = Project(_name, _budget, 0, true);
        emit ProjectCreated(projectCount, _name, _budget);
    }

    function allocateFunds(uint256 _projectId, uint256 _amount) public onlyCityPlanner {
        require(projects[_projectId].active, "Project is not active");
        projects[_projectId].budget += _amount;
        emit FundsAllocated(_projectId, _amount);
    }

    function recordExpense(uint256 _projectId, uint256 _amount) public onlyCityPlanner {
        require(projects[_projectId].active, "Project is not active");
        require(projects[_projectId].budget >= projects[_projectId].spent + _amount, "Insufficient budget");
        projects[_projectId].spent += _amount;
        emit ExpenseRecorded(_projectId, _amount);
    }

    function getProjectDetails(uint256 _projectId) public view returns (string memory, uint256, uint256, bool) {
        Project memory project = projects[_projectId];
        return (project.name, project.budget, project.spent, project.active);
    }

    function closeProject(uint256 _projectId) public onlyCityPlanner {
        require(projects[_projectId].active, "Project is already inactive");
        projects[_projectId].active = false;
    }
}
        

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"ExpenseRecorded","inputs":[{"type":"uint256","name":"projectId","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"FundsAllocated","inputs":[{"type":"uint256","name":"projectId","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ProjectCreated","inputs":[{"type":"uint256","name":"projectId","internalType":"uint256","indexed":true},{"type":"string","name":"name","internalType":"string","indexed":false},{"type":"uint256","name":"budget","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"allocateFunds","inputs":[{"type":"uint256","name":"_projectId","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"cityPlanner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"closeProject","inputs":[{"type":"uint256","name":"_projectId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createProject","inputs":[{"type":"string","name":"_name","internalType":"string"},{"type":"uint256","name":"_budget","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bool","name":"","internalType":"bool"}],"name":"getProjectDetails","inputs":[{"type":"uint256","name":"_projectId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"projectCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"name","internalType":"string"},{"type":"uint256","name":"budget","internalType":"uint256"},{"type":"uint256","name":"spent","internalType":"uint256"},{"type":"bool","name":"active","internalType":"bool"}],"name":"projects","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"recordExpense","inputs":[{"type":"uint256","name":"_projectId","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"}]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50600080546001600160a01b03191633179055610a21806100326000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c80638c03ed461161005b5780638c03ed46146100f657806391754a5d1461010957806393dc12e61461011c578063c94dd46d1461012f57610088565b8063107046bd1461008d578063328fb510146100b957806336fbad26146100ce5780635f8439e3146100e3575b600080fd5b6100a061009b366004610782565b610144565b6040516100b0949392919061083c565b60405180910390f35b6100cc6100c736600461079a565b6101f9565b005b6100d66102c1565b6040516100b09190610948565b6100a06100f1366004610782565b6102c7565b6100cc61010436600461079a565b6103cb565b6100cc6101173660046106db565b6104cc565b6100cc61012a366004610782565b6105bd565b610137610633565b6040516100b09190610806565b60016020526000908152604090208054819061015f90610969565b80601f016020809104026020016040519081016040528092919081815260200182805461018b90610969565b80156101d85780601f106101ad576101008083540402835291602001916101d8565b820191906000526020600020905b8154815290600101906020018083116101bb57829003601f168201915b50505050600183015460028401546003909401549293909290915060ff1684565b6000546001600160a01b0316331461022c5760405162461bcd60e51b81526004016102239061086d565b60405180910390fd5b60008281526001602052604090206003015460ff1661025d5760405162461bcd60e51b815260040161022390610919565b6000828152600160208190526040822001805483929061027e908490610951565b92505081905550817fa76702541970ac8a240a5f42c5a0d1558c299844949ec41fad31fac5444e5504826040516102b59190610948565b60405180910390a25050565b60025481565b6060600080600080600160008781526020019081526020016000206040518060800160405290816000820180546102fd90610969565b80601f016020809104026020016040519081016040528092919081815260200182805461032990610969565b80156103765780601f1061034b57610100808354040283529160200191610376565b820191906000526020600020905b81548152906001019060200180831161035957829003601f168201915b50505091835250506001820154602080830191909152600283015460408084019190915260039093015460ff161515606092830152835190840151928401519390910151909991985091965090945092505050565b6000546001600160a01b031633146103f55760405162461bcd60e51b81526004016102239061086d565b60008281526001602052604090206003015460ff166104265760405162461bcd60e51b815260040161022390610919565b600082815260016020526040902060020154610443908290610951565b6000838152600160208190526040909120015410156104745760405162461bcd60e51b8152600401610223906108ec565b60008281526001602052604081206002018054839290610495908490610951565b92505081905550817fa839f0e08e3c9f4c239834a1a86926f37447333fb5be70c81b192e16996f35e9826040516102b59190610948565b6000546001600160a01b031633146104f65760405162461bcd60e51b81526004016102239061086d565b60028054906000610506836109a4565b90915550506040805160808101825283815260208082018490526000828401819052600160608401819052600254825282529290922081518051929391926105519284920190610642565b50602082015181600101556040820151816002015560608201518160030160006101000a81548160ff0219169083151502179055509050506002547f6245d01eb0db8df9242165c3ee1e2324367f93303d7b8f6a86e38a8767e643ae83836040516102b592919061081a565b6000546001600160a01b031633146105e75760405162461bcd60e51b81526004016102239061086d565b60008181526001602052604090206003015460ff166106185760405162461bcd60e51b8152600401610223906108b5565b6000908152600160205260409020600301805460ff19169055565b6000546001600160a01b031681565b82805461064e90610969565b90600052602060002090601f01602090048101928261067057600085556106b6565b82601f1061068957805160ff19168380011785556106b6565b828001600101855582156106b6579182015b828111156106b657825182559160200191906001019061069b565b506106c29291506106c6565b5090565b5b808211156106c257600081556001016106c7565b600080604083850312156106ed578182fd5b823567ffffffffffffffff80821115610704578384fd5b818501915085601f830112610717578384fd5b813560208282111561072b5761072b6109d5565b604051601f8301601f191681018201848111828210171561074e5761074e6109d5565b6040528281528483018201891015610764578687fd5b82828601838301379182018101959095529694909301359450505050565b600060208284031215610793578081fd5b5035919050565b600080604083850312156107ac578182fd5b50508035926020909101359150565b60008151808452815b818110156107e0576020818501810151868301820152016107c4565b818111156107f15782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b60006040825261082d60408301856107bb565b90508260208301529392505050565b60006080825261084f60808301876107bb565b60208301959095525060408101929092521515606090910152919050565b60208082526028908201527f4f6e6c79206369747920706c616e6e65722063616e2063616c6c207468697320604082015267333ab731ba34b7b760c11b606082015260800190565b6020808252601b908201527f50726f6a65637420697320616c726561647920696e6163746976650000000000604082015260600190565b602080825260139082015272125b9cdd59999a58da595b9d08189d5919d95d606a1b604082015260600190565b60208082526015908201527450726f6a656374206973206e6f742061637469766560581b604082015260600190565b90815260200190565b60008219821115610964576109646109bf565b500190565b60028104600182168061097d57607f821691505b6020821081141561099e57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156109b8576109b86109bf565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220192102f9a1cebe43075c5307174110a37e830012d63734a67e22f6425d31b29964736f6c63430008000033

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100885760003560e01c80638c03ed461161005b5780638c03ed46146100f657806391754a5d1461010957806393dc12e61461011c578063c94dd46d1461012f57610088565b8063107046bd1461008d578063328fb510146100b957806336fbad26146100ce5780635f8439e3146100e3575b600080fd5b6100a061009b366004610782565b610144565b6040516100b0949392919061083c565b60405180910390f35b6100cc6100c736600461079a565b6101f9565b005b6100d66102c1565b6040516100b09190610948565b6100a06100f1366004610782565b6102c7565b6100cc61010436600461079a565b6103cb565b6100cc6101173660046106db565b6104cc565b6100cc61012a366004610782565b6105bd565b610137610633565b6040516100b09190610806565b60016020526000908152604090208054819061015f90610969565b80601f016020809104026020016040519081016040528092919081815260200182805461018b90610969565b80156101d85780601f106101ad576101008083540402835291602001916101d8565b820191906000526020600020905b8154815290600101906020018083116101bb57829003601f168201915b50505050600183015460028401546003909401549293909290915060ff1684565b6000546001600160a01b0316331461022c5760405162461bcd60e51b81526004016102239061086d565b60405180910390fd5b60008281526001602052604090206003015460ff1661025d5760405162461bcd60e51b815260040161022390610919565b6000828152600160208190526040822001805483929061027e908490610951565b92505081905550817fa76702541970ac8a240a5f42c5a0d1558c299844949ec41fad31fac5444e5504826040516102b59190610948565b60405180910390a25050565b60025481565b6060600080600080600160008781526020019081526020016000206040518060800160405290816000820180546102fd90610969565b80601f016020809104026020016040519081016040528092919081815260200182805461032990610969565b80156103765780601f1061034b57610100808354040283529160200191610376565b820191906000526020600020905b81548152906001019060200180831161035957829003601f168201915b50505091835250506001820154602080830191909152600283015460408084019190915260039093015460ff161515606092830152835190840151928401519390910151909991985091965090945092505050565b6000546001600160a01b031633146103f55760405162461bcd60e51b81526004016102239061086d565b60008281526001602052604090206003015460ff166104265760405162461bcd60e51b815260040161022390610919565b600082815260016020526040902060020154610443908290610951565b6000838152600160208190526040909120015410156104745760405162461bcd60e51b8152600401610223906108ec565b60008281526001602052604081206002018054839290610495908490610951565b92505081905550817fa839f0e08e3c9f4c239834a1a86926f37447333fb5be70c81b192e16996f35e9826040516102b59190610948565b6000546001600160a01b031633146104f65760405162461bcd60e51b81526004016102239061086d565b60028054906000610506836109a4565b90915550506040805160808101825283815260208082018490526000828401819052600160608401819052600254825282529290922081518051929391926105519284920190610642565b50602082015181600101556040820151816002015560608201518160030160006101000a81548160ff0219169083151502179055509050506002547f6245d01eb0db8df9242165c3ee1e2324367f93303d7b8f6a86e38a8767e643ae83836040516102b592919061081a565b6000546001600160a01b031633146105e75760405162461bcd60e51b81526004016102239061086d565b60008181526001602052604090206003015460ff166106185760405162461bcd60e51b8152600401610223906108b5565b6000908152600160205260409020600301805460ff19169055565b6000546001600160a01b031681565b82805461064e90610969565b90600052602060002090601f01602090048101928261067057600085556106b6565b82601f1061068957805160ff19168380011785556106b6565b828001600101855582156106b6579182015b828111156106b657825182559160200191906001019061069b565b506106c29291506106c6565b5090565b5b808211156106c257600081556001016106c7565b600080604083850312156106ed578182fd5b823567ffffffffffffffff80821115610704578384fd5b818501915085601f830112610717578384fd5b813560208282111561072b5761072b6109d5565b604051601f8301601f191681018201848111828210171561074e5761074e6109d5565b6040528281528483018201891015610764578687fd5b82828601838301379182018101959095529694909301359450505050565b600060208284031215610793578081fd5b5035919050565b600080604083850312156107ac578182fd5b50508035926020909101359150565b60008151808452815b818110156107e0576020818501810151868301820152016107c4565b818111156107f15782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b60006040825261082d60408301856107bb565b90508260208301529392505050565b60006080825261084f60808301876107bb565b60208301959095525060408101929092521515606090910152919050565b60208082526028908201527f4f6e6c79206369747920706c616e6e65722063616e2063616c6c207468697320604082015267333ab731ba34b7b760c11b606082015260800190565b6020808252601b908201527f50726f6a65637420697320616c726561647920696e6163746976650000000000604082015260600190565b602080825260139082015272125b9cdd59999a58da595b9d08189d5919d95d606a1b604082015260600190565b60208082526015908201527450726f6a656374206973206e6f742061637469766560581b604082015260600190565b90815260200190565b60008219821115610964576109646109bf565b500190565b60028104600182168061097d57607f821691505b6020821081141561099e57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156109b8576109b86109bf565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220192102f9a1cebe43075c5307174110a37e830012d63734a67e22f6425d31b29964736f6c63430008000033