Created
July 12, 2025 19:38
-
-
Save rpaskin/5d31339e9882940f3c951279f91898db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: GPL-3.0 | |
| pragma solidity >=0.8.2 <0.9.0; | |
| contract Carro { | |
| address payable public dono_atual; | |
| uint256 public renavam; | |
| uint256 public valor; | |
| constructor(uint256 _renavam, uint256 _valor) { | |
| renavam = _renavam; | |
| valor = _valor; | |
| dono_atual = payable(msg.sender); | |
| } | |
| function comprar() external payable { | |
| address payable dono_anterior = dono_atual; | |
| require(msg.value >= valor, "Valor e menor!!"); | |
| dono_anterior.transfer(valor); | |
| dono_atual = payable(msg.sender); | |
| if(msg.value > valor){ | |
| uint troco = msg.value - valor; | |
| dono_atual.transfer(troco); | |
| } | |
| } | |
| } | |
| // function guarda(uint8 _num) public { | |
| // numero = _num; | |
| // } | |
| // function devolve() public view returns (uint8){ | |
| // return numero; | |
| // } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Endereço do contrato na rede SEPOLIA
0xD5E74F5DDECc934d381D0BAa06006eC44a4E0782