0

I have read about smart contracts and I am left with some doubts. Every invocation of a function in smart contract is a transaction which costs some ether.A miner chooses a smart contract on blockchain to complete the transaction.My doubts are :

1) If we have many smart contracts written by many developers to serve same purpose in the blockchain, who will decide that a particular smart contract is best one out of all ? How can miners choose that this smart contract has best logic and rules to be verified against or users tell to use a specific smart contract ? Ex : If I wanted to verify my certificate using a smart contract, and there are many smart contracts to serve this purpose, which and how does miners choose only one of them to verify ?

2) Suppose, I have mapping data structure in solidity smart contract A and I stored some data say mapping(uint => string) vals and it is stored with 5 values till vals[4] . Now in another transaction , I wanted to access vals[3] or store a new value at another index from the same smart contract by creating a new transaction , is it feasible ?If so, how will miners choose same smart contract everytime ?

3) Can I create a private smart contract in ethereum ? Suppose a Govt institution wants to store its certificates in blockchain using some mapping data structure say mapping(stu_ID => Certificate_ID) and others can only read it or use the same mapping data structute to verify their certificate if it's fake or genuine ?Is it possible ?

4) Can I edit a smart contract in blockchain ? Suppose I wanted to change some rules or logic of my own smart contract , can I do it ?

forgive me if queries are noobish.

Thank you.

2

1) Miners only choose which transactions they include in a block. They basically choose the transactions which have the highest gas price because that way they get the best rewards. They don't analyze the transaction contents in any way as that doesn't matter much for them.

Nobody decides whether a smart contract is good or not. Smart contracts are identified by their contract address and each address is unique. When a user wants to interact with some smart contract they have to know its address and then they issue transactions to that address. There may be multiple smart contracts with exactly the same contents but they all have a unique address.

2) One of the main points of smart contracts is that many users can access them. So, yes, different users can change and read the state of a smart contract. The contract they use is identified by its address.

3) No you can't have private smart contracts. All information on the blockchain is public. But you can have a private blockchain where you control access and you can decide who can read & write to it. This is quite common in financial systems where privacy is a required feature.

5) No you can't edit a smart contract. All information input into the blockchain is final and immutable - once it's there nobody can edit or remove it. So you'd better not code bugs in your contracts :)

  • for 2nd answer, user has to mention the smart contract's address so that miners choose that to be executed as a transaction. – manivarma indukuri Nov 30 '19 at 13:49
  • for 3rd answer, can't we write a smart contract which allows some users to store data in smart contract and allows other users to only read data from it – manivarma indukuri Nov 30 '19 at 13:52
  • 2) The user creates the transaction which states what address the transaction targets, miners just include the tx in a block. 3) No, you can't have private data in the public Ethereum blockchain, so everyone has always access to the same data. You can of course encrypt the data but that has to be done off-chain as everyone would see the encryption key if it was done in the smart contract. – Lauri Peltonen Nov 30 '19 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.