Skip to content

Instantly share code, notes, and snippets.

@rpaskin
Created September 23, 2024 14:03
Show Gist options
  • Save rpaskin/88896a488e3e0cd15ad8fa187783b5b6 to your computer and use it in GitHub Desktop.
Save rpaskin/88896a488e3e0cd15ad8fa187783b5b6 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
contract ArmazenarAcoes {
mapping (address => uint) acoes;
address public proprietario;
constructor() {
proprietario = msg.sender;
}
function armazenar(uint _num, address _endereco) public {
require(msg.sender == proprietario, "Somente o proprietario pode armazenar");
require(acoes[_endereco] == 0);
acoes[_endereco] = _num;
}
function recuperar(address _endereco) public view returns (uint _acoes) {
return acoes[_endereco];
}
function transferir(address _destino, uint _quantidade) public {
require(acoes[msg.sender] >= _quantidade, "Nao ha saldo suficiente");
require(msg.sender != _destino, "Nao pode transferir para si mesmo");
acoes[_destino] += _quantidade;
acoes[msg.sender] -= _quantidade;
}
}
// Sepolia: 0x7b40fF8763D76FEA2BaeC0f2c5C81B5a46D9A95C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment