function redeem(uint256 _token) public {
    // transfering the token from tokenholder to owner
    token tokenBalance = token(tokenAddress);
    tokenBalance.transferToOwner(owner, _token);

    // the tokenholder gets the ethereum
    uint256 weiVal = (_mtcTokens * redeemRate);

The first part of the function is transfering the token from the holder to owner by calling an external function in another contract. The second part is transfering the ethereum for each token transfered.

Does the first part will work in a synced manner (i.e. the code will run line by line) OR the execution of second part can happen even if the execution of first part is not completed?

Are there any security flaws (like re-entry attack etc)?


It all happens in a single thread in the EVM.

There is a reentrancy attack, which basically means a "recursive" call, when the same function is called while the previous execution of this function is not finished yet. You can read more here https://consensys.github.io/smart-contract-best-practices/known_attacks/#reentrancy


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.