I created a smart contract that should execute a function after its called by two owners, if and only if both owners call for function X, then this function is performed. It's like a multi signature type. My code is below, but its still not operational. The contract should send 1 Ether to the Wallet account after its called by the two Owners. Please, any one could help me. Thanks in advance.
`pragma solidity ^0.4.25;
contract MyContract {
address Owner1;
address Owner2;
address Wallet;
mapping(address => bool) signed;
mapping(address => uint) balances;
constructor() public payable {
Owner1 = 0xC20201d915458EF540aDe6068dFe2777E8fa733c;
Owner2 = 0x54201A09ACff6D2A60DcdF8896AFf308FDDC160C;
Wallet = 0x30E09Fa68430Def6978ED1a3E8f5ed473A04024c;
}
function Sign() public {
require (msg.sender == Owner1 || msg.sender == Owner2);
require (signed[msg.sender] == false);
signed[msg.sender] = true;
}
function Reward() public payable returns (string) {
require (signed[Owner1] == true && signed[Owner2] == true);
Wallet.transfer(1 ether);
signed[Owner1] = false;
signed[Oener2] = false;
}
}
`
In this code below first you need to deposit some ether from your account to deposit function. and then you can call the sign and reward function
pragma solidity ^0.4.25;
contract MyContract {
address Owner1;
address Owner2;
address Wallet;
mapping(address => bool) signed;
mapping(address => uint) balances;
constructor() public payable {
Owner1 = 0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB;
Owner2 = 0x583031D1113aD414F02576BD6afaBfb302140225;
Wallet = 0xdD870fA1b7C4700F2BD7f44238821C26f7392148;
}
function deposit() payable returns(bool success) {
balances[msg.sender] +=msg.value;
return true;
}
function Sign() public {
require (msg.sender == Owner1 || msg.sender == Owner2);
require (signed[msg.sender] == false);
signed[msg.sender] = true;
}
function Reward() public payable returns (string) {
require (signed[Owner1] == true && signed[Owner2] == true);
Wallet.transfer(1 ether);
signed[Owner1] = false;
signed[Owner2] = false;
}
}