0

I am new to Ethereum and I deployed a contract in Ganache which has a function like this:

function withdraw(uint256 amount) public payable returns(bool) {
    require(accounts[msg.sender].balance >= amount);
    accounts[msg.sender].balance -= amount;
    bool r = msg.sender.send(amount);
    if (!r){
        accounts[msg.sender].balance += amount;
    }
    return r;   
}

Then, I use Truffle console to send transactions calling function withdraw. I expected there should be two transactions: one is calling function withdraw and another is the contract sending ether to the sender, which is a result of msg.sender.send(amount).

But I only got one transaction in Ganache which about calling function withdraw.

Am I understanding <address>.send() wrong?

0

This answer is quoted from others.

The transfer() or send() or call() function doesn't result in a transaction. It results in a message call inside the original transaction initiated by an external account. The blockchain will record a single transaction no matter how many transfer() or call() or send() invocations there are in the code.

I just put the link here for reference.

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.