계약에 이더 입금
Sep 30 2020
기사에 설명 된대로 배포 된 계약에 아래 세 가지 기능을 추가했습니다. https://programtheblockchain.com/posts/2017/12/15/writing-a-contract-that-handles-ether/
Rinkeby에서 Remix를 사용하여 배포했습니다. Remix의 입금 거래에 1 Ether를 입력하면 "Gas Estimation Failed"오류가 발생합니다.
예금 기능에서 오류가 발생하는 이유는 무엇입니까?
감사합니다
function withdraw () public {msg.sender.transfer (address (this) .balance); }
function deposit(uint256 amount) payable public {
require(msg.value == amount);
// nothing else to do!
}
function getBalance() public view returns (uint256) {
return address(this).balance;
}
최신 정보
폴백 기능을 사용하려고했지만 Remix는 좋아하지 않습니다.
pragma 견고성> = 0.4.0 <0.7.0;
감사합니다
답변
1 Picard78 Sep 30 2020 at 15:48
- 아래 폴백 기능을 사용했는데 효과가있었습니다.
receive() external payable {}
- 이 게시물은 원래 질문에서 실제로 찾고 있던 것입니다. 이제 모든 것이 잘 작동합니다.
Remix를 사용하여 계약에 Ether를 함수로 보내는 방법은 무엇입니까?