0

I am trying to understand how a smart contracts works and what are the steps from requesting to receiving some amount of coin (let's say ethereum). I have some questions..

  • When a smart contract is created this is added in a block and send in the network to be checked (what should users check here, because smart contract is not a transaction?)

  • When a user makes a request to a method exported by the smart contract it creates a transaction and it will be sent to the network for validation, right (so what is the smart contract job if the transaction will be validated in network?).

  • Smart contract beeing in the blockchain this means every user from network has it. Smart contract is run by every user when a request to a method is done?

  • We can think of a smart contract like a normal user which has a balance? A user can access every contract from blockchain?

I am referring to ethereum. Thanks.

1

When a smart contract is created this is added in a block and send in the network to be checked (what should users check here, because smart contract is not a transaction?)

Smart contract creation is a transaction which includes contract bytecode and new address for a contract (keccak256(rlp.encode([normalize_address(sender), nonce]))[12:]).

When a user make a request to a method exported by the smart contract it creates a transaction and it will be sent in the network for validation, right (so what is the smart contract job if the transaction will be validated in network?).

Smart contract is just a piece of code somewhere in the blockchain. When node has a request to call some contract method it just takes code of corresponding address and executes the call. It will apply changes to the blockchain if it will be successfull and will return error message corresponding to the type of opcode raised.

Smart contract beeing in the blockchain this means every user from network has > it. Smart contract is run by every user when a request to a method is done?

Theoretically yes, but literally it's just computed in one node and the result then is distributed to (i.e. state is updated) on other nodes.

We can think of a smart contract like a normal user which has a balance? A user can access every contract from blockchain?

Smart contract is kind of normal address, but still not. It can't receive funds by default if it doesn't have fallback payable function. But it still has the same functionality like address.balance and it can be a msg.sender if the call is initiated inside contract to another method.

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.