Fund:0.024 ETH / $13.88
Question is solved
How are traceability and scalability achieved in Ethereum Smart Contracts?
1 month ago
1. Traceability: Whenever the state of your contract is changed, that state change is permanently stored on the blockchain. You can use etherscan.io to view block info and examine each individual transactions. However if you want to programmatically access this info, there are two ways. One is to use Events as a way to get the history of things that happened in your contract. You can use web3's event api to set filters on the type of events you want to listen to. Another way is to send queries about the blockchain at a specific block. For example, web3.eth.getStorageAt() method takes a block number as parameter and you can query the specific state at that block. Basically, in short, yes that state of your smart contract is stored on the blockchain and there are ways to extract that history out by manually examining it or by using code. 2. Scalability: Yes the mapping is scalable, the mapping uses a hash function to calculate an index based on the key and store the data at that index. This an O(1) operation which means it takes constant time and doesn't matter on size of mapping. Whenever you want to add new element to the mapping, the caller of the contract AddCar() has to pay the gas to add a new entry. The caller can be the contract owner or could be done by anyone depending on if you make that function public. Whoever calls the add function has to pay the gas. The gas price per each new entry should be more or less the same depending on the demand of the network. In other words, the price per new entry into the mapping is not related to the size of the map. Basically, the price is more or less the same when your adding the first entry or the 1 millionth entry if the network demand is more or less the same.
1 month ago